Iliassti commited on
Commit
5c54b7f
·
1 Parent(s): 5cc47df

using t5 model

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -11,6 +11,7 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
11
  import streamlit as st
12
  from dotenv import load_dotenv
13
  import PyPDF2
 
14
 
15
  load_dotenv()
16
 
@@ -25,6 +26,16 @@ class LegalExpert:
25
  [self.system_prompt, self.user_prompt]
26
  )
27
 
 
 
 
 
 
 
 
 
 
 
28
  # create llm pipeline for huggingfaceHub model
29
  model_name = "google/flan-t5-xl"
30
 
@@ -33,7 +44,7 @@ class LegalExpert:
33
  self.openai_gpt4_llm = ChatOpenAI(temperature=0, max_tokens=256)
34
  # self.chat = ChatAnthropic()
35
 
36
- self.chain = LLMChain(llm=self.openai_gpt4_llm, prompt=full_prompt_template)
37
 
38
  def get_system_prompt(self):
39
  system_prompt = """
 
11
  import streamlit as st
12
  from dotenv import load_dotenv
13
  import PyPDF2
14
+ import torch
15
 
16
  load_dotenv()
17
 
 
26
  [self.system_prompt, self.user_prompt]
27
  )
28
 
29
+ # falcon model
30
+ model_name = "tiiuae/falcon-40b-instruct"
31
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
32
+ custom_pipeline = pipeline("text-generation",
33
+ model=model_name,
34
+ tokenizer=tokenizer,
35
+ torch_dtype=torch.float16,
36
+ trust_remote_code=True,
37
+ device_map="auto")
38
+
39
  # create llm pipeline for huggingfaceHub model
40
  model_name = "google/flan-t5-xl"
41
 
 
44
  self.openai_gpt4_llm = ChatOpenAI(temperature=0, max_tokens=256)
45
  # self.chat = ChatAnthropic()
46
 
47
+ self.chain = LLMChain(llm=self.huggingface_llm, prompt=full_prompt_template)
48
 
49
  def get_system_prompt(self):
50
  system_prompt = """