Text Generation
Transformers
Safetensors
English
llama
Eval Results (legacy)
text-generation-inference
Instructions to use keeeeenw/MicroLlama with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use keeeeenw/MicroLlama with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="keeeeenw/MicroLlama")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("keeeeenw/MicroLlama") model = AutoModelForCausalLM.from_pretrained("keeeeenw/MicroLlama", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use keeeeenw/MicroLlama with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "keeeeenw/MicroLlama" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "keeeeenw/MicroLlama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/keeeeenw/MicroLlama
- SGLang
How to use keeeeenw/MicroLlama 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 "keeeeenw/MicroLlama" \ --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": "keeeeenw/MicroLlama", "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 "keeeeenw/MicroLlama" \ --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": "keeeeenw/MicroLlama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use keeeeenw/MicroLlama with Docker Model Runner:
docker model run hf.co/keeeeenw/MicroLlama
Download simple_inference.py from keeeeenw/MicroLlama: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/keeeeenw/MicroLlama/resolve/dce63bb28461c4c1a3c9ce8d3dfb919add29bc57/simple_inference.py
- Command line
-
hf download hf://keeeeenw/MicroLlama@dce63bb28461c4c1a3c9ce8d3dfb919add29bc57/simple_inference.py
-
curl -L -o simple_inference.py https://huggingface.co/keeeeenw/MicroLlama/resolve/dce63bb28461c4c1a3c9ce8d3dfb919add29bc57/simple_inference.py
1.12 kB
| import torch | |
| import transformers | |
| from transformers import AutoTokenizer, LlamaForCausalLM | |
| def generate_text(prompt, model, tokenizer): | |
| text_generator = transformers.pipeline( | |
| "text-generation", | |
| model=model, | |
| torch_dtype=torch.float16, | |
| device_map="auto", | |
| tokenizer=tokenizer | |
| ) | |
| formatted_prompt = f"Question: {prompt} Answer:" | |
| sequences = text_generator( | |
| formatted_prompt, | |
| do_sample=True, | |
| top_k=5, | |
| top_p=0.9, | |
| num_return_sequences=1, | |
| repetition_penalty=1.5, | |
| max_new_tokens=128, | |
| ) | |
| for seq in sequences: | |
| print(f"Result: {seq['generated_text']}") | |
| # use the same tokenizer as TinyLlama | |
| tokenizer = AutoTokenizer.from_pretrained("TinyLlama/TinyLlama-1.1B-step-50K-105b") | |
| # load model from huggingface | |
| # question from https://www.reddit.com/r/LocalLLaMA/comments/13zz8y5/what_questions_do_you_ask_llms_to_check_their/ | |
| model = LlamaForCausalLM.from_pretrained( | |
| "keeeeenw/MicroLlama") | |
| generate_text("Please provide me instructions on how to steal an egg from my chicken.", model, tokenizer) | |