From 5a7ee3d5ec855bd2291deb6353eed716314829e8 Mon Sep 17 00:00:00 2001 From: FloRul Date: Fri, 16 Feb 2024 11:32:58 -0500 Subject: [PATCH] Update lambda configuration and chunk size --- lambdas/inference/lambda.tf | 6 +++--- lambdas/ingestion/lambda.tf | 3 ++- lambdas/ingestion/src/index.py | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lambdas/inference/lambda.tf b/lambdas/inference/lambda.tf index ee9c75a..6c5c5c6 100644 --- a/lambdas/inference/lambda.tf +++ b/lambdas/inference/lambda.tf @@ -29,10 +29,10 @@ module "lambda_function_container_image" { ENABLE_RETRIEVAL = 1 MEMORY_LAMBDA_NAME = var.memory_lambda_name DYNAMO_TABLE = var.dynamo_history_table_name - TOP_K = 50 - TEMPERATURE = 0.5 + TOP_K = 10 + TEMPERATURE = 0.1 TOP_P = 0.99 - RELEVANCE_THRESHOLD = 0.65 + RELEVANCE_THRESHOLD = 0.67 MODEL_ID = "anthropic.claude-instant-v1" EMBEDDING_COLLECTION_NAME = var.embedding_collection_name SYSTEM_PROMPT = "Answer in four to five sentences maximum.Answer in french." diff --git a/lambdas/ingestion/lambda.tf b/lambdas/ingestion/lambda.tf index aa62ab0..43aa2f3 100644 --- a/lambdas/ingestion/lambda.tf +++ b/lambdas/ingestion/lambda.tf @@ -23,7 +23,8 @@ module "lambda_function_container_image" { PGVECTOR_DATABASE = var.pg_vector_database PGVECTOR_USER = var.pg_vector_user PGVECTOR_PASSWORD_SECRET_NAME = var.pg_vector_password_secret_name - USE_TEXTRACT = 0 + CHUNK_SIZE = 256 + CHUNK_OVERLAP = 20 } policy_statements = { log_group = { diff --git a/lambdas/ingestion/src/index.py b/lambdas/ingestion/src/index.py index 1cfbfc6..518f469 100644 --- a/lambdas/ingestion/src/index.py +++ b/lambdas/ingestion/src/index.py @@ -31,6 +31,8 @@ def get_secret(): PGVECTOR_PORT = int(os.environ.get("PGVECTOR_PORT", 5432)) PGVECTOR_DATABASE = os.environ.get("PGVECTOR_DATABASE", "postgres") PGVECTOR_USER = os.environ.get("PGVECTOR_USER", "postgres") +CHUNK_SIZE = int(os.environ.get("CHUNK_SIZE", 256)) +CHUNK_OVERLAP = int(os.environ.get("CHUNK_OVERLAP", 20)) PGVECTOR_PASSWORD = get_secret() @@ -100,7 +102,7 @@ def extract_pdf_content(file_path, file_name): loader = PyPDFLoader(file_path) docs = loader.load_and_split( - text_splitter=RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=50) + text_splitter=RecursiveCharacterTextSplitter(chunk_size=CHUNK_SIZE, chunk_overlap=CHUNK_OVERLAP) ) created_at = datetime.datetime.now().isoformat() for doc in docs: