Instructions to use botverse/Titans-MAC-Llama-3-8b-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use botverse/Titans-MAC-Llama-3-8b-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="botverse/Titans-MAC-Llama-3-8b-Instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("botverse/Titans-MAC-Llama-3-8b-Instruct", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("botverse/Titans-MAC-Llama-3-8b-Instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use botverse/Titans-MAC-Llama-3-8b-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "botverse/Titans-MAC-Llama-3-8b-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "botverse/Titans-MAC-Llama-3-8b-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/botverse/Titans-MAC-Llama-3-8b-Instruct
- SGLang
How to use botverse/Titans-MAC-Llama-3-8b-Instruct 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 "botverse/Titans-MAC-Llama-3-8b-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "botverse/Titans-MAC-Llama-3-8b-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "botverse/Titans-MAC-Llama-3-8b-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "botverse/Titans-MAC-Llama-3-8b-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use botverse/Titans-MAC-Llama-3-8b-Instruct with Docker Model Runner:
docker model run hf.co/botverse/Titans-MAC-Llama-3-8b-Instruct
Memory-Augmented Llama Model (Llama-3-8B-Instruct)
This repository contains the base weights for Llama-3-8B-Instruct packaged with custom code for the InferenceMemoryWrapper.
This allows loading the model with memory capabilities using trust_remote_code=True.
Model Details
- Base Model: Llama-3-8B-Instruct
- Wrapper:
InferenceMemoryWrapper - Memory Size: 4096
- Memory Dims: 4096
- Memory Storage (approx): 64.0 MB (FP16, buffer + state) if buffer/state exist
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch # Added import for example
model_id = "your-username/your-repo-name" # Replace with your repo ID
# Load the model and tokenizer, allowing custom code execution
# Requires sufficient VRAM for the Llama 8B model + memory buffer
model = AutoModelForCausalLM.from_pretrained(
model_id,
trust_remote_code=True,
torch_dtype=torch.float16, # Recommended for memory
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Example prompt
prompt = "What is the capital of France?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
# Generate using the custom method
# Note: The memory buffer is initially randomly initialized unless loaded separately.
# It will be updated during generation if update_rule is 'ema' or 'surprise'.
outputs = model.generate(
**inputs,
max_new_tokens=50,
use_memory=True,
update_rule='ema' # or 'surprise' or 'none'
)
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_text)
# To save user-specific memory state (after generation/updates):
# user_memory_state = model.memory_buffer.data.clone()
# user_surprise_state = model.surprise_state.clone()
# torch.save({'memory_buffer': user_memory_state, 'surprise_state': user_surprise_state}, 'user_memory.pt')
# To load user-specific memory state:
# loaded_state = torch.load('user_memory.pt')
# model.memory_buffer.data.copy_(loaded_state['memory_buffer'])
# model.surprise_state.copy_(loaded_state['surprise_state'])
Important: The memory_buffer and surprise_state in this packaged model are initialized randomly according to the InferenceMemoryWrapper code. They do not contain any pre-trained memory state unless you load it separately after initializing the model (see example above). You need to manage loading/saving the memory state per user externally.
- Downloads last month
- 2