You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

The Calculate Vector Stage is the first step of semantic search. In this stage the vector is calculated or retrieved based on the model given by the user. There are 3 types of models enumerated.

  1. Saga model: This model retrieves the vector from saga, an entry with the value is require in saga. The value needs to be the same as the saga stage name.
  2. Open AI model: This model calculates the vector with Open AI API, this needs the credentials to make calls to the API as environment variables. These are the supported Open AI models:
    1. text-embedding-ada-002

    2. text-search-ada-doc-001

    3. text-search-curie-doc-001

  3. Sentence Transformer GTR: This model calculates the vector with the GTR component of the python library sentence_transformer. These are the supported GTR models:
    1. sentence-transformers/gtr-t5-base
    2. sentence-transformers/gtr-t5-large
    3. sentence-transformers/gtr-t5-xl
    4. sentence-transformers/gtr-t5-xxl

The Calculate Vector Stage stores the vector on intermediate for the Create Query Stage usage.

Properties

PropertyDescriptionDefaultTypeRequiredQPL Config?
typeStage class name-stringYesNo
enableEnable stage for executiontruebooleanNoNo
nameName for this specific stage"vector"stringNoNo
save_to_intermediateIf true, the result of the stage will be stored in the intermediate instead of the final sectionfalsebooleanNoNo
expand_resultIndicates if the result of this stage should be expanded into the final data dictionary instead of being appended as usualfalsebooleanNoNo
halt_on_exceptionIndicates if the pipeline should be interrupted in case of an exceptiontruebooleanNoNo
modelIndicates the model to be used to calculate or retrieve the vectors. Its restricted by the types allowed by the enum.

EnumSaga.SAGA

EnumYesNo

open_ai_api_key

This is your Open AI key to use the chat from your service provideros.environ.get('OPEN_AI_API_KEY', 'default_key')stringNoNo

open_ai_api_base_url

Base url of your service provider for Open AI chat.os.environ.get('OPEN_AI_API_BASE_URL', 'default_url')stringNoNo

open_ai_api_type

API type, its restricted by the types allowed by the enum.EnumOpenAiType.AZUREEnumNoNo

open_ai_api_version

API version of the Open AI chatos.environ.get('OPEN_AI_API_VERSION', '2023-03-15-preview')stringNoNo


Calculate Vector Stage Intermediate Parameters

The Calculate Vector Stage offers a range of parameters that can be passed via the intermediate input to customize your search request or modify the configuration of the current stage. These parameters provide flexibility and control over the search process.


ParameterDescription
qA string query for performing a search. Can be transformed into engine-specific queries using PyQPL (Query Parser Language).
queryEngine-specific queries for the search.
knnEngine-specific queries specifically for k-nearest neighbor (KNN) searches.
filtersCalculated filters for search. This with knn parameter get stored on the same variable as a tuple, this is the second parameter of the tuple.
sizeNumber of results to return from the search request. Overrides the size specified in the configuration.
from/startIndicates the starting point for retrieving search results. Can be used interchangeably with the page parameter.
pageIt can be an alternative to from/start. It calculates the start based on the size parameter.
fetch_fieldsList of fields to fetch for each search result. Overrides the fields specified in the configuration.
exclude_fieldsList of fields to exclude from the search results. Overrides the fields specified in the configuration.
scrollScroll ID used to retrieve large numbers of results from a single search request, similar to a cursor in a traditional database.
operatorThe default operator for query string queries: AND or OR. Overrides the default operator specified in the configuration.
vectorCalculated vectors use to create the knn query.

Remember that the intermediate can be fill with either other stages or the original request body that trigger the pipeline, making this essentially REST API parameters


Example Configuration

_vector_stage = CalculateVectorStage(
    enable=True,
    save_to_intermediate=True,
    expand_result=False,
    halt_on_exception=False,
    name=VECTOR_STAGE_NAME,
    model=EnumOpenAI.OPENAI_EMBEDDING_ADA,
    open_ai_api_key=os.environ.get('OPEN_AI_API_KEY'),
    open_ai_api_base_url=os.environ.get('OPEN_AI_API_BASE_URL'),
    open_ai_api_type=EnumOpenAiType.AZURE,
    open_ai_api_version='2023-03-15-preview',
    type='CalculateVectorStage'
)
  • No labels