Upload 10 files
Browse files- nlp/added_tokens.json +3 -0
- nlp/config.json +40 -0
- nlp/generation_config.json +7 -0
- nlp/merges.txt +0 -0
- nlp/model.safetensors +3 -0
- nlp/special_tokens_map.json +24 -0
- nlp/tokenizer_config.json +30 -0
- nlp/vocab.json +0 -0
- requirements.txt +3 -0
- streamlit1.py +61 -0
nlp/added_tokens.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"[PAD]": 50257
|
3 |
+
}
|
nlp/config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "gpt2",
|
3 |
+
"activation_function": "gelu_new",
|
4 |
+
"architectures": [
|
5 |
+
"GPT2LMHeadModel"
|
6 |
+
],
|
7 |
+
"attn_pdrop": 0.1,
|
8 |
+
"bos_token_id": 50256,
|
9 |
+
"embd_pdrop": 0.1,
|
10 |
+
"eos_token_id": 50256,
|
11 |
+
"initializer_range": 0.02,
|
12 |
+
"layer_norm_epsilon": 1e-05,
|
13 |
+
"model_type": "gpt2",
|
14 |
+
"n_ctx": 1024,
|
15 |
+
"n_embd": 768,
|
16 |
+
"n_head": 12,
|
17 |
+
"n_inner": null,
|
18 |
+
"n_layer": 12,
|
19 |
+
"n_positions": 1024,
|
20 |
+
"pad_token_id": 50256,
|
21 |
+
"reorder_and_upcast_attn": false,
|
22 |
+
"resid_pdrop": 0.1,
|
23 |
+
"scale_attn_by_inverse_layer_idx": false,
|
24 |
+
"scale_attn_weights": true,
|
25 |
+
"summary_activation": null,
|
26 |
+
"summary_first_dropout": 0.1,
|
27 |
+
"summary_proj_to_labels": true,
|
28 |
+
"summary_type": "cls_index",
|
29 |
+
"summary_use_proj": true,
|
30 |
+
"task_specific_params": {
|
31 |
+
"text-generation": {
|
32 |
+
"do_sample": true,
|
33 |
+
"max_length": 50
|
34 |
+
}
|
35 |
+
},
|
36 |
+
"torch_dtype": "float32",
|
37 |
+
"transformers_version": "4.35.2",
|
38 |
+
"use_cache": true,
|
39 |
+
"vocab_size": 50257
|
40 |
+
}
|
nlp/generation_config.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 50256,
|
4 |
+
"eos_token_id": 50256,
|
5 |
+
"pad_token_id": 50256,
|
6 |
+
"transformers_version": "4.35.2"
|
7 |
+
}
|
nlp/merges.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
nlp/model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2753b3af3420afcfd85544b4d4c78427fe4cbc4d9d18823e40dc763accc199d3
|
3 |
+
size 497774208
|
nlp/special_tokens_map.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<|endoftext|>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": true,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "<|endoftext|>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": true,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": "<|endoftext|>",
|
17 |
+
"unk_token": {
|
18 |
+
"content": "<|endoftext|>",
|
19 |
+
"lstrip": false,
|
20 |
+
"normalized": true,
|
21 |
+
"rstrip": false,
|
22 |
+
"single_word": false
|
23 |
+
}
|
24 |
+
}
|
nlp/tokenizer_config.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": false,
|
3 |
+
"add_prefix_space": false,
|
4 |
+
"added_tokens_decoder": {
|
5 |
+
"50256": {
|
6 |
+
"content": "<|endoftext|>",
|
7 |
+
"lstrip": false,
|
8 |
+
"normalized": true,
|
9 |
+
"rstrip": false,
|
10 |
+
"single_word": false,
|
11 |
+
"special": true
|
12 |
+
},
|
13 |
+
"50257": {
|
14 |
+
"content": "[PAD]",
|
15 |
+
"lstrip": false,
|
16 |
+
"normalized": false,
|
17 |
+
"rstrip": false,
|
18 |
+
"single_word": false,
|
19 |
+
"special": true
|
20 |
+
}
|
21 |
+
},
|
22 |
+
"bos_token": "<|endoftext|>",
|
23 |
+
"clean_up_tokenization_spaces": true,
|
24 |
+
"eos_token": "<|endoftext|>",
|
25 |
+
"errors": "replace",
|
26 |
+
"model_max_length": 1024,
|
27 |
+
"pad_token": "<|endoftext|>",
|
28 |
+
"tokenizer_class": "GPT2Tokenizer",
|
29 |
+
"unk_token": "<|endoftext|>"
|
30 |
+
}
|
nlp/vocab.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
transformers
|
3 |
+
time
|
streamlit1.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
3 |
+
import time
|
4 |
+
|
5 |
+
# Load the fine-tuned model
|
6 |
+
model_path = r"C:\Users\Kush\Desktop\dfuchatbot\nlp"
|
7 |
+
tokenizer = GPT2Tokenizer.from_pretrained(model_path)
|
8 |
+
model = GPT2LMHeadModel.from_pretrained(model_path)
|
9 |
+
|
10 |
+
# Set page title and favicon
|
11 |
+
st.set_page_config(page_title="Diabetic Foot Ulcer Chatbot", page_icon=":hospital:")
|
12 |
+
|
13 |
+
# Set app title and description
|
14 |
+
st.title("Diabetic Foot Ulcer Chatbot")
|
15 |
+
st.markdown("Welcome to the Diabetic Foot Ulcer Chatbot. Ask any questions related to diabetic foot ulcers!")
|
16 |
+
|
17 |
+
# Define conversation loop
|
18 |
+
def chatbot(user_input):
|
19 |
+
# Check for exit command
|
20 |
+
if user_input.lower() == 'exit':
|
21 |
+
st.info("Chat ended. Goodbye!")
|
22 |
+
return
|
23 |
+
|
24 |
+
# Display typing animation
|
25 |
+
with st.spinner(text="Chatbot is typing..."):
|
26 |
+
time.sleep(2) # Simulate typing time
|
27 |
+
|
28 |
+
# Get model response
|
29 |
+
response = generate_response(user_input)
|
30 |
+
|
31 |
+
# Display model response
|
32 |
+
st.text_area("Chatbot:", value=response, height=100, max_chars=500)
|
33 |
+
|
34 |
+
# Generate response from the model
|
35 |
+
def generate_response(user_input):
|
36 |
+
# Encode user input
|
37 |
+
input_ids = tokenizer.encode(user_input, return_tensors="pt")
|
38 |
+
|
39 |
+
# Generate model response
|
40 |
+
output = model.generate(
|
41 |
+
input_ids,
|
42 |
+
max_length=100,
|
43 |
+
num_return_sequences=1,
|
44 |
+
no_repeat_ngram_size=2,
|
45 |
+
top_k=50,
|
46 |
+
top_p=0.95,
|
47 |
+
temperature=0.7,
|
48 |
+
do_sample=True,
|
49 |
+
pad_token_id=tokenizer.eos_token_id,
|
50 |
+
early_stopping=True
|
51 |
+
)
|
52 |
+
|
53 |
+
# Decode and return model response
|
54 |
+
return tokenizer.decode(output[0], skip_special_tokens=True)
|
55 |
+
|
56 |
+
# Get user input
|
57 |
+
user_input = st.text_input("You:")
|
58 |
+
|
59 |
+
# Start conversation when user submits input
|
60 |
+
if st.button("Send"):
|
61 |
+
chatbot(user_input)
|