Skip to content

Commit

Permalink
Merge branch 'main' into add-text2sql
Browse files Browse the repository at this point in the history
  • Loading branch information
elronbandel authored Jan 22, 2025
2 parents 9ae0061 + 52031bb commit 4fc611f
Show file tree
Hide file tree
Showing 49 changed files with 168 additions and 80 deletions.
2 changes: 2 additions & 0 deletions prepare/cards/open_australian_legal_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
card = TaskCard(
loader=LoadHF(
path="umarbutler/open-australian-legal-qa",
name="default",
),
preprocess_steps=[
SplitRandomMix(
Expand Down Expand Up @@ -51,6 +52,7 @@
card = TaskCard(
loader=LoadHF(
path="umarbutler/open-australian-legal-qa",
name="default",
),
preprocess_steps=[
SplitRandomMix(
Expand Down
2 changes: 1 addition & 1 deletion prepare/recipes/tables_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
serializers = ",".join(list(SERIALIZERS))
max_augmentors = 10
max_pred_tokens = 100
num_demos = 5
recipes_only = False

# Process parameters
Expand All @@ -35,6 +34,7 @@
for card in cards_parsed:
for augment in all_augment:
for serializer in serializers_parsed:
num_demos = 1 if card == "wikitq" else 5
kwargs = {
"card": "cards." + card,
"serializer": f"serializers.table.{serializer}"
Expand Down
34 changes: 33 additions & 1 deletion src/unitxt/assistant/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import datetime
import importlib
import json
import logging
import os
import uuid

Expand All @@ -8,8 +10,11 @@
import pandas as pd
import streamlit as st
import torch
from litellm import AuthenticationError
from transformers import AutoTokenizer

logger = logging.getLogger("unitxt-assistance")


@st.cache_resource
def load_data():
Expand All @@ -20,9 +25,36 @@ def load_data():
return metadata_df, embeddings


def get_embedding_with_retry(model, input, max_retries=3):
"""This function calls the litellm.embedding method and handles token expiration.
It will retry the call up to `max_retries` times if an AuthenticationError is raised.
"""
retries = 0
actual_exception = None
while retries < max_retries:
try:
return litellm.embedding(model=model, input=input)

except AuthenticationError as e:
actual_exception = e
retries += 1
logger.info(
f"Authentication error: {e}. Retrying... ({retries}/{max_retries})"
)
importlib.reload(
litellm
) # Reload the litellm module to clear any cached state

# If all retries fail, raise an error
raise Exception(
f"Failed to get embedding after {max_retries} attempts. Exception: {actual_exception}"
)


def search(query, metadata_df, embeddings, max_tokens=5000, min_text_length=50):
# Generate embedding for the query using litellm
response = litellm.embedding(
response = get_embedding_with_retry(
model="watsonx/intfloat/multilingual-e5-large",
input=[query],
)
Expand Down
70 changes: 35 additions & 35 deletions src/unitxt/catalog/benchmarks/tables_benchmark.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,71 +683,71 @@
"concat": {
"__type__": "benchmark",
"subsets": {
"insert_empty_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.concat.insert_empty_rows_augmentation_5_demos",
"no_augmentation_5_demos": "recipes.tables_benchmark.wikitq.concat.no_augmentation_5_demos",
"shuffle_cols_augmentation_5_demos": "recipes.tables_benchmark.wikitq.concat.shuffle_cols_augmentation_5_demos",
"shuffle_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.concat.shuffle_rows_augmentation_5_demos",
"transpose_augmentation_5_demos": "recipes.tables_benchmark.wikitq.concat.transpose_augmentation_5_demos"
"insert_empty_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.concat.insert_empty_rows_augmentation_1_demos",
"no_augmentation_1_demos": "recipes.tables_benchmark.wikitq.concat.no_augmentation_1_demos",
"shuffle_cols_augmentation_1_demos": "recipes.tables_benchmark.wikitq.concat.shuffle_cols_augmentation_1_demos",
"shuffle_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.concat.shuffle_rows_augmentation_1_demos",
"transpose_augmentation_1_demos": "recipes.tables_benchmark.wikitq.concat.transpose_augmentation_1_demos"
}
},
"csv": {
"__type__": "benchmark",
"subsets": {
"insert_empty_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.csv.insert_empty_rows_augmentation_5_demos",
"no_augmentation_5_demos": "recipes.tables_benchmark.wikitq.csv.no_augmentation_5_demos",
"shuffle_cols_augmentation_5_demos": "recipes.tables_benchmark.wikitq.csv.shuffle_cols_augmentation_5_demos",
"shuffle_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.csv.shuffle_rows_augmentation_5_demos",
"transpose_augmentation_5_demos": "recipes.tables_benchmark.wikitq.csv.transpose_augmentation_5_demos"
"insert_empty_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.csv.insert_empty_rows_augmentation_1_demos",
"no_augmentation_1_demos": "recipes.tables_benchmark.wikitq.csv.no_augmentation_1_demos",
"shuffle_cols_augmentation_1_demos": "recipes.tables_benchmark.wikitq.csv.shuffle_cols_augmentation_1_demos",
"shuffle_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.csv.shuffle_rows_augmentation_1_demos",
"transpose_augmentation_1_demos": "recipes.tables_benchmark.wikitq.csv.transpose_augmentation_1_demos"
}
},
"df": {
"__type__": "benchmark",
"subsets": {
"insert_empty_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.df.insert_empty_rows_augmentation_5_demos",
"no_augmentation_5_demos": "recipes.tables_benchmark.wikitq.df.no_augmentation_5_demos",
"shuffle_cols_augmentation_5_demos": "recipes.tables_benchmark.wikitq.df.shuffle_cols_augmentation_5_demos",
"shuffle_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.df.shuffle_rows_augmentation_5_demos",
"transpose_augmentation_5_demos": "recipes.tables_benchmark.wikitq.df.transpose_augmentation_5_demos"
"insert_empty_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.df.insert_empty_rows_augmentation_1_demos",
"no_augmentation_1_demos": "recipes.tables_benchmark.wikitq.df.no_augmentation_1_demos",
"shuffle_cols_augmentation_1_demos": "recipes.tables_benchmark.wikitq.df.shuffle_cols_augmentation_1_demos",
"shuffle_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.df.shuffle_rows_augmentation_1_demos",
"transpose_augmentation_1_demos": "recipes.tables_benchmark.wikitq.df.transpose_augmentation_1_demos"
}
},
"html": {
"__type__": "benchmark",
"subsets": {
"insert_empty_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.html.insert_empty_rows_augmentation_5_demos",
"no_augmentation_5_demos": "recipes.tables_benchmark.wikitq.html.no_augmentation_5_demos",
"shuffle_cols_augmentation_5_demos": "recipes.tables_benchmark.wikitq.html.shuffle_cols_augmentation_5_demos",
"shuffle_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.html.shuffle_rows_augmentation_5_demos",
"transpose_augmentation_5_demos": "recipes.tables_benchmark.wikitq.html.transpose_augmentation_5_demos"
"insert_empty_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.html.insert_empty_rows_augmentation_1_demos",
"no_augmentation_1_demos": "recipes.tables_benchmark.wikitq.html.no_augmentation_1_demos",
"shuffle_cols_augmentation_1_demos": "recipes.tables_benchmark.wikitq.html.shuffle_cols_augmentation_1_demos",
"shuffle_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.html.shuffle_rows_augmentation_1_demos",
"transpose_augmentation_1_demos": "recipes.tables_benchmark.wikitq.html.transpose_augmentation_1_demos"
}
},
"indexed_row_major": {
"__type__": "benchmark",
"subsets": {
"insert_empty_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.insert_empty_rows_augmentation_5_demos",
"no_augmentation_5_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.no_augmentation_5_demos",
"shuffle_cols_augmentation_5_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.shuffle_cols_augmentation_5_demos",
"shuffle_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.shuffle_rows_augmentation_5_demos",
"transpose_augmentation_5_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.transpose_augmentation_5_demos"
"insert_empty_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.insert_empty_rows_augmentation_1_demos",
"no_augmentation_1_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.no_augmentation_1_demos",
"shuffle_cols_augmentation_1_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.shuffle_cols_augmentation_1_demos",
"shuffle_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.shuffle_rows_augmentation_1_demos",
"transpose_augmentation_1_demos": "recipes.tables_benchmark.wikitq.indexed_row_major.transpose_augmentation_1_demos"
}
},
"json": {
"__type__": "benchmark",
"subsets": {
"insert_empty_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.json.insert_empty_rows_augmentation_5_demos",
"no_augmentation_5_demos": "recipes.tables_benchmark.wikitq.json.no_augmentation_5_demos",
"shuffle_cols_augmentation_5_demos": "recipes.tables_benchmark.wikitq.json.shuffle_cols_augmentation_5_demos",
"shuffle_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.json.shuffle_rows_augmentation_5_demos",
"transpose_augmentation_5_demos": "recipes.tables_benchmark.wikitq.json.transpose_augmentation_5_demos"
"insert_empty_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.json.insert_empty_rows_augmentation_1_demos",
"no_augmentation_1_demos": "recipes.tables_benchmark.wikitq.json.no_augmentation_1_demos",
"shuffle_cols_augmentation_1_demos": "recipes.tables_benchmark.wikitq.json.shuffle_cols_augmentation_1_demos",
"shuffle_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.json.shuffle_rows_augmentation_1_demos",
"transpose_augmentation_1_demos": "recipes.tables_benchmark.wikitq.json.transpose_augmentation_1_demos"
}
},
"markdown": {
"__type__": "benchmark",
"subsets": {
"insert_empty_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.markdown.insert_empty_rows_augmentation_5_demos",
"no_augmentation_5_demos": "recipes.tables_benchmark.wikitq.markdown.no_augmentation_5_demos",
"shuffle_cols_augmentation_5_demos": "recipes.tables_benchmark.wikitq.markdown.shuffle_cols_augmentation_5_demos",
"shuffle_rows_augmentation_5_demos": "recipes.tables_benchmark.wikitq.markdown.shuffle_rows_augmentation_5_demos",
"transpose_augmentation_5_demos": "recipes.tables_benchmark.wikitq.markdown.transpose_augmentation_5_demos"
"insert_empty_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.markdown.insert_empty_rows_augmentation_1_demos",
"no_augmentation_1_demos": "recipes.tables_benchmark.wikitq.markdown.no_augmentation_1_demos",
"shuffle_cols_augmentation_1_demos": "recipes.tables_benchmark.wikitq.markdown.shuffle_cols_augmentation_1_demos",
"shuffle_rows_augmentation_1_demos": "recipes.tables_benchmark.wikitq.markdown.shuffle_rows_augmentation_1_demos",
"transpose_augmentation_1_demos": "recipes.tables_benchmark.wikitq.markdown.transpose_augmentation_1_demos"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/unitxt/catalog/cards/open_australian_legal_qa.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"__type__": "task_card",
"loader": {
"__type__": "load_hf",
"path": "umarbutler/open-australian-legal-qa"
"path": "umarbutler/open-australian-legal-qa",
"name": "default"
},
"preprocess_steps": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"__type__": "task_card",
"loader": {
"__type__": "load_hf",
"path": "umarbutler/open-australian-legal-qa"
"path": "umarbutler/open-australian-legal-qa",
"name": "default"
},
"preprocess_steps": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"__type__": "llm_judge_direct",
"inference_engine": {
"__type__": "rits_inference_engine",
"model_name": "ibm-granite/granite-3.0-8b-instruct",
"max_tokens": 1024,
"seed": 42
},
"evaluator_name": "GRANITE3_8B",
"generate_summaries": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"__type__": "llm_judge_direct",
"inference_engine": {
"__type__": "rits_inference_engine",
"model_name": "ibm-granite/granite-3.1-8b-instruct",
"max_tokens": 1024,
"seed": 42
},
"evaluator_name": "GRANITE3_1_8B",
"generate_summaries": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"__type__": "llm_judge_pairwise",
"inference_engine": {
"__type__": "rits_inference_engine",
"model_name": "ibm-granite/granite-3.0-8b-instruct",
"max_tokens": 1024,
"seed": 42
},
"evaluator_name": "GRANITE3_8B",
"generate_summaries": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"__type__": "llm_judge_pairwise",
"inference_engine": {
"__type__": "rits_inference_engine",
"model_name": "ibm-granite/granite-3.1-8b-instruct",
"max_tokens": 1024,
"seed": 42
},
"evaluator_name": "GRANITE3_1_8B",
"generate_summaries": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.concat",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.concat",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.concat",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.concat",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.concat",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": null,
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": null,
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": null,
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": null,
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": null,
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.df",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.df",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.df",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.df",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__type__": "dataset_recipe",
"card": "cards.wikitq",
"serializer": "serializers.table.df",
"num_demos": 5,
"num_demos": 1,
"demos_pool_size": -1,
"loader_limit": 10000,
"augmentor": [
Expand Down
Loading

0 comments on commit 4fc611f

Please sign in to comment.