BWComedian commited on
Commit
0fe11d8
·
1 Parent(s): a3543ea

Add app.py, config.json, README.md, and requirements.txt

Browse files
Files changed (4) hide show
  1. README.md +15 -0
  2. app.py +34 -0
  3. config.json +8 -0
  4. requirements.txt +3 -0
README.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSM-1B Maya Model
2
+
3
+ This is the CSM-1B Maya-like conversational model.
4
+
5
+ ## Description
6
+
7
+ A large language model trained for conversational AI, designed to simulate Maya.
8
+
9
+ ## Usage
10
+
11
+ You can interact with this model via the Hugging Face Spaces app or load it using custom scripts.
12
+
13
+ ## License
14
+
15
+ Specify your license here (e.g., MIT, Apache 2.0).
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+ import torch
3
+ import gradio as gr
4
+
5
+ # Load tokenizer and model with trust_remote_code=True
6
+ tokenizer = AutoTokenizer.from_pretrained("BWComedian/CSM-1B", trust_remote_code=True)
7
+ model = AutoModelForCausalLM.from_pretrained("BWComedian/CSM-1B", trust_remote_code=True)
8
+
9
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
10
+ model.to(device)
11
+
12
+ def generate_response(prompt):
13
+ inputs = tokenizer(prompt, return_tensors="pt").to(device)
14
+ outputs = model.generate(
15
+ **inputs,
16
+ max_length=200,
17
+ do_sample=True,
18
+ top_p=0.95,
19
+ top_k=50,
20
+ pad_token_id=tokenizer.eos_token_id
21
+ )
22
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
23
+ return response
24
+
25
+ demo = gr.Interface(
26
+ fn=generate_response,
27
+ inputs=gr.Textbox(lines=5, placeholder="Talk to Maya..."),
28
+ outputs=gr.Textbox(label="Maya says", lines=10),
29
+ title="CSM-1B Maya Chatbot",
30
+ description="Chat with your Maya-like model."
31
+ )
32
+
33
+ if __name__ == "__main__":
34
+ demo.launch()
config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "gpt2",
3
+ "architectures": ["GPT2LMHeadModel"],
4
+ "hidden_size": 768,
5
+ "num_attention_heads": 12,
6
+ "num_hidden_layers": 12,
7
+ "vocab_size": 50257
8
+ }
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio