Instructions to use psikosen/snow_spike with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use psikosen/snow_spike with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("psikosen/snow_spike") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use psikosen/snow_spike with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "psikosen/snow_spike" --prompt "Once upon a time"
- Atomic Chat
File size: 6,541 Bytes
1e12712 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | """
Example usage of the decay module.
"""
from src.decay import (
apply_continuous_decay, calculate_discrete_decay_multiplier,
apply_discrete_decay_factor, DecayManager
)
from src.utils.common import DecayStrategy
import time
import numpy as np
import matplotlib.pyplot as plt
def main():
print("Decay Mechanisms Example")
print("----------------------")
# Parameters
initial_value = 1.0
decay_lambda = 0.01 # Decay rate
# Current time
current_time = time.time()
# Continuous decay example
print("\nContinuous Decay Example:")
time_points = np.array([0, 1, 6, 12, 24, 48, 72]) * 3600 # Hours to seconds
print(" Decay over time:")
for dt in time_points:
initial_timestamp = current_time - dt
decayed = apply_continuous_decay(
initial_value, initial_timestamp, current_time, decay_lambda
)
print(f" After {dt/3600:.1f} hours: {decayed:.5f}")
# Discrete decay example
print("\nDiscrete Decay Example:")
intervals = np.array([1, 6, 12, 24]) * 3600 # Hours to seconds
print(" Decay multipliers for different intervals:")
for interval in intervals:
multiplier = calculate_discrete_decay_multiplier(decay_lambda, interval)
print(f" Interval: {interval/3600:.1f} hours -> Multiplier: {multiplier:.5f}")
# Compare continuous vs. discrete decay
print("\nContinuous vs. Discrete Decay Comparison:")
# Parameters
discrete_interval = 24 * 3600 # 1 day in seconds
simulation_days = 30
# Create time points for plotting
days = np.linspace(0, simulation_days, 1000)
hours = days * 24
seconds = hours * 3600
# Calculate continuous decay
continuous_values = [
apply_continuous_decay(initial_value, current_time, current_time + t, decay_lambda)
for t in seconds
]
# Calculate discrete decay
discrete_multiplier = calculate_discrete_decay_multiplier(decay_lambda, discrete_interval)
discrete_values = []
current_value = initial_value
for day in range(simulation_days + 1):
# Get value at the start of each day
day_seconds = day * 24 * 3600
day_hours = day * 24
# Apply decay for completed days
if day > 0:
current_value = apply_discrete_decay_factor(current_value, discrete_multiplier)
# Record value
discrete_values.append((day_hours, current_value))
# Print comparison at key points
print(" Value comparison at key days:")
comparison_days = [0, 1, 7, 14, 30]
for day in comparison_days:
cont_idx = np.abs(days - day).argmin()
disc_idx = next((i for i, (h, _) in enumerate(discrete_values) if h == day * 24), None)
cont_value = continuous_values[cont_idx]
disc_value = next((v for h, v in discrete_values if h == day * 24), None)
print(f" Day {day}:")
print(f" Continuous: {cont_value:.5f}")
print(f" Discrete: {disc_value:.5f}")
if disc_value is not None:
print(f" Difference: {abs(cont_value - disc_value):.5f}")
# Decay manager example
print("\nDecay Manager Example:")
# Create manager with continuous strategy
manager = DecayManager(
strategy=DecayStrategy.CONTINUOUS_ON_READ,
decay_lambda=decay_lambda
)
print(" Testing different strategies:")
# Test with continuous strategy
manager.strategy = DecayStrategy.CONTINUOUS_ON_READ
continuous_result = manager.decay_value(
initial_value,
timestamp=current_time - 7*24*3600 # 7 days ago
)
print(f" Continuous (after 7 days): {continuous_result:.5f}")
# Test with no decay
manager.strategy = DecayStrategy.NO_DECAY
no_decay_result = manager.decay_value(
initial_value,
timestamp=current_time - 7*24*3600 # 7 days ago
)
print(f" No Decay (after 7 days): {no_decay_result:.5f}")
# Test with discrete (should return original value on read)
manager.strategy = DecayStrategy.DISCRETE_BATCH
discrete_result = manager.decay_value(
initial_value,
timestamp=current_time - 7*24*3600 # 7 days ago
)
print(f" Discrete (on read, after 7 days): {discrete_result:.5f}")
# Configure from dictionary
config = {
"strategy": "CONTINUOUS_ON_READ",
"decay_lambda": 0.02,
"batch_interval": 12 * 3600 # 12 hours
}
manager.configure_from_dict(config)
print("\n After configuration from dictionary:")
print(f" Strategy: {manager.strategy}")
print(f" Decay Lambda: {manager.decay_lambda}")
print(f" Batch Interval: {manager.batch_interval / 3600} hours")
# Visualize decay
try:
plt.figure(figsize=(15, 5))
# Plot 1: Continuous decay over time
plt.subplot(1, 3, 1)
plt.plot(days, continuous_values)
plt.xlabel('Days')
plt.ylabel('Value')
plt.title(f'Continuous Decay (λ = {decay_lambda})')
plt.grid(True)
# Plot 2: Comparison of continuous vs. discrete decay
plt.subplot(1, 3, 2)
plt.plot(days, continuous_values, label='Continuous')
# Extract x and y values from discrete_values
discrete_x = [h/24 for h, _ in discrete_values]
discrete_y = [v for _, v in discrete_values]
plt.plot(discrete_x, discrete_y, 'o-', label='Discrete (Daily)')
plt.xlabel('Days')
plt.ylabel('Value')
plt.title('Continuous vs. Discrete Decay')
plt.legend()
plt.grid(True)
# Plot 3: Effect of different decay rates
plt.subplot(1, 3, 3)
lambda_values = [0.005, 0.01, 0.02, 0.05]
for lam in lambda_values:
vals = [apply_continuous_decay(initial_value, current_time, current_time + t, lam)
for t in seconds]
plt.plot(days, vals, label=f'λ = {lam}')
plt.xlabel('Days')
plt.ylabel('Value')
plt.title('Effect of Different Decay Rates')
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.savefig('decay_example.png')
print("\nVisualization saved as 'decay_example.png'")
except Exception as e:
print(f"\nCould not create visualization: {e}")
if __name__ == "__main__":
main()
|