Text Generation
Transformers
Safetensors
English
gpt2
toy-llm
4bit
quantized
casual-lm
small-llm
text-generation-inference
4-bit precision
bitsandbytes
Instructions to use mehta/CooperLM-354M-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mehta/CooperLM-354M-4bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mehta/CooperLM-354M-4bit")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mehta/CooperLM-354M-4bit") model = AutoModelForCausalLM.from_pretrained("mehta/CooperLM-354M-4bit") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use mehta/CooperLM-354M-4bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mehta/CooperLM-354M-4bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mehta/CooperLM-354M-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/mehta/CooperLM-354M-4bit
- SGLang
How to use mehta/CooperLM-354M-4bit 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 "mehta/CooperLM-354M-4bit" \ --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": "mehta/CooperLM-354M-4bit", "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 "mehta/CooperLM-354M-4bit" \ --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": "mehta/CooperLM-354M-4bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use mehta/CooperLM-354M-4bit with Docker Model Runner:
docker model run hf.co/mehta/CooperLM-354M-4bit
π§ CooperLM-354M (4-bit Quantized)
This is a 4-bit quantized version of CooperLM-354M, a 354M parameter GPT-2 style language model trained from scratch on a subset of Wikipedia, BookCorpus, and OpenWebText.
The quantized model is intended for faster inference and smaller memory footprint, especially useful for CPU or limited-GPU setups.
π Model Details
- Base Model: mehta/CooperLM-354M
- Architecture: GPT-2 (24 layers, 16 heads, 1024 hidden size)
- Quantization: 4-bit integer weights via
AutoGPTQ(safetensors) - Precision: INT4
π οΈ How to Use
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("mehta/CooperLM-354M-4bit")
model = AutoModelForCausalLM.from_pretrained("mehta/CooperLM-354M-4bit")
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.to(device)
prompt = "In the distant future,"
inputs = tokenizer(prompt, return_tensors="pt").to(device)
outputs = model.generate(
**inputs,
max_length=100,
temperature=0.8,
top_p=0.95,
do_sample=True
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- Downloads last month
- 3