Skip to content

Commit

Permalink
Fix embedding size and correctly filter default models (#31)
Browse files Browse the repository at this point in the history
* correctly filter default model

* minor typing fix

* fix chat mode streaming with non-multiturn columns

* minor fix to ollama model, update to qwen2.5 3B

* update changelog

---------

Co-authored-by: deafnv <[email protected]>
  • Loading branch information
noobHappylife and deafnv authored Nov 29, 2024
1 parent b144455 commit 5c3df39
Show file tree
Hide file tree
Showing 36 changed files with 827 additions and 768 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- The version number mentioned here refers to the cloud version. For each release, all SDKs will have the same major and minor version, but their patch version may differ. For example, latest Python SDK might be `v0.2.0` whereas TS SDK might be `v0.2.1`, but both will be compatible with release `v0.2`.

## [Unreleased]

Backend - owl (API server)

- Fix bge-small embedding size (1024 -> 384)
- Correctly filter models at auth level
- Fix ollama model deployment config

Frontend

- Added support for multiple multiturn columns in Chat table chat view.
- Added multiturn chat toggle to column settings.

Docker

- Added Mac Apple Silicon `compose.mac.yml`
- Update `ollama.yml` to use Qwen2.5 3B
- Fix ollama default config

## [v0.3.1] (2024-11-26)

This is a bug fix release for frontend code. SDKs are not affected.
Expand Down
33 changes: 7 additions & 26 deletions clients/python/src/jamaibase/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,46 +1719,27 @@ class ActionTableSchemaCreate(TableSchemaCreate):


class AddActionColumnSchema(ActionTableSchemaCreate):
# TODO: Deprecate this
pass


class KnowledgeTableSchemaCreate(TableSchemaCreate):
# TODO: Maybe deprecate this and use EmbedGenConfig instead ?
embedding_model: str

@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
num_text_cols = sum(c.id.lower() in ("text", "title", "file id") for c in self.cols)
if num_text_cols != 0:
raise ValueError("Schema cannot contain column names: 'Text', 'Title', 'File ID'.")
return self


class AddKnowledgeColumnSchema(TableSchemaCreate):
@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
num_text_cols = sum(c.id.lower() in ("text", "title", "file id") for c in self.cols)
if num_text_cols != 0:
raise ValueError("Schema cannot contain column names: 'Text', 'Title', 'File ID'.")
return self
# TODO: Deprecate this
pass


class ChatTableSchemaCreate(TableSchemaCreate):
@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
num_text_cols = sum(c.id.lower() in ("user", "ai") for c in self.cols)
if num_text_cols != 2:
raise ValueError("Schema must contain column names: 'User' and 'AI'.")
return self
pass


class AddChatColumnSchema(TableSchemaCreate):
@model_validator(mode="after")
def check_cols(self) -> Self:
super().check_cols()
return self
# TODO: Deprecate this
pass


class TableMeta(TableBase):
Expand Down
45 changes: 38 additions & 7 deletions clients/python/tests/oss/gen_table/test_table_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"str": '"Arrival" is a 2016 science fiction film. "Arrival" è un film di fantascienza del 2016. 「Arrival」は2016年のSF映画です。',
}
KT_FIXED_COLUMN_IDS = ["Title", "Title Embed", "Text", "Text Embed", "File ID"]
CT_FIXED_COLUMN_IDS = ["User"]

TABLE_ID_A = "table_a"
TABLE_ID_B = "table_b"
Expand Down Expand Up @@ -1430,6 +1431,21 @@ def test_kt_drop_invalid_columns(client_cls: Type[JamAI]):
)


@flaky(max_runs=5, min_passes=1, rerun_filter=_rerun_on_fs_error_with_delay)
@pytest.mark.parametrize("client_cls", CLIENT_CLS)
def test_ct_drop_invalid_columns(client_cls: Type[JamAI]):
table_type = "chat"
jamai = client_cls()
with _create_table(jamai, table_type) as table:
assert isinstance(table, p.TableMetaResponse)
for col in CT_FIXED_COLUMN_IDS:
with pytest.raises(RuntimeError):
jamai.table.drop_columns(
table_type,
p.ColumnDropRequest(table_id=table.id, column_names=[col]),
)


@flaky(max_runs=5, min_passes=1, rerun_filter=_rerun_on_fs_error_with_delay)
@pytest.mark.parametrize("client_cls", CLIENT_CLS)
@pytest.mark.parametrize("table_type", TABLE_TYPES)
Expand All @@ -1450,7 +1466,7 @@ def test_rename_columns(
assert isinstance(table, p.TableMetaResponse)
assert all(isinstance(c, p.ColumnSchema) for c in table.cols)
# Test rename on empty table
table = jamai.rename_columns(
table = jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(y="z")),
)
Expand All @@ -1475,7 +1491,7 @@ def test_rename_columns(
_add_row(jamai, table_type, False, data=dict(x="True", z="<dummy>"))
# Test rename table with data
# Test also auto gen config reference update
table = jamai.rename_columns(
table = jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(x="a")),
)
Expand Down Expand Up @@ -1503,14 +1519,14 @@ def test_rename_columns(

# Repeated new column names
with pytest.raises(RuntimeError):
jamai.rename_columns(
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(a="b", z="b")),
)

