Skip to content

Instantly share code, notes, and snippets.

View dgallitelli's full-sized avatar
🌍
The world is mine for the taking.

Davide Gallitelli dgallitelli

🌍
The world is mine for the taking.
View GitHub Profile
@dgallitelli
dgallitelli / bonito-v1-sagemaker.ipynb
Last active April 4, 2024 13:46
Using Bonito v1 on Amazon SageMaker to generate datasets for LLM fine-tuning
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dgallitelli
dgallitelli / kendra_results.py
Created June 29, 2023 15:42
LangChain + Kendra + Comprehend for ANY language querying
from langchain.docstore.document import Document
import boto3
import re
def clean_result(res_text):
res = re.sub("\s+", " ", res_text).replace("...","")
return res
def get_query_language(query):
# Use Amazon Comprehend to detect the language of the query
@dgallitelli
dgallitelli / sagemaker_async_endpoint.py
Last active July 3, 2023 17:20
Using SageMaker Asynchronous Inference with LangChain
"""Wrapper around Sagemaker InvokeEndpointAsync API."""
from abc import abstractmethod
from typing import Any, List, Optional
from langchain.callbacks.manager import CallbackManagerForLLMRun
from langchain.llms.utils import enforce_stop_tokens
from langchain.llms.sagemaker_endpoint import SagemakerEndpoint
import boto3, time, os, uuid
from botocore.exceptions import ClientError
def wait_inference_file(output_url, failure_url, s3_client=None):