Spaces:
Runtime error
Runtime error
Update models/llamaCustom.py
Browse files21 unmodified lines2223242526272817 unmodified lines46474849505152535455565758596061626364656667686970717273747521 unmodified linesfrom llama_index.llms import CompletionResponse, CustomLLM, LLMMetadata# from langchain.llms.base import LLMfrom llama_index.prompts import Promptfrom transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, pipeline# from utils.customLLM import CustomLLM17 unmodified lineschunk_overlap_ratio=CHUNK_OVERLAP_RATIO,)text_qa_template_str = ("Context information is below.\n""---------------------\n""{context_str}\n""---------------------\n""Using both the context information and also using your own knowledge, ""answer the question: {query_str}\n""If the question is relevant, you can answer by providing the name of the chapter, the article and the title to the answer. In addition, you can add the page number of the document when you found the answer.\n""If the context isn't helpful, you can also answer the question on your own.\n")text_qa_template = Prompt(text_qa_template_str)refine_template_str = ("The original question is as follows: {query_str}\n""We have provided an existing answer: {existing_answer}\n""We have the opportunity to refine the existing answer ""(only if needed) with some more context below.\n""------------\n""{context_msg}\n""------------\n""Using both the new context and your own knowledege, update or repeat the existing answer.\n")refine_template = Prompt(refine_template_str)@st.cache_resourcedef load_model(mode_name: str):21 unmodified lines2223242526272817 unmodified lines46474849505121 unmodified linesfrom llama_index.llms import CompletionResponse, CustomLLM, LLMMetadata# from langchain.llms.base import LLM# from llama_index.prompts import Promptfrom transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, pipeline# from utils.customLLM import CustomLLM17 unmodified lineschunk_overlap_ratio=CHUNK_OVERLAP_RATIO,)@st.cache_resourcedef load_model(mode_name: str):
models/llamaCustom.py+1-25