naman4jain commited on
Commit
126d5f7
1 Parent(s): ca5dca2

Upload 2 files

Browse files
Files changed (2) hide show
  1. chatgpt_prompts_bart_long.py +40 -0
  2. requirements.txt +3 -0
chatgpt_prompts_bart_long.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """chatgpt-prompts-bart-long.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/185ao64S-GtYsW71yesPrKvnywS3UKxQl
8
+
9
+ https://huggingface.co/merve/chatgpt-prompts-bart-long
10
+
11
+ # GPT to create ChatGPT prompts
12
+ """
13
+
14
+ pip install transformers -q
15
+
16
+ from transformers import AutoTokenizer, TFAutoModelForSeq2SeqLM
17
+
18
+ # Load the tokenizer and model
19
+ tokenizer = AutoTokenizer.from_pretrained("merve/chatgpt-prompts-bart-long")
20
+ model = TFAutoModelForSeq2SeqLM.from_pretrained("merve/chatgpt-prompts-bart-long")
21
+
22
+ # Define a function to generate text
23
+ def generate_text(prompt):
24
+ # Encode the prompt
25
+ inputs = tokenizer.encode(prompt, return_tensors='pt')
26
+
27
+ # Generate a sequence of tokens
28
+ outputs = model.generate(inputs, max_length=250, do_sample=True, temperature=0.7)
29
+
30
+ # Decode the output tokens to text
31
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
32
+
33
+ !pip install gradio
34
+
35
+ !pip install --upgrade pillow
36
+
37
+ import gradio as gr
38
+
39
+ ui=gr.Interface(fn=generate_text,inputs="text",outputs="text")
40
+ ui.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ gradio
3
+ pillow