yanyoyo commited on
Commit
d5c7d7b
·
1 Parent(s): 0ebb649
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -3,26 +3,26 @@ from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
3
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
4
  from llama_index.llms.huggingface import HuggingFaceLLM
5
 
6
- st.set_page_config(page_title="llama_index_demo", page_icon="🦜🔗")
7
- st.title("llama_index_demo")
8
 
9
  # 初始化模型
10
  @st.cache_resource
11
  def init_models():
12
  embed_model = HuggingFaceEmbedding(
13
- model_name="/root/model/sentence-transformer"
14
  )
15
  Settings.embed_model = embed_model
16
 
17
  llm = HuggingFaceLLM(
18
- model_name="/root/model/internlm2-chat-1_8b",
19
- tokenizer_name="/root/model/internlm2-chat-1_8b",
20
  model_kwargs={"trust_remote_code": True},
21
  tokenizer_kwargs={"trust_remote_code": True}
22
  )
23
  Settings.llm = llm
24
 
25
- documents = SimpleDirectoryReader("/root/llamaindex_demo/data").load_data()
26
  index = VectorStoreIndex.from_documents(documents)
27
  query_engine = index.as_query_engine()
28
 
 
3
  from llama_index.embeddings.huggingface import HuggingFaceEmbedding
4
  from llama_index.llms.huggingface import HuggingFaceLLM
5
 
6
+ st.set_page_config(page_title="Streamlit-LlamaIndex-API", page_icon="🦜🔗")
7
+ st.title("Streamlit-LlamaIndex-API")
8
 
9
  # 初始化模型
10
  @st.cache_resource
11
  def init_models():
12
  embed_model = HuggingFaceEmbedding(
13
+ model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
14
  )
15
  Settings.embed_model = embed_model
16
 
17
  llm = HuggingFaceLLM(
18
+ model_name="internlm/internlm2_5-1_8b-chat",
19
+ tokenizer_name="internlm/internlm2_5-1_8b-chat",
20
  model_kwargs={"trust_remote_code": True},
21
  tokenizer_kwargs={"trust_remote_code": True}
22
  )
23
  Settings.llm = llm
24
 
25
+ documents = SimpleDirectoryReader("Streamlit-LlamaIndex-API/data").load_data()
26
  index = VectorStoreIndex.from_documents(documents)
27
  query_engine = index.as_query_engine()
28