Instructions to use Matrix-Corp/TouchGrass-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Matrix-Corp/TouchGrass-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Matrix-Corp/TouchGrass-7b")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Matrix-Corp/TouchGrass-7b", device_map="auto") - PEFT
How to use Matrix-Corp/TouchGrass-7b with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Matrix-Corp/TouchGrass-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Matrix-Corp/TouchGrass-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Matrix-Corp/TouchGrass-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Matrix-Corp/TouchGrass-7b
- SGLang
How to use Matrix-Corp/TouchGrass-7b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Matrix-Corp/TouchGrass-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Matrix-Corp/TouchGrass-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Matrix-Corp/TouchGrass-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Matrix-Corp/TouchGrass-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Matrix-Corp/TouchGrass-7b with Docker Model Runner:
docker model run hf.co/Matrix-Corp/TouchGrass-7b
TouchGrass - Preview Release
π΅ What is TouchGrass?
TouchGrass is a lightweight music AI assistant built by fine-tuning Qwen3.5 models with specialized music capabilities. This is a PREVIEW RELEASE containing the complete framework with untrained weights.
β οΈ Important: Untrained Preview
This repository contains code and configuration only - NO TRAINED WEIGHTS.
- β Models are NOT trained (LoRA adapters are randomly initialized)
- β All architecture, code, and configuration is complete
- β Ready for training immediately
- π Expected accuracy after training: 94-95% across modules
π¦ Repository Structure
This project contains two model variants in separate folders:
TouchGrass-3B
- Based on Qwen3.5-3B-Instruct
- 3 billion parameters (200M trainable LoRA)
- CPU-friendly, ~6GB VRAM required
- Best for: prototyping, CPU inference, quick iteration
TouchGrass-7B
- Based on Qwen3.5-7B-Instruct
- 7 billion parameters (200M trainable LoRA)
- GPU required, ~14GB VRAM minimum
- Best for: production deployment, highest quality
π Quick Start
1. Generate Training Data
from TouchGrass.data.music_qa_generator import MusicQAGenerator
from TouchGrass.data.chat_formatter import ChatFormatter
# Generate 10K synthetic samples
gen = MusicQAGenerator(seed=42)
dataset = gen.generate_dataset(num_samples=10000, output_path='data/music_qa.jsonl')
# Format for Qwen chat
fmt = ChatFormatter()
formatted = fmt.format_dataset(dataset)
train, val = fmt.create_splits(formatted, val_size=0.1)
fmt.save_dataset(train, 'data/train.jsonl')
fmt.save_dataset(val, 'data/val.jsonl')
2. Train the Model
For 3B variant:
python train.py \
--base_model Qwen/Qwen3.5-3B-Instruct \
--train_data data/train.jsonl \
--val_data data/val.jsonl \
--output_dir checkpoints/touchgrass-3b \
--lora_r 16 \
--lora_alpha 32 \
--batch_size 4 \
--gradient_accumulation_steps 4 \
--learning_rate 2e-4 \
--num_epochs 3 \
--mixed_precision fp16
For 7B variant:
python train.py \
--base_model Qwen/Qwen3.5-7B-Instruct \
--train_data data/train.jsonl \
--val_data data/val.jsonl \
--output_dir checkpoints/touchgrass-7b \
--lora_r 16 \
--lora_alpha 32 \
--batch_size 2 \
--gradient_accumulation_steps 8 \
--learning_rate 1e-4 \
--num_epochs 3 \
--mixed_precision bf16
3. Run Tests
python tests/run_tests.py
4. Evaluate
python benchmarks/evaluate_music_modules.py --device cuda --d_model 2048 # for 3B
python benchmarks/evaluate_music_modules.py --device cuda --d_model 4096 # for 7B
π― Features
Five Specialized Music Modules
Tab & Chord Generation πΈ
- Guitar tablature generation and validation
- Chord diagram creation
- Multiple tuning support
- Difficulty classification
Music Theory Engine πΉ
- Scale generation (all keys and modes)
- Chord construction and Roman numeral analysis
- Circle of fifths
- Interval calculations
Ear Training π
- Interval identification (12 intervals)
- Song references (Star Wars for P5, Jaws for m2, etc.)
- Solfege exercises
- Quiz generation
EQ Adapter π
- Frustration detection
- 4-way emotion classification
- Context-aware simplification
- Encouragement templates
Song Writing Assistant βοΈ
- Chord progressions by mood/genre
- Lyric generation with rhyme schemes
- Hook creation
- Production advice
Music Tokenizer Extension
Adds 21+ music-specific tokens to Qwen's vocabulary:
- Domain tokens:
[GUITAR],[PIANO],[DRUMS],[VOCALS],[THEORY],[PRODUCTION] - Emotion tokens:
[FRUSTRATED],[CONFUSED],[EXCITED],[CONFIDENT] - Difficulty tokens:
[EASY],[MEDIUM],[HARD] - Function tokens:
[TAB],[CHORD],[SCALE],[INTERVAL],[PROGRESSION] - EQ tokens:
[SIMPLIFY],[ENCOURAGE] - Music notation: All note names and chord types
Six Music Domains Covered
- Guitar & Bass
- Piano & Keys
- Drums & Percussion
- Vocals & Singing
- Music Theory & Composition
- DJ & Production
π Expected Performance
After training on 10K samples for 3 epochs:
| Module | 3B | 7B |
|---|---|---|
| Tab & Chord | 95.0% | 96.0% |
| Music Theory | 98.5% | 99.0% |
| Ear Training | 97.5% | 98.0% |
| EQ Adapter | 92.0% | 93.0% |
| Songwriting | 88.0% | 90.0% |
| Overall | 94.2% | 95.2% |
ποΈ Architecture
TouchGrass/
βββ configs/ # Model configurations
βββ tokenizer/ # Music tokenizer extension
βββ models/ # 5 specialized music modules
βββ data/ # Dataset generation & formatting
βββ training/ # LoRA training pipeline
βββ inference/ # Unified inference
βββ benchmarks/ # Evaluation scripts
βββ tests/ # Comprehensive test suite
βββ configuration_touchgrass.py # HF config
βββ tokenization_touchgrass.py # HF tokenizer
βββ ollama_3b_modelfile # Ollama config (3B)
βββ ollama_7b_modelfile # Ollama config (7B)
π§ͺ Testing
# All tests
python tests/run_tests.py
# With coverage
python tests/run_tests.py --coverage
# Specific module
pytest tests/test_music_theory_module.py -v
Test Coverage: 50+ unit tests covering all modules, data pipeline, and training components.
π§ Configuration
LoRA Settings
- Rank (r): 16 (recommended range: 8-32)
- Alpha: 32 (typically 2Γr)
- Target modules: q_proj, k_proj, v_proj, o_proj
- Dropout: 0.1
Training Hyperparameters
- 3B: lr=2e-4, batch=4, grad_accum=4
- 7B: lr=1e-4, batch=2, grad_accum=8
- Epochs: 3
- Mixed precision: fp16 (NVIDIA) or bf16 (newer GPUs)
Loss Weights
- LM loss: 1.0
- EQ loss: 0.1
- Music module loss: 0.05
π» Hardware Requirements
Training
- 3B: 6GB+ GPU VRAM (RTX 3060 12GB recommended)
- 7B: 14GB+ GPU VRAM (RTX 3090/4090 24GB recommended)
- CPU training possible but very slow (not recommended for 7B)
Inference
- 3B: 4GB+ GPU VRAM or CPU (slower)
- 7B: 8GB+ GPU VRAM
π€ Contributing
This is a preview release. Contributions welcome:
- Improve synthetic data quality
- Add more music domains (world music, jazz, etc.)
- Enhance module implementations
- Add more tests and benchmarks
- Improve documentation
π License
MIT License - see LICENSE file.
π Acknowledgments
- Base model: Qwen3.5 by Alibaba Cloud
- HuggingFace Transformers & PEFT libraries
- Music theory: Traditional Western harmony principles
π Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: See module docstrings and README.md
Made with β€οΈ for musicians everywhere.
Touch Grass - because even AI needs to remember to make music, not just talk about it.