Instructions to use nraesalmi/tinyllama-kalevala-chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nraesalmi/tinyllama-kalevala-chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nraesalmi/tinyllama-kalevala-chat") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nraesalmi/tinyllama-kalevala-chat") model = AutoModelForCausalLM.from_pretrained("nraesalmi/tinyllama-kalevala-chat", device_map="auto") 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 Settings
- vLLM
How to use nraesalmi/tinyllama-kalevala-chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nraesalmi/tinyllama-kalevala-chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nraesalmi/tinyllama-kalevala-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nraesalmi/tinyllama-kalevala-chat
- SGLang
How to use nraesalmi/tinyllama-kalevala-chat 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 "nraesalmi/tinyllama-kalevala-chat" \ --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": "nraesalmi/tinyllama-kalevala-chat", "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 "nraesalmi/tinyllama-kalevala-chat" \ --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": "nraesalmi/tinyllama-kalevala-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nraesalmi/tinyllama-kalevala-chat with Docker Model Runner:
docker model run hf.co/nraesalmi/tinyllama-kalevala-chat
TinyLlama Kalevala Chat Model
This is a fine-tuned version of TinyLlama/TinyLlama-1.1B-Chat, adapted to answer questions about the Finnish national epic, the Kalevala. The model was fine-tuned using LoRA (Low-Rank Adaptation) on a curated dataset of prompt-response pairs derived from the Kalevala's characters, events, and symbolism.
π§ Model Description
- Base model:
TinyLlama-1.1B-Chat - Parameter count: 1.1B
- Fine-tuning method: LoRA using Hugging Face Transformers and PEFT
- Dataset: nraesalmi/kalevala-dataset, consisting of 300 structured prompt-response pairs
- Language: English (with content related to Finnish culture and mythology)
ποΈ Example Usage
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model = AutoModelForCausalLM.from_pretrained("nraesalmi/tinyllama-kalevala-chat")
tokenizer = AutoTokenizer.from_pretrained("nraesalmi/tinyllama-kalevala-chat")
chat = pipeline("text-generation", model=model, tokenizer=tokenizer)
chat("Tell me about the Sampo in the Kalevala:")
π§Ύ Example Output
"The Sampo is a magical artifact in the Kalevala, forged by the smith Ilmarinen. It brings prosperity by grinding out salt, grain, and gold. The struggle for control of the Sampo is a central theme in the epic."
π Intended Use
This model is intended for educational, cultural, and research purposes related to Finnish literature and mythology. It may also be useful for generating creative narratives or teaching materials about the Kalevala.
π Limitations
The model may hallucinate or provide incorrect historical details outside its fine-tuned scope.
While aligned to be informative, it does not always follow factual sources beyond its training data.
π License
The model follows the same license as the original TinyLlama base model (Apache 2.0). The fine-tuning dataset is public domain or derived from freely accessible summaries and interpretations of the Kalevala.
βοΈ Author
Fine-tuned and published by nraesalmi
- Downloads last month
- 4
Model tree for nraesalmi/tinyllama-kalevala-chat
Base model
TinyLlama/TinyLlama-1.1B-Chat-v1.0