evanthebouncy commited on
Commit
85f3da5
·
1 Parent(s): 17ce275
Files changed (2) hide show
  1. app.py +19 -0
  2. requirements.txt +18 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import T5ForConditionalGeneration, AutoTokenizer, TrainingArguments
3
+
4
+ tokenizer = AutoTokenizer.from_pretrained('evanthebouncy/cad-llm')
5
+ model = T5ForConditionalGeneration.from_pretrained('evanthebouncy/cad-llm')
6
+
7
+ temp = 1.0
8
+
9
+ def generate_samples_with_temp(txt_n):
10
+ txt, n = txt_n.split('|')
11
+ n_samples = int(n)
12
+ to_tokenizer = [txt for i in range(n_samples)]
13
+ outputs = model.generate(tokenizer(to_tokenizer, return_tensors='pt', padding=True).input_ids, do_sample=True, max_length=128, temperature = temp)
14
+ results = tokenizer.batch_decode(outputs, skip_special_tokens=True)
15
+ return '\n'.join(results)
16
+
17
+
18
+ iface = gr.Interface(fn=generate_samples_with_temp, inputs="text", outputs="text")
19
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ certifi==2022.9.14
2
+ charset-normalizer==2.1.1
3
+ filelock==3.8.0
4
+ huggingface-hub==0.9.1
5
+ idna==3.4
6
+ numpy==1.23.3
7
+ packaging==21.3
8
+ pyparsing==3.0.9
9
+ PyYAML==6.0
10
+ regex==2022.9.13
11
+ requests==2.28.1
12
+ tokenizers==0.12.1
13
+ torch==1.12.1
14
+ tqdm==4.64.1
15
+ transformers==4.22.1
16
+ typing_extensions==4.3.0
17
+ urllib3==1.26.12
18
+