MuratcanKoylan/Marketing-Memory-Routing-8B
1
1---2license: apache-2.03language:4- en5tags:6- memory-routing7- marketing8- classification9- llama10- lora11- tinker12base_model: meta-llama/Llama-3.1-8B13datasets:14- muratcankoylan/memory-routing-marketing15metrics:16- f117- accuracy18pipeline_tag: text-classification19---20 21# Memory Routing Agent (Llama-8B + LoRA)22 23A specialized 8B parameter model that **outperforms 104B models** on marketing conversation classification.24 25## Key Results26 27| Model | Size | Avg F1 | Exact Match |28|-------|------|--------|-------------|29| **This Model** | 8B | **0.68** | **60%** |30| Cohere Command-R-Plus | 104B | 0.61 | 26% |31 32**11.1% higher F1** than the 104B teacher model that generated its training data.33 34## Model Description35 36The Memory Routing Agent classifies marketing conversations into 13 memory categories:37 38### Company Categories39- `company.brand_core` - Voice, values, positioning40- `company.strategic_signatures` - Decision frameworks41- `company.knowledge_artifacts` - Docs, style guides42- `company.business_priorities` - Quarterly goals43- `company.tools_config` - Integrations, APIs44- `company.performance_context` - Campaign metrics45 46### User Categories47- `user.communication_style` - Tone, format preferences48- `user.strategic_approach` - Personal priorities49- `user.role_context` - Title, scope50- `user.workflow_patterns` - Review cadence51- `user.session_history` - Immediate context52- `user.interaction_preferences` - Coaching style53 54### Special55- `none` - Transactional or irrelevant content56 57## Training58 59- **Base Model**: meta-llama/Llama-3.1-8B60- **Method**: LoRA (rank 32) + SFT + RL61- **Platform**: Tinker (Thinking Machines)62- **Dataset**: 2,001 synthetic marketing conversations63- **Teacher**: Cohere Command-R-Plus (104B)64 65### Training Pipeline66 671. **SFT Phase**: 100 steps, batch size 128, cross-entropy loss682. **RL Phase**: 12 iterations, importance sampling policy gradient693. **Reward**: 0.6×F1 + 0.2×temporal + 0.1×parity + 0.1×efficiency70 71## Usage72 73```python74# Note: This model was trained on Tinker platform75# The checkpoint is: tinker://4f4bae1f-5a95-5f53-a55a-a14f2872825c:train:0/sampler_weights/rl_iter_01276 77import tinker78from tinker import types79from tinker_cookbook import renderers80from tinker_cookbook.tokenizer_utils import get_tokenizer81 82service_client = tinker.ServiceClient()83checkpoint = "tinker://4f4bae1f-5a95-5f53-a55a-a14f2872825c:train:0/sampler_weights/rl_iter_012"84sampling_client = service_client.create_sampling_client(model_path=checkpoint)85 86tokenizer = get_tokenizer("meta-llama/Llama-3.1-8B")87renderer = renderers.get_renderer(name="llama3", tokenizer=tokenizer)88 89conversation = """90USER: Our brand voice is professional but approachable.91ASSISTANT: So authoritative content with a conversational tone?92USER: Exactly. We never use jargon without explaining it first.93"""94 95messages = [96 {"role": "system", "content": "You route marketing conversations into structured memory categories..."},97 {"role": "user", "content": f"Analyze this conversation:\n\n{conversation}"}98]99 100prompt = renderer.build_generation_prompt(messages)101params = types.SamplingParams(max_tokens=100, temperature=0.1, stop=renderer.get_stop_sequences())102result = sampling_client.sample(prompt=prompt, sampling_params=params, num_samples=1).result()103 104response, _ = renderer.parse_response(result.sequences[0].tokens)105print(f"Categories: {response['content']}")106# Output: company.brand_core107```108 109## Benchmark110 11150 challenging marketing scenarios across 7 domains:112 113| Difficulty | Our Model | Cohere (104B) |114|------------|-----------|---------------|115| Easy | 0.86 F1 | 0.48 F1 |116| Medium | 0.65 F1 | 0.64 F1 |117| Hard | 0.50 F1 | 0.72 F1 |118 119## Limitations120 121- Under-predicts multi-label scenarios122- Sometimes confuses company vs user categories123- Marketing-specific; not tested on other domains124 125## Citation126 127```bibtex128@misc{memory-routing-agent-2024,129 title={Memory Routing Agent: Prompt Distillation for Marketing AI},130 author={Muratcan Koylan},131 year={2024},132 howpublished={\url{https://github.com/muratcankoylan/memory-routing-agent}},133}134```135 136## Links137 138- **GitHub**: [muratcankoylan/memory-routing-agent](https://github.com/muratcankoylan/memory-routing-agent)139- **Training Platform**: [Tinker by Thinking Machines](https://thinkingmachines.ai/)140 141 