model_config.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import torch.cuda
  2. import torch.backends
  3. import os
  4. embedding_model_dict = {
  5. "ernie-tiny": "nghuyong/ernie-3.0-nano-zh",
  6. "ernie-base": "nghuyong/ernie-3.0-base-zh",
  7. "text2vec-base": "shibing624/text2vec-base-chinese",
  8. "text2vec": "GanymedeNil/text2vec-large-chinese",
  9. }
  10. # Embedding model name
  11. EMBEDDING_MODEL = "text2vec"
  12. # Embedding running device
  13. EMBEDDING_DEVICE = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
  14. # supported LLM models
  15. llm_model_dict = {
  16. "chatyuan": "ClueAI/ChatYuan-large-v2",
  17. "chatglm-6b-int4-qe": "THUDM/chatglm-6b-int4-qe",
  18. "chatglm-6b-int4": "THUDM/chatglm-6b-int4",
  19. "chatglm-6b-int8": "THUDM/chatglm-6b-int8",
  20. "chatglm-6b": "THUDM/chatglm-6b",
  21. }
  22. # LLM model name
  23. LLM_MODEL = "chatglm-6b"
  24. # LLM streaming reponse
  25. STREAMING = True
  26. # Use p-tuning-v2 PrefixEncoder
  27. USE_PTUNING_V2 = False
  28. # LLM running device
  29. LLM_DEVICE = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
  30. VS_ROOT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "vector_store", "")
  31. UPLOAD_ROOT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "content", "")
  32. # 基于上下文的prompt模版,请务必保留"{question}"和"{context}"
  33. PROMPT_TEMPLATE = """已知信息:
  34. {context}
  35. 根据上述已知信息,简洁和专业的来回答用户的问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题” 或 “没有提供足够的相关信息”,不允许在答案中添加编造成分,答案请使用中文。 问题是:{question}"""
  36. # 匹配后单段上下文长度
  37. CHUNK_SIZE = 500