🧠 ASFT: Adaptive Synaptic Fine-Tuning
The intelligent LLM training acceleration framework that decides if you actually need to train.
🚀 The Pitch
Most LLM fine-tuning frameworks (Unsloth, Axolotl, LLaMA-Factory) focus entirely on making matrix math faster, assuming you must train. ASFT flips the paradigm: it acts as an intelligent decision engine that treats fine-tuning as a last resort.
Before allocating a single GPU cycle to backpropagation, ASFT systematically evaluates zero-shot reasoning, vector retrieval (RAG), and programmatic skills. If fine-tuning is truly required, ASFT orchestrates highly compressed, automated data pruning and memory-safe training loops. This radically reduces training costs, dataset requirements, and energy consumption—all while maintaining or improving model capability.
⚡ How ASFT Compares to the Ecosystem
When choosing an LLM fine-tuning framework, the decision typically comes down to a trade-off between performance, flexibility, and automation. Here is how ASFT stands out:
| Feature | ASFT (Adaptive Synaptic Fine-Tuning) | Unsloth | Axolotl | LLaMA-Factory | TRL |
|---|---|---|---|---|---|
| Core Philosophy | "Train only if absolutely necessary." | "Squeeze every bit of speed via CUDA kernels." | "Highly customizable YAML-driven reproducible pipelines." | "Abstract complexity with an easy WebUI." | "Provide core RLHF/DPO building blocks." |
| Decision Engine | ✅ Pre-evaluates RAG, Zero-Shot & Skills before training. | ❌ None (blindly executes training). | ❌ None. | ❌ None. | ❌ None. |
| Dataset Pruning | ✅ Auto-prunes redundant/easy samples using FAISS & clustering. | ❌ Manual curation required. | ❌ Manual curation required. | ❌ Manual curation required. | ❌ Manual curation required. |
| Cost Estimation | ✅ Pre-computes exact GPU-hours & USD cost via scaling laws. | ❌ Trial and error. | ❌ Trial and error. | ❌ Trial and error. | ❌ Trial and error. |
| Learning Curve | Low (Intelligent defaults & automation). | Low. | Moderate (Requires deep YAML config knowledge). | Very Low (WebUI). | High (Requires custom training loops). |
Summary:
- Use Unsloth if you know exactly what data you have and just need to train it incredibly fast on a single consumer GPU.
- Use Axolotl for highly customized, distributed, production-level configurations.
- Use LLaMA-Factory if you want a visual UI to prototype quickly.
- Use ASFT if you want an intelligent agent that optimizes your entire ML pipeline—saving you thousands of dollars in compute by preventing unnecessary training and compressing your dataset automatically.
📊 Benchmarks
ASFT is built for speed and efficiency across all subsystems:
- Dataset Compression: Compress a 5,000-sample dataset to just 35 semantically unique samples (0.7% of original size) in ~10 seconds using bounded memory FAISS indices.
- Memory Operations: < 0.04s latency for semantic retrieval among 10,000 embedded items via FTS5 and persistent Qdrant databases.
- Concurrency: Robust multi-process task offloading handling continuous throughput safely under strict enterprise stress testing.
💻 Installation
ASFT is designed to be lightweight and modular.
# Python 3.10+ required
pip install asft
Or install from source with optional extras:
git clone https://github.com/soumyashiv/asft.git
cd asft
# Base installation
pip install -e .
# Optional backend integrations
pip install -e ".[faiss]" # For CPU vector search (Data compression)
pip install -e ".[qdrant]" # For persistent vector memory
pip install -e ".[dev]" # For testing and development
🔍 Analyze before you fine-tune
ASFT is an LLM optimization decision assistant — it runs a 4-stage analysis pipeline and tells you exactly which approach to use before you spend money on fine-tuning.
asft analyze task_config.json
task_config.json — supported fields:
{
"task_name": "customer support chatbot",
"model": "meta-llama/Llama-3",
"dataset": "./dataset.json",
"documents": "./knowledge_base/",
"evaluation_metric": "accuracy"
}
Example output:
================================
ASFT Decision Report
================================
Task: Customer Support Chatbot
Prompt: 72%
RAG: 89%
Fine-tuning: 90% estimated
Recommendation: RAG
Confidence: 97%
Reason:
RAG improves accuracy by 17.0 pp over prompting (72% -> 89%).
Fine-tuning adds only 1.0 pp more while costing $500 and 9 GPU hours.
Avoid unnecessary fine-tuning.
Estimated savings:
$500 GPU cost avoided
9 GPU hours avoided
================================
Python API
from asft import Analyzer
# From a task config dict
report = Analyzer.from_config({
"task_name": "customer support chatbot",
"model": "meta-llama/Llama-3",
"documents": "./knowledge_base/",
}).recommend()
print(report.recommendation.method) # "RAG"
print(report.recommendation.savings_usd) # 500.0
Framework integrations
HuggingFace
from asft import Analyzer
result = Analyzer.from_huggingface(
model="meta-llama/Llama-3",
dataset="my_dataset",
)
result.recommend()
Plug in a real evaluator
Subclass PromptEvaluator or RAGAnalyzer to connect your own benchmark runner:
from asft.analysis import Analyzer, PromptEvaluator, PromptEvaluationResult
class MyEvalHarnessEvaluator(PromptEvaluator):
def evaluate_baseline(self, task_config) -> PromptEvaluationResult:
# call lm-eval-harness, OpenAI Evals, or your own test suite here
score = run_my_benchmark(task_config["model"], task_config["dataset"])
return PromptEvaluationResult(score=score * 100)
report = Analyzer.from_config(task_config, prompt_evaluator=MyEvalHarnessEvaluator()).recommend()
The goal is to prevent unnecessary fine-tuning and reduce LLM development cost.
🛠️ Quickstart
Before you spend hours fine-tuning, ask ASFT's Decision Engine if it is actually required and what the optimal path is:
from asft.optimizer.auto_optimizer import AutoOptimizer
# ASFT evaluates the task against Zero-Shot, RAG, and Skills capabilities
decision = AutoOptimizer().decide(
task="Provide medical triage recommendations based on symptoms",
domain="medical",
target_accuracy=0.92,
budget_usd=50.0
)
print(f"Action: {decision.action} | Reasoning: {decision.reasoning}")
2. Dataset Compression
If the decision engine recommends training, ASFT can automatically compress your dataset to save compute time by extracting only the most semantically unique samples.
from asft.dataset.streaming_compressor import StreamingCompressor
compressor = StreamingCompressor()
# Compress thousands of records into just the critical, highly unique semantic samples
compressed_data, report = compressor.compress_stream(
dataset_path="your_dataset.jsonl",
dataset_format="json",
text_field="instruction"
)
print(f"Original size: {report['original_count']} -> New size: {report['final_count']}")
print(f"Data Reduction: {report['total_reduction'] * 100:.2f}%")
3. Estimating Training Costs
Before spinning up expensive cloud GPUs, predict exactly how much the fine-tuning job will cost.
from asft.optimizer.cost_estimator import CostEstimator
estimator = CostEstimator()
projection = estimator.estimate(
model_name="Qwen/Qwen2-7B",
dataset_size=5_000,
method="qlora"
)
print(f"Estimated Cost: ${projection.cost_usd:.2f}")
print(f"GPU Hours Required: {projection.gpu_hours:.2f}")
4. Intelligent Routing (Bandit Learning)
When multiple models or strategies are available, ASFT uses a Multi-Armed Bandit router to balance exploration (trying new methods) and exploitation (using the best known method) based on historical success rates.
from asft.optimizer.decision_engine import MultiArmedBanditRouter
router = MultiArmedBanditRouter()
# Dynamically select between RAG and QLoRA for a specific task
strategy, is_explore = router.select_strategy(
task_hash="task_medical_triage_001",
available_strategies=["memory_rag", "qlora"]
)
print(f"Selected Strategy: {strategy} (Exploration Mode: {is_explore})")
# Later, record the success to train the router for future queries
router.record_outcome(task_hash="task_medical_triage_001", strategy=strategy, success=True)
5. Managing Stateful Memory
ASFT includes a full-fledged Memory Manager handling Working Memory (Key-Value), Semantic Memory (Knowledge Graphs), and Episodic Memory (Event Logs).
from asft.memory.memory_manager import MemoryManager
memory = MemoryManager(session_id="session_001")
# 1. Store short-term context
memory.remember(key="patient_id", value="PT-8942", tags=["medical", "active"])
# 2. Learn a permanent semantic fact
fact_id = memory.learn_fact(
subject="PT-8942",
predicate="diagnosed_with",
obj="Hypertension",
confidence=0.95
)
# 3. Record an episodic event
memory.record_task_event(
event_type="consultation",
context={"patient": "PT-8942"},
outcome={"action": "prescribed_medication"},
success=True
)
🛡️ Architecture & Security
ASFT is designed for robust enterprise deployment:
- Zero-Execution Verification: The framework's verification layers never execute LLM-generated code. Validation uses strictly AST-based parsing (
RestrictedPython) and the SymPy Computer Algebra System. - Bounded Persistent Memory: Fast, O(1) semantic lookups via SQLite FTS5 inverted indices and Qdrant Vector databases.
- Memory-Safe Work Queues: The API server delegates intensive GPU compute to sandboxed isolated processes via
ProcessPoolExecutorprotecting the main application from CUDA Out-Of-Memory crashes.
Status
Current Version: 0.1.0 (Production Ready)
Security Posture: Hardened
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asft-0.2.0.tar.gz.
File metadata
- Download URL: asft-0.2.0.tar.gz
- Upload date:
- Size: 177.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9fe81220f764ca4ce78ce47e5ab6b88dde764131c35f435a1c12c6e78563582
|
|
| MD5 |
e878b9dc59c7635d8c8de1234f4a2f75
|
|
| BLAKE2b-256 |
65b8376416b213e97c9a1daa7fd5308a4bdb4764956109b0772880a0c6a275f9
|
File details
Details for the file asft-0.2.0-py3-none-any.whl.
File metadata
- Download URL: asft-0.2.0-py3-none-any.whl
- Upload date:
- Size: 196.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9c7677edcf61574d5789ee49bab46cd809363bae612fd68cf785ed7026b1fc3
|
|
| MD5 |
6698850056acb817347811b4e16c27de
|
|
| BLAKE2b-256 |
9183542ba0159be100a9033b00b928f11b935bcd68b661bcc515a7c218ad406d
|