gufett0 commited on
Commit
bcb5f66
·
1 Parent(s): 0875680
Files changed (1) hide show
  1. backend.py +4 -9
backend.py CHANGED
@@ -63,13 +63,13 @@ os.environ['TOKENIZERS_PARALLELISM'] = 'false'
63
  llm = HuggingFaceLLM(
64
  context_window=4096,
65
  max_new_tokens=256,
66
- generate_kwargs={"temperature": 0.1, "do_sample": False},
67
  system_prompt=system_prompt,
68
  tokenizer_name="meta-llama/Llama-2-7b-chat-hf",
69
  model_name="meta-llama/Llama-2-7b-chat-hf",
70
  device_map="auto",
71
  # loading model in 8bit for reducing memory
72
- model_kwargs={"torch_dtype": torch.float16 , "load_in_8bit":True}
73
  )
74
 
75
  embed_model= HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
@@ -87,18 +87,13 @@ nodes = SentenceSplitter(chunk_size=512, chunk_overlap=20, paragraph_separator="
87
  # Build the vector store index from the nodes
88
  index = VectorStoreIndex(nodes, show_progress = True)
89
 
90
-
91
-
92
- #
93
  # what models will be used by LlamaIndex:
94
  #Settings.embed_model = InstructorEmbedding(model_name="hkunlp/instructor-base")
95
  #Settings.embed_model = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
96
  #Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
97
-
98
  #Settings.llm = GemmaLLMInterface()
99
 
100
 
101
-
102
  documents_paths = {
103
  'blockchain': 'data/blockchainprova.txt',
104
  'metaverse': 'data/metaverseprova.txt',
@@ -122,7 +117,7 @@ ISTR = "In italiano, chiedi molto brevemente se la domanda si riferisce agli 'Os
122
  ############################---------------------------------
123
 
124
  # Get the parser
125
- parser = SentenceSplitter.from_defaults(
126
  chunk_size=256, chunk_overlap=64, paragraph_separator="\n\n"
127
  )
128
  def build_index(path: str):
@@ -136,7 +131,7 @@ def build_index(path: str):
136
  #storage_context = StorageContext.from_defaults()
137
  #index.storage_context.persist(persist_dir=PERSIST_DIR)
138
 
139
- return index
140
 
141
 
142
 
 
63
  llm = HuggingFaceLLM(
64
  context_window=4096,
65
  max_new_tokens=256,
66
+ generate_kwargs={"temperature": 0.1, "do_sample": True},
67
  system_prompt=system_prompt,
68
  tokenizer_name="meta-llama/Llama-2-7b-chat-hf",
69
  model_name="meta-llama/Llama-2-7b-chat-hf",
70
  device_map="auto",
71
  # loading model in 8bit for reducing memory
72
+ model_kwargs={"torch_dtype": torch.float16 }
73
  )
74
 
75
  embed_model= HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
 
87
  # Build the vector store index from the nodes
88
  index = VectorStoreIndex(nodes, show_progress = True)
89
 
 
 
 
90
  # what models will be used by LlamaIndex:
91
  #Settings.embed_model = InstructorEmbedding(model_name="hkunlp/instructor-base")
92
  #Settings.embed_model = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
93
  #Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
 
94
  #Settings.llm = GemmaLLMInterface()
95
 
96
 
 
97
  documents_paths = {
98
  'blockchain': 'data/blockchainprova.txt',
99
  'metaverse': 'data/metaverseprova.txt',
 
117
  ############################---------------------------------
118
 
119
  # Get the parser
120
+ """parser = SentenceSplitter.from_defaults(
121
  chunk_size=256, chunk_overlap=64, paragraph_separator="\n\n"
122
  )
123
  def build_index(path: str):
 
131
  #storage_context = StorageContext.from_defaults()
132
  #index.storage_context.persist(persist_dir=PERSIST_DIR)
133
 
134
+ return index"""
135
 
136
 
137