Closed ink7-sudo closed 1 month ago
see FQA
see FQA
but im not using ollama, how to update the config file?
see FQA
but im not using ollama, how to update the config file?
You can find the model files under the cache path of Hugging Face. By modifying the config.json
file and the way you load the model in your example, you can support a larger context length.
Add this to the config.json
:
{
...,
"rope_scaling": {
"factor": 4.0,
"original_max_position_embeddings": 32768,
"type": "yarn"
}
}
At the same time, set the max_new_tokens
for generate
to 8192.
Thank you very much for your help! But i met a new problem.
Traceback (most recent call last):
File "/home/djj/nano-graphrag/local_llm_test/Qwen.py", line 130, in <module>
insert()
File "/home/djj/nano-graphrag/local_llm_test/Qwen.py", line 123, in insert
rag.insert(FAKE_TEXT)
File "/home/djj/nano-graphrag/nano_graphrag/graphrag.py", line 204, in insert
return loop.run_until_complete(self.ainsert(string_or_strings))
File "/home/djj/anaconda3/envs/nano/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/djj/nano-graphrag/nano_graphrag/graphrag.py", line 322, in ainsert
await self._insert_done()
File "/home/djj/nano-graphrag/nano_graphrag/_storage.py", line 37, in index_done_callback
write_json(self._data, self._file_name)
File "/home/djj/nano-graphrag/nano_graphrag/_utils.py", line 74, in write_json
json.dump(json_obj, f, indent=2, ensure_ascii=False)
File "/home/djj/anaconda3/envs/nano/lib/python3.10/json/__init__.py", line 179, in dump
for chunk in iterable:
File "/home/djj/anaconda3/envs/nano/lib/python3.10/json/encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/home/djj/anaconda3/envs/nano/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/home/djj/anaconda3/envs/nano/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/home/djj/anaconda3/envs/nano/lib/python3.10/json/encoder.py", line 438, in _iterencode
o = _default(o)
File "/home/djj/anaconda3/envs/nano/lib/python3.10/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Qwen2ForCausalLM is not JSON serializable
I'm kind of confused what this is for? and how to solve it. I do appreciate your kind help and patience.
we cache llm response by llm name. In your case you try to put a qwen model into a json file instead of just 'qwen' .
Replace all model below to qwen string instead.
args_hash = compute_args_hash(model, messages) ...
hashing_kv.upsert({args_hash: {"return": result, "model": model}})
how to run with Qwen 2 together ai ? @rangehow
how to run with Qwen 2 together ai ? 如何与Qwen 2一起运行ai?@rangehow
You can access model hosted on together via their API. Check out our example of custom model for a try.
when i run Qwen 2 by together , is error:
File ~/test/nano_graphrag/graphrag.py:221, in GraphRAG.query(self, query, param) 219 def query(self, query: str, param: QueryParam = QueryParam()): 220 loop = always_get_an_event_loop() --> 221 return loop.run_until_complete(self.aquery(query, param))
File ~/anaconda3/lib/python3.11/site-packages/nest_asyncio.py:98, in _patch_loop.
File ~/anaconda3/lib/python3.11/asyncio/futures.py:203, in Future.result(self) 201 self.__log_traceback = False 202 if self._exception is not None: --> 203 raise self._exception.with_traceback(self._exception_tb) 204 return self._result
File ~/anaconda3/lib/python3.11/asyncio/tasks.py:269, in Task.__step(failed resolving arguments) 267 result = coro.send(None) 268 else: --> 269 result = coro.throw(exc) 270 except StopIteration as exc: 271 if self._must_cancel: 272 # Task is cancelled right before coro stops.
File ~/test/nano_graphrag/graphrag.py:239, in GraphRAG.aquery(self, query, param) 229 response = await local_query( 230 query, 231 self.chunk_entity_relation_graph, (...) 236 asdict(self), 237 ) 238 elif param.mode == "global": --> 239 response = await global_query( 240 query, 241 self.chunk_entity_relation_graph, 242 self.entities_vdb, 243 self.community_reports, 244 self.text_chunks, 245 param, 246 asdict(self), 247 ) 248 elif param.mode == "naive": 249 response = await naive_query( 250 query, 251 self.chunks_vdb, (...) 254 asdict(self), 255 )
File ~/test/nano_graphrag/_op.py:1028, in global_query(query, knowledge_graph_inst, entities_vdb, community_reports, text_chunks_db, query_param, global_config) 1021 community_datas = sorted( 1022 community_datas, 1023 key=lambda x: (x["occurrence"], x["report_json"].get("rating", 0)), 1024 reverse=True, 1025 ) 1026 logger.info(f"Revtrieved {len(community_datas)} communities") -> 1028 map_communities_points = await _map_global_communities( 1029 query, community_datas, query_param, global_config 1030 ) 1031 final_support_points = [] 1032 for i, mc in enumerate(map_communities_points):
File ~/test/nano_graphrag/_op.py:983, in _map_global_communities(query, communities_data, query_param, global_config) 980 return data.get("points", []) 982 logger.info(f"Grouping to {len(community_groups)} groups for global search") --> 983 responses = await asyncio.gather(*[_process(c) for c in community_groups]) 984 return responses
File ~/anaconda3/lib/python3.11/asyncio/tasks.py:339, in Task.wakeup(self, future) 337 def wakeup(self, future): 338 try: --> 339 future.result() 340 except BaseException as exc: 341 # This may also be a cancellation. 342 self.__step(exc)
File ~/anaconda3/lib/python3.11/asyncio/tasks.py:267, in Task.step(failed resolving arguments)
263 try:
264 if exc is None:
265 # We use the send
method directly, because coroutines
266 # don't have `iterand
next__` methods.
--> 267 result = coro.send(None)
268 else:
269 result = coro.throw(exc)
File ~/test/nano_graphrag/_op.py:979, in _map_global_communities.
File ~/test/nano_graphrag/_utils.py:31, in convert_response_to_json(response) 29 def convert_response_to_json(response: str) -> dict: 30 json_str = locate_json_string_body_from_string(response) ---> 31 assert json_str is not None, f"Unable to parse JSON from response: {response}" 32 try: 33 data = json.loads(json_str)
AssertionError: Unable to parse JSON from response:
we cache llm response by llm name. In your case you try to put a qwen model into a json file instead of just 'qwen' .
Replace all model below to qwen string instead.
args_hash = compute_args_hash(model, messages) ...
hashing_kv.upsert({args_hash: {"return": result, "model": model}})
we cache llm response by llm name. In your case you try to put a qwen model into a json file instead of just 'qwen' .
Replace all model below to qwen string instead.
args_hash = compute_args_hash(model, messages) ...
hashing_kv.upsert({args_hash: {"return": result, "model": model}})
sorry i want to ask another question. When to use the best_model_func, cheap_model_func and embedding_func separately?. I can't figure it out by checking through the code.
we cache llm response by llm name. In your case you try to put a qwen model into a json file instead of just 'qwen' . Replace all model below to qwen string instead. args_hash = compute_args_hash(model, messages) ...args_hash =compute_args_hash(模型,消息)... hashing_kv.upsert({args_hash: {"return": result, "model": model}})
we cache llm response by llm name. In your case you try to put a qwen model into a json file instead of just 'qwen' . Replace all model below to qwen string instead. args_hash = compute_args_hash(model, messages) ...args_hash =compute_args_hash(模型,消息)... hashing_kv.upsert({args_hash: {"return": result, "model": model}})
sorry i want to ask another question. When to use the best_model_func, cheap_model_func and embedding_func separately?. I can't figure it out by checking through the code.抱歉,我想问另一个问题。何时分别使用 best_model_func、cheap_model_func 和 embedding_func?我通过检查代码无法弄清楚。
To make it easier for the community to retrieve relevant issues, please open a new issue. Thank you.
Error
Issue
I'm using the no_openai_key_at_all.py Replaced the Ollama call with a local LLM call. I know this is because something wrong with the response from llm. But you have already implemented exception handling, i dont know why the program still throw an error here and stop?
How to reproduce