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
Download examples/decay_example.py from psikosen/snow_spike: direct link, hf CLI and curl.
- Browser
- Download file 6.54 kB
-
https://huggingface.co/psikosen/snow_spike/resolve/main/examples/decay_example.py
- Command line
-
hf download hf://psikosen/snow_spike/examples/decay_example.py
-
curl -L -o decay_example.py https://huggingface.co/psikosen/snow_spike/resolve/main/examples/decay_example.py
6.54 kB
| """ | |
| 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() | |