๐Ÿ“–Advanced Usage

This showcases on how to use the model along with vectordb and retrieval to make the model converse on top of contextual data

There are two ways we can implement this:

  • Python

  • CLI

Python Implementation:

==> With default supported ETLs

from genai_stack.model import OpenAIGpt35Model

model = OpenAIGpt35Model.from_kwargs(
 fields={"openai_api_key": "Paste your Open AI key"}
)

# This does the ETL underneath but supports only the default 5 data types
model.add_source("csv", "valid_csv_path_or_url") 

model.predict("<Some question whose answer is could be found in the csv>")

For more context on default ETLs check the doc here.

==> With your own custom ETL, Retriever and Vectordb

For more context refer to each component's documentation

CLI Implementation

You can write a etl.json for the etl process and model.json to perform inference on the extracted data

etl.json

Run the ETL command:

model.json

Run the model command

Important Note: The vectordb section should be the same for the etl.json and model.json.

Explanation: During the ETL process all the data are extracted and stored into the vectordb as embeddings on which we can perform semantic search. So when we are using the model on top of contextual data we need to specify the source of the contextual data.

The source of contextual data in our case is the vectordb into which the ETL contents were loaded into . So that's why the vectordb content should be the same for both the model.json and etl.json

Last updated