Spaces:
Running on Zero
Running on Zero
Download app.py from Sebestianmek/checkpoint-200-base-model-test: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/Sebestianmek/checkpoint-200-base-model-test/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sebestianmek/checkpoint-200-base-model-test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sebestianmek/checkpoint-200-base-model-test/resolve/main/app.py
1.07 kB
| import spaces | |
| import gradio as gr | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| MODEL_ID = "Sebestianmek/Seb-AI-S1-Mini-350M" | |
| tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM-360M") | |
| model = AutoModelForCausalLM.from_pretrained( | |
| MODEL_ID, | |
| dtype=torch.float16 | |
| ) | |
| def chat_with_base(message, history): | |
| model.to("cuda") | |
| prompt = f"User: {message}\nAssistant:" | |
| inputs = tokenizer(prompt, return_tensors="pt").to("cuda") | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=120, | |
| do_sample=True, | |
| temperature=0.6, | |
| top_p=0.9, | |
| repetition_penalty=1.2, | |
| pad_token_id=tokenizer.eos_token_id | |
| ) | |
| full_text = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| reply = full_text.split("Assistant:")[-1].strip() | |
| return reply | |
| demo = gr.ChatInterface( | |
| fn=chat_with_base, | |
| title="Seb AI S1 Mini Base (409M)", | |
| description="Open-source 409M parameter base language model trained from scratch by Seb AI Inc." | |
| ) | |
| demo.launch() | |