MrD05 commited on
Commit
f036f98
·
1 Parent(s): 33203c4

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +3 -5
handler.py CHANGED
@@ -3,8 +3,6 @@ from langchain.llms import HuggingFacePipeline
3
  from langchain import PromptTemplate, LLMChain
4
  import torch
5
 
6
- device = 0 if torch.cuda.is_available() else -1
7
-
8
  template = """{char_name}'s Persona: {char_persona}
9
  <START>
10
  {chat_history}
@@ -13,18 +11,18 @@ template = """{char_name}'s Persona: {char_persona}
13
  {user_name}: {user_input}
14
  {char_name}: """
15
 
 
16
  class EndpointHandler():
17
 
18
  def __init__(self, path=""):
19
- tokenizer = AutoTokenizer.from_pretrained("")
20
- model = AutoModelForCausalLM.from_pretrained("", load_in_8bit = True, device_map = "auto")
21
  local_llm = HuggingFacePipeline(
22
  pipeline = pipeline(
23
  "text-generation",
24
  model = model,
25
  tokenizer = tokenizer,
26
  max_length = 2048,
27
- device=device,
28
  temperature = 0.5,
29
  top_p = 0.9,
30
  top_k = 0,
 
3
  from langchain import PromptTemplate, LLMChain
4
  import torch
5
 
 
 
6
  template = """{char_name}'s Persona: {char_persona}
7
  <START>
8
  {chat_history}
 
11
  {user_name}: {user_input}
12
  {char_name}: """
13
 
14
+ #model_id="MrD05/kaido-6b"
15
  class EndpointHandler():
16
 
17
  def __init__(self, path=""):
18
+ tokenizer = AutoTokenizer.from_pretrained(path)
19
+ model = AutoModelForCausalLM.from_pretrained(path, device_map="auto", load_in_8bit=True)
20
  local_llm = HuggingFacePipeline(
21
  pipeline = pipeline(
22
  "text-generation",
23
  model = model,
24
  tokenizer = tokenizer,
25
  max_length = 2048,
 
26
  temperature = 0.5,
27
  top_p = 0.9,
28
  top_k = 0,