new code
Browse files- src/pdfchatbot.py +5 -2
src/pdfchatbot.py
CHANGED
|
@@ -36,6 +36,7 @@ class PDFChatBot:
|
|
| 36 |
self.chunk_size = None
|
| 37 |
self.current_context = None
|
| 38 |
self.format_seperator="""\n\n--\n\n"""
|
|
|
|
| 39 |
#self.chunk_size_slider = chunk_size_slider
|
| 40 |
|
| 41 |
def load_embeddings(self):
|
|
@@ -59,7 +60,7 @@ class PDFChatBot:
|
|
| 59 |
|
| 60 |
@spaces.GPU
|
| 61 |
def create_organic_pipeline(self):
|
| 62 |
-
self.
|
| 63 |
"text-generation",
|
| 64 |
model="meta-llama/Meta-Llama-3-8B-Instruct",
|
| 65 |
model_kwargs={"torch_dtype": torch.bfloat16},
|
|
@@ -78,12 +79,14 @@ class PDFChatBot:
|
|
| 78 |
def create_organic_response(self, history, query):
|
| 79 |
self.get_organic_context(query)
|
| 80 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
|
|
|
|
| 81 |
pipe = pipeline(
|
| 82 |
"text-generation",
|
| 83 |
model="meta-llama/Meta-Llama-3-8B-Instruct",
|
| 84 |
model_kwargs={"torch_dtype": torch.bfloat16},
|
| 85 |
device="cuda",
|
| 86 |
)
|
|
|
|
| 87 |
messages = [
|
| 88 |
{"role": "system", "content": "From the the contained given below, answer the question of user \n " + self.current_context},
|
| 89 |
{"role": "user", "content": query},
|
|
@@ -95,7 +98,7 @@ class PDFChatBot:
|
|
| 95 |
add_generation_prompt=True
|
| 96 |
)
|
| 97 |
temp = 0.1
|
| 98 |
-
outputs = pipe(
|
| 99 |
prompt,
|
| 100 |
max_new_tokens=1024,
|
| 101 |
do_sample=True,
|
|
|
|
| 36 |
self.chunk_size = None
|
| 37 |
self.current_context = None
|
| 38 |
self.format_seperator="""\n\n--\n\n"""
|
| 39 |
+
self.pipe = None
|
| 40 |
#self.chunk_size_slider = chunk_size_slider
|
| 41 |
|
| 42 |
def load_embeddings(self):
|
|
|
|
| 60 |
|
| 61 |
@spaces.GPU
|
| 62 |
def create_organic_pipeline(self):
|
| 63 |
+
self.pipe = pipeline(
|
| 64 |
"text-generation",
|
| 65 |
model="meta-llama/Meta-Llama-3-8B-Instruct",
|
| 66 |
model_kwargs={"torch_dtype": torch.bfloat16},
|
|
|
|
| 79 |
def create_organic_response(self, history, query):
|
| 80 |
self.get_organic_context(query)
|
| 81 |
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
|
| 82 |
+
"""
|
| 83 |
pipe = pipeline(
|
| 84 |
"text-generation",
|
| 85 |
model="meta-llama/Meta-Llama-3-8B-Instruct",
|
| 86 |
model_kwargs={"torch_dtype": torch.bfloat16},
|
| 87 |
device="cuda",
|
| 88 |
)
|
| 89 |
+
"""
|
| 90 |
messages = [
|
| 91 |
{"role": "system", "content": "From the the contained given below, answer the question of user \n " + self.current_context},
|
| 92 |
{"role": "user", "content": query},
|
|
|
|
| 98 |
add_generation_prompt=True
|
| 99 |
)
|
| 100 |
temp = 0.1
|
| 101 |
+
outputs = self.pipe(
|
| 102 |
prompt,
|
| 103 |
max_new_tokens=1024,
|
| 104 |
do_sample=True,
|