WICKED4950 commited on
Commit
30d3db7
·
verified ·
1 Parent(s): 6ac88b7

Delete inference.py

Browse files
Files changed (1) hide show
  1. inference.py +0 -28
inference.py DELETED
@@ -1,28 +0,0 @@
1
- import gradio as gr
2
- from transformers import AutoTokenizer, TFBlenderbotForConditionalGeneration
3
- import tensorflow as tf
4
- model_name = "WICKED4950/Irisonego5"
5
- strategy = tf.distribute.MirroredStrategy()
6
- tf.config.optimizer.set_jit(True) # Enable XLA
7
- tokenizer = AutoTokenizer.from_pretrained(model_name)
8
- with strategy.scope():
9
- model = TFBlenderbotForConditionalGeneration.from_pretrained(model_name)
10
-
11
- # Define the chatbot function
12
- def predict(user_input):
13
- # Tokenize input text
14
- inputs = tokenizer(user_input, return_tensors="tf", padding=True, truncation=True)
15
-
16
- # Generate the response using the model
17
- response_ids = model.generate(
18
- inputs['input_ids'],
19
- max_length=128, # Set max length of response
20
- do_sample=True, # Sampling for variability
21
- top_k=15, # Consider top 50 tokens
22
- top_p=0.95, # Nucleus sampling
23
- temperature=0.8 # Adjusts creativity of response
24
- )
25
-
26
- # Decode the response
27
- response = tokenizer.decode(response_id[0], skip_special_tokens=True)
28
- return response