# Overlapping new and old column names
with pytest.raises(RuntimeError):
jamai.rename_columns(
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map=dict(a="b", z="a")),
)
Expand All @@ -1525,7 +1541,22 @@ def test_kt_rename_invalid_columns(client_cls: Type[JamAI]):
assert isinstance(table, p.TableMetaResponse)
for col in KT_FIXED_COLUMN_IDS:
with pytest.raises(RuntimeError):
jamai.rename_columns(
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map={col: col}),
)


@flaky(max_runs=5, min_passes=1, rerun_filter=_rerun_on_fs_error_with_delay)
@pytest.mark.parametrize("client_cls", CLIENT_CLS)
def test_ct_rename_invalid_columns(client_cls: Type[JamAI]):
table_type = "chat"
jamai = client_cls()
with _create_table(jamai, table_type) as table:
assert isinstance(table, p.TableMetaResponse)
for col in CT_FIXED_COLUMN_IDS:
with pytest.raises(RuntimeError):
jamai.table.rename_columns(
table_type,
p.ColumnRenameRequest(table_id=table.id, column_map={col: col}),
)
Expand Down Expand Up @@ -1582,7 +1613,7 @@ def test_reorder_columns(
cols = [c.id for c in table.cols]
assert cols == expected_order, cols
# Test reorder empty table
table = jamai.reorder_columns(
table = jamai.table.reorder_columns(
table_type,
p.ColumnReorderRequest(table_id=TABLE_ID_A, column_names=column_names),
)
Expand Down Expand Up @@ -1692,7 +1723,7 @@ def test_reorder_columns_invalid(
else:
raise ValueError(f"Invalid table type: {table_type}")
with pytest.raises(RuntimeError, match="referenced an invalid source column"):
jamai.reorder_columns(
jamai.table.reorder_columns(
table_type,
p.ColumnReorderRequest(table_id=TABLE_ID_A, column_names=column_names),
)
Expand Down
4 changes: 2 additions & 2 deletions docker/compose.cpu.ollama.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ services:
echo 'ollama serve did not start in time'; \
exit 1; \
fi; \
ollama pull phi3.5 && ollama cp phi3.5 microsoft/Phi3.5-mini-instruct; \
ollama pull qwen2.5:3b && ollama cp qwen2.5:3b Qwen/Qwen2.5-3B-Instruct; \
tail -f /dev/null",
]
restart: unless-stopped
healthcheck:
test: ["CMD", "sh", "-c", "ollama show microsoft/Phi3.5-mini-instruct || exit 1"]
test: ["CMD", "sh", "-c", "ollama show Qwen/Qwen2.5-3B-Instruct || exit 1"]
interval: 20s
timeout: 2s
retries: 20
Expand Down
2 changes: 1 addition & 1 deletion docker/ollama.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
services:
owl:
environment:
- OWL_MODELS_CONFIG="models_ollama.json"
- OWL_MODELS_CONFIG=models_ollama.json
1 change: 1 addition & 0 deletions scripts/remove_cloud_modules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ function quiet_rm($item)
quiet_rm "services/app/ecosystem.config.cjs"
quiet_rm "services/appecosystem.json"
quiet_rm ".github/workflows/trigger-push-gh-image.yml"
quiet_rm ".github/workflows/ci.cloud.yml"
1 change: 1 addition & 0 deletions scripts/remove_cloud_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ find . -type d -name "(cloud)" -exec rm -rf {} +
rm -f services/app/ecosystem.config.cjs
rm -f services/app/ecosystem.json
rm -f .github/workflows/trigger-push-gh-image.yml
rm -f .github/workflows/ci.cloud.yml
2 changes: 1 addition & 1 deletion services/api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ dependencies = [
"sqlmodel~=0.0.21",
"srsly~=2.4.8",
# starlette 0.38.3 and 0.38.4 seem to have issues with background tasks
"starlette==0.38.2",
"starlette~=0.41.3",
"stripe~=9.12.0",
"tantivy~=0.22.0",
"tenacity~=8.5.0",
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/owl/configs/models_aipc.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"id": "ellm/BAAI/bge-small-en-v1.5",
"name": "ELLM BAAI BGE Small EN v1.5",
"context_length": 512,
"embedding_size": 1024,
"embedding_size": 384,
"languages": ["mul"],
"capabilities": ["embed"],
"deployments": [
Expand Down
12 changes: 6 additions & 6 deletions services/api/src/owl/configs/models_ollama.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
]
},
{
"id": "ellm/microsoft/Phi3.5-mini-instruct",
"name": "ELLM Phi3.5 mini instruct (3.8B)",
"context_length": 131072,
"id": "ellm/Qwen/Qwen2.5-3B-Instruct",
"name": "ELLM Qwen2.5 (3B)",
"context_length": 32000,
"languages": ["en"],
"capabilities": ["chat"],
"deployments": [
{
"litellm_id": "ollama_chat/microsoft/Phi3.5-mini-instruct",
"api_base": "http://ollama:11434",
"litellm_id": "openai/Qwen/Qwen2.5-3B-Instruct",
"api_base": "http://ollama:11434/v1",
"provider": "ellm"
}
]
Expand All @@ -62,7 +62,7 @@
"id": "ellm/BAAI/bge-small-en-v1.5",
"name": "ELLM BAAI BGE Small EN v1.5",
"context_length": 512,
"embedding_size": 1024,
"embedding_size": 384,
"languages": ["mul"],
"capabilities": ["embed"],
"deployments": [
Expand Down
Loading

0 comments on commit 5c3df39

Please sign in to comment.