Replies: 1 comment 2 replies
-
Answer generated by a 🤖 AnswerI understand that you have a fine-tuned Starcoder model and you're looking to use it with the pandas dataframe agent in LangChain. You're also interested in knowing how to use an open-source model from Hugging Face in the same context. Here's how you can achieve this: First, you'll need to import the model and use it when creating the agent. Here's a sample code snippet to illustrate this: from langchain.agents import create_pandas_dataframe_agent
from langchain.agents.agent_types import AgentType
from langchain.schema.language_model import BaseLanguageModel
import pandas as pd
# Load your dataframe
df = pd.read_csv("titanic.csv")
# Load your fine-tuned model
# Replace BaseLanguageModel with the class used to load your model
model = BaseLanguageModel(model_path="path/to/your/model")
# Create the agent
agent = create_pandas_dataframe_agent(
llm=model,
df=df,
verbose=True,
agent_type=AgentType.OPENAI_FUNCTIONS
)
# Run the agent
# Replace "how many rows are there?" with your question
agent.run("how many rows are there?") In the above code, replace If you're looking to use a Hugging Face model, you would need to replace Also, LangChain has a Please note that this is one potential solution based on the information provided. If you find this solution helpful and believe it could benefit others, I encourage you to make a pull request to update the LangChain documentation. This way, other users facing the same issue can also benefit from your experience. Sources
This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Suppose I have fine tuned starcoder model. How can I use pandas dataframe agent using this local fine tuned model or any other open source model from hugging-face ?
Beta Was this translation helpful? Give feedback.
All reactions