Views
No views yet
adamw_bnb_8bit)| Model | Intelligence Score |
|---|---|
| Gemma-3-27B (for comparison) | 8.3 |
| tiny-model-700M-chat | 4.42841 |
| tiny-model-141M-chat (unreleased) | 2.7 |
| tiny-model-500M-chat-v2 | 2.50909 |
| tiny-model-500M-chat-v2-5-exp | 2.08295 |
1import torch
2from transformers import pipeline, set_seed
3
4# Set up the text-generation pipeline
5model_name = "amusktweewt/tiny-model-700M-chat"
6chatbot = pipeline(
7 "text-generation",
8 model=model_name,
9 device=0 if torch.cuda.is_available() else -1
10)
11
12# Ensure that bos_token and eos_token are explicitly set as strings
13chatbot.tokenizer.bos_token = "<sos>"
14chatbot.tokenizer.eos_token = "<|endoftext|>"
15
16# Set seed for reproducibility (optional)
17set_seed(42)
18
19print("Chatbot is ready! Type 'exit' to end the conversation.")
20
21# Initialize the conversation history
22conversation_history = []
23
24conversation_history.append({"role": "system", "content": "You are a highly intelligent and helpful AI assistant named Tiny Chat, developed by amusktweewt. Always refer to yourself like that. Your responses should be clear, concise, and accurate. Always prioritize user needs, provide well-structured answers, and maintain a friendly yet professional tone. Adapt to the user's preferences and communication style. When needed, ask clarifying questions to ensure the best response. Be honest about limitations and avoid making assumptions. Keep interactions engaging, informative, and efficient."})
25
26while True:
27 user_input = input("You: ").strip()
28 if user_input.lower() == "exit":
29 print("Exiting chat. Goodbye!")
30 break
31
32 # Append user message to the conversation history
33 conversation_history.append({"role": "user", "content": user_input})
34
35 # Prepare the messages with the conversation history and an empty assistant turn
36 messages = conversation_history + [{"role": "assistant", "content": ""}]
37
38 # Use the tokenizer's apply_chat_template() method to format the prompt.
39 prompt = chatbot.tokenizer.apply_chat_template(messages, tokenize=False)
40
41 # Generate text using the formatted prompt.
42 response = chatbot(
43 prompt,
44 do_sample=True,
45 max_new_tokens=512,
46 top_k=50,
47 temperature=0.6,
48 num_return_sequences=1,
49 repetition_penalty=1.1,
50 pad_token_id=chatbot.tokenizer.eos_token_id,
51 min_new_tokens=20
52 )
53
54 # The returned 'generated_text' includes the prompt plus the generation.
55 full_text = response[0]["generated_text"]
56 # Extract the assistant's response by removing the prompt portion.
57 bot_response = full_text[len(prompt):].strip()
58 print(f"Bot: {bot_response}")