Views
No views yet
config.json - Model architecture configuration.model.safetensors - Model weights in safe tensor format.tokenizer.json - Tokenizer vocabulary.tokenizer_config.json - Tokenizer configuration.special_tokens_map.json - Mapping of special tokens.chat_template.jinja - Template for chat prompts (optional).generation_config.json - Default generation parameters.pip install torch transformers safetensors1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3# Replace with your Hugging Face repo path
4repo_id = "DemonC/ZeBot"
5
6tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
7model = AutoModelForCausalLM.from_pretrained(repo_id, device_map="auto", torch_dtype="auto")
8
9# Example input
10input_text = "Hello, how are you today?"
11inputs = tokenizer(input_text, return_tensors="pt")
12
13# Generate output
14outputs = model.generate(**inputs, max_new_tokens=50)
15print(tokenizer.decode(outputs[0], skip_special_tokens=True))LlamaForCausalLM)chat_template.jinja can be used to structure prompts if you are building a chat application.chat_template.jinja to structure prompts and generate responses with the model.1from transformers import AutoTokenizer, AutoModelForCausalLM
2from jinja2 import Template
3import torch
4
5# Load the model and tokenizer
6repo_id = "DemonC/ZenBot"
7tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
8model = AutoModelForCausalLM.from_pretrained(repo_id, device_map="auto", torch_dtype=torch.float16)
9
10# Load and render the chat template
11with open("chat_template.jinja", "r") as f:
12 template_content = f.read()
13template = Template(template_content)
14
15# Example system prompt and user input
16system_prompt = "You are a friendly assistant that helps with sleep and stress."
17user_input = "I couldn't sleep well last night. Any tips?"
18
19# Render the final prompt
20final_prompt = template.render(system=system_prompt, user_input=user_input)
21print("Prompt to model:\n", final_prompt)
22
23# Tokenize and generate response
24inputs = tokenizer(final_prompt, return_tensors="pt")
25outputs = model.generate(
26 **inputs,
27 max_new_tokens=100,
28 do_sample=True,
29 temperature=0.7,
30 top_p=0.9,
31 pad_token_id=tokenizer.eos_token_id
32)
33
34# Decode and print the model output
35response = tokenizer.decode(outputs[0], skip_special_tokens=True)
36print("\nModel Response:\n", response)