aframson commited on
Commit
f1a963e
1 Parent(s): 32721fb
Files changed (2) hide show
  1. app.py +17 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM,AutoModel
3
+ from transformers import AutoTokenizer
4
+ import torch
5
+
6
+ model = AutoModel.from_pretrained("aframson/RDPDLM",trust_remote_code=True)
7
+ tokenizer = AutoTokenizer.from_pretrained("aframson/RDPDLM",trust_remote_code=True)
8
+
9
+
10
+ def Generate(context):
11
+ context_tokens = torch.tensor(tokenizer._encode(context), dtype=torch.long).unsqueeze(0) # Encode the text
12
+ # Generate text based on the context
13
+ generated_text = model.generate(context_tokens, max_new_tokens=10)[0].tolist()
14
+ return tokenizer._decode(generated_text)
15
+
16
+ iface = gr.Interface(fn=Generate, inputs="text", outputs="text")
17
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers==4.30.2
2
+ torch
3
+ sentencepiece