llama-index,uncharted and llama2:7b run locally to generate Index
创始人
2025-01-08 03:33:43
0

题意:本地运行 llama-indexuncharted 以及 llama2:7b 来生成索引

问题背景:

I wanted to use llama-index locally with ollama and llama3:8b to index utf-8 json file. I dont have a gpu. I use uncharted to convert docs into json. Now If it is not possible to use llama-index locally without GPU I wanted to use hugging face inference API. But I am not certain if it is free. Can anyone suggest a way?

This is my python code:

from llama_index.core import Document, SimpleDirectoryReader, VectorStoreIndex     from llama_index.llms.ollama import Ollama     import json     from llama_index.core import Settings               # Convert the JSON document into LlamaIndex Document objects     with open('data/UBER_2019.json', 'r',encoding='utf-8') as f:         json_doc = json.load(f)     documents = [Document(text=str(doc)) for doc in json_doc]          # Initialize Ollama with the local LLM     ollama_llm = Ollama(model="llama3:8b")     Settings.llm = ollama_llm          # Create the index using the local LLM     index = VectorStoreIndex.from_documents(documents)#, llm=ollama_llm)

But i keep getting error that there is no OPENAI key. I wanted to use llama2 so that i dont require OPENAI key

Can anyone suggest what i am doing wrong? Also can i use huggingfaceinference API to do indexing of a local json file for free?

问题解决:

You are not setting the embedding model, so I think Llama Index is defaulting to OpenAI.
You must specify an embedding model that does not require an API key.

You can use Ollama:

from llama_index.embeddings.ollama import OllamaEmbedding  # Using Nomic Settings.embed_model = OllamaEmbedding(model_name="nomic-embed-text")  # Using Llama Settings.embed_model = OllamaEmbedding(model_name="llama2")

But there are many options in the documentation like this, this, this

相关内容

热门资讯

黑科技好牌(wpk微扑克)外挂... 黑科技好牌(wpk微扑克)外挂透明挂辅助助手(透视)都是真的是有挂(有挂存在)-哔哩哔哩1、起透看视...
黑科技新版!微扑克有规律吗(透... 黑科技新版!微扑克有规律吗(透视)揭秘教程(2023已更新)(哔哩哔哩)一、微扑克有规律吗软件透明挂...
黑科技ai(pokermast... 黑科技ai(pokermastersteam外挂)外挂透明挂辅助器(透视)确实真的有挂(真的有挂)-...
今日百科!德州辅助神器软件(黑... 今日百科!德州辅助神器软件(黑科技)外挂ai代打辅助挂(有挂方法)-哔哩哔哩1、德州辅助神器软件系统...
黑科技好牌(Wepoke代码)... 黑科技好牌(Wepoke代码)外挂透明挂辅助下载(ai代打)都是是真的有挂(有挂细节)-哔哩哔哩1)...
重大通报!!wpk透视辅助合作... 重大通报!!wpk透视辅助合作(黑科技)外挂透明黑科技辅助工具(发现有挂)-哔哩哔哩;一、wpk透视...
黑科技存在!微扑克脚本代写(透... 黑科技存在!微扑克脚本代写(透视)wpk教程(2023已更新)(哔哩哔哩)1、游戏颠覆性的策略玩法,...
黑科技辅助(wpk透视辅助测试... 黑科技辅助(wpk透视辅助测试)外挂透明挂辅助黑科技(透视)果然有挂(有人有挂)-哔哩哔哩暗藏猫腻,...
黑科技线上(aapker代理)... 黑科技线上(aapker代理)外挂透明挂辅助挂(智能ai)确实有挂(竟然有挂)-哔哩哔哩;1、aap...
攻略讲解!云扑克德州辅助器(黑... 1、攻略讲解!云扑克德州辅助器(黑科技)外挂透视辅助神器(竟然有挂)-哔哩哔哩;详细教程。2、云扑克...