rllm.llm.LLMWithRetriever

class rllm.llm.LLMWithRetriever(file_path: str, metadata_path: str, task_info_path: str, label_info_path: str, llm: BaseChatModel | BaseLLM | None = None, *, shots: int = 4, test_size: float | int = 0.2, target_column: str | None = None, seed: int = 0)[source]

Bases: object

A class that integrates a language model with a retriever for classification tasks.

df

The dataframe loaded from the CSV file.

Type:

pd.DataFrame

dir

The directory of the input file.

Type:

str

data_name

The name of the dataset (without extension).

Type:

str

metadata

Metadata loaded from the JSON file.

Type:

dict

task_info

Task description loaded from the TXT file.

Type:

str

label_info

Label information loaded from the TXT file.

Type:

str

llm

The language model instance.

Type:

Union[LC.BaseChatModel, LC.BaseLLM]

shots

Number of examples to retrieve for few-shot learning.

Type:

int

seed

Random seed for reproducibility.

Type:

int

train_file_path

Path to the training data CSV file.

Type:

str

test_file_path

Path to the testing data CSV file.

Type:

str

label_file_path

Path to the label data CSV file.

Type:

str

retriever

Instance of the retriever for fetching similar examples.

Type:

SingleTableRetriever

invoke()[source]

Executes the inference process by retrieving neighbors for test instances and querying the language model for predictions.

Saves the results to a JSON file in the same directory as the input file.