Issue: Not sure whether my transformation using the model I created was correct, as I am getting an error.
Labels: name: auto:bug, name: area: models

### Issue you'd like to raise.

# The code for my model for sentiment analysis (this works, the problem is in the next part of my code)

from datasets import load_dataset,Dataset
from sentence_transformers.losses import CosineSimilarityLoss
from setfit import SetFitModel, SetFitTrainer, sample_dataset
from transformers import pipeline
import pandas as pd
import langchain

# df = pd.read_csv("C:/Users/sanja/OneDrive/Desktop/Trillo InternShip/train.csv",encoding='ISO-8859-1')
df = pd.read_csv("C:/Users/sanja/OneDrive/Desktop/Trillo InternShip/train-utf-8.csv")

# Create a mapping from string labels to integer labels
label_mapping = {"negative": 0, "neutral": 1, "positive": 2}  # Customize this mapping as needed

# Apply the mapping to the "sentiment" column
df['label'] = df['label'].map(label_mapping)


# Specify the columns for text (input) and label (output)
text_column = "selected_text"
label_column = "label"

# Assuming you have already preprocessed and tokenized your text data
dataset = Dataset.from_pandas(df)

num_samples_per_class = 8
# Simulate the few-shot regime by sampling 8 examples per class
train_dataset = sample_dataset(dataset, label_column=label_column, num_samples=num_samples_per_class)
eval_dataset = dataset  # Assuming you want to evaluate on the same DataFrame



# Load a SetFit model from Hub
model = SetFitModel.from_pretrained("sentence-transformers/paraphrase-mpnet-base-v2")

# Create trainer
trainer1 = SetFitTrainer(
    model=model,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    loss_class=CosineSimilarityLoss,
    metric="accuracy",
    batch_size=16,
    num_iterations=20,  # The number of text pairs to generate for contrastive learning
    num_epochs=1,  # The number of epochs to use for contrastive learning
    column_mapping={text_column: "text", label_column: "label"}  # Map dataset columns to text/label expected by trainer
)

# Train and evaluate
trainer1.train()
metrics = trainer1.evaluate()

# Pushing model to hub
trainer1.push_to_hub("Sanjay1234/Trillo-Project")

# But here I get a problem when I do transformation,
from langchain.chains import TransformChain, LLMChain, SimpleSequentialChain
from sentence_transformers.losses import CosineSimilarityLoss
from setfit import SetFitModel, SetFitTrainer, sample_dataset
from transformers import pipeline

def transform_func(text):
    shortened_text = "\n\n".join(text.split("\n\n")[:3])
    return shortened_text

transform_chain = TransformChain(
    input_variables=["text"], output_variables=["output_text"], transform=transform_func
)

# I get a problem here
llm_chain = LLMChain(
   llm={"llm": "Sanjay1234/Trillo-Project"},  # Provide the llm parameter as a dictionary
        prompt={"prompt": "Summarize this text:"}
)

sequential_chain = SimpleSequentialChain(chains=[transform_chain, llm_chain])
text = "This is a long text. I want to transform it to only the first 3 paragraphs."
transformed_text = sequential_chain.run(text)
print(transformed_text)

I get the following error.-
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[26], line 1
----> 1 llm_chain = LLMChain(
      2     llm={"llm": "Sanjay1234/Trillo-Project"},  # Provide the llm parameter as a dictionary
      3         prompt={"prompt": "Summarize this text:"}
      4 )

File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\langchain\load\serializable.py:74, in Serializable.__init__(self, **kwargs)
     73 def __init__(self, **kwargs: Any) -> None:
---> 74     super().__init__(**kwargs)
     75     self._lc_kwargs = kwargs

File ~\AppData\Local\Programs\Python\Python39\lib\site-packages\pydantic\main.py:341, in pydantic.main.BaseModel.__init__()

ValidationError: 2 validation errors for LLMChain
prompt
  Can't instantiate abstract class BasePromptTemplate with abstract methods format, format_prompt (type=type_error)
llm
  Can't instantiate abstract class BaseLanguageModel with abstract methods agenerate_prompt, apredict, apredict_messages, generate_prompt, invoke, predict, predict_messages (type=type_error)

### Suggestion:

_No response_