Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated: acclerate and spacy packages #1135

Merged
merged 14 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langtest/augmentation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List, TypedDict, Union
import os

from pydantic import BaseModel, validator
from pydantic.v1 import BaseModel, validator
from langtest.logger import logger


Expand Down
6 changes: 3 additions & 3 deletions langtest/modelhandler/llm_modelhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from typing import Any, List, Union
import langchain.llms as lc
import langchain.chat_models as chat_models
from langchain.chains import LLMChain
from langchain.chains.llm import LLMChain
from langchain_core.prompts import PromptTemplate
from langchain_core.exceptions import OutputParserException
from pydantic import Field, ValidationError
from pydantic.v1 import Field, ValidationError

from langtest.utils.custom_types.output import NEROutput
from langtest.utils.custom_types.predictions import NERPrediction
Expand Down Expand Up @@ -311,7 +311,7 @@ def __call__(self, text: str, *args, **kwargs):

def __output_parser(self):
from langchain_core.output_parsers import JsonOutputParser
from pydantic import BaseModel
from pydantic.v1 import BaseModel

class Word(BaseModel):
"""Single word in a named entity recognition prediction"""
Expand Down
2 changes: 1 addition & 1 deletion langtest/prompts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import defaultdict
from typing import Dict, List, Union

from pydantic import BaseModel, Extra, validator
from pydantic.v1 import BaseModel, validator, Extra


class MessageType(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion langtest/utils/custom_types/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from pydantic import BaseModel
from pydantic.v1 import BaseModel
from collections.abc import Hashable
import importlib
from typing import List, Tuple
Expand Down
2 changes: 1 addition & 1 deletion langtest/utils/custom_types/output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List, Optional, TypeVar, Union
from pydantic import BaseModel, validator
from pydantic.v1 import BaseModel, validator
from .helpers import Span
from .predictions import NERPrediction, SequenceLabel

Expand Down
2 changes: 1 addition & 1 deletion langtest/utils/custom_types/predictions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from pydantic import BaseModel, Field
from pydantic.v1 import BaseModel, Field

from .helpers import Span

Expand Down
2 changes: 1 addition & 1 deletion langtest/utils/custom_types/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from langtest.modelhandler.modelhandler import ModelAPI
from ...errors import Errors
from pydantic import BaseModel, PrivateAttr, validator, Field
from pydantic.v1 import BaseModel, PrivateAttr, validator, Field
from .helpers import Transformation, Span
from .helpers import default_user_prompt
from ...metrics import EmbeddingDistance
Expand Down
4 changes: 2 additions & 2 deletions langtest/utils/number_to_word.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from numbers import Number
from pydantic import Field
from pydantic.typing import Annotated
from pydantic.v1 import Field
from pydantic.v1.typing import Annotated
from ..errors import Errors
from langtest.transform.constants import (
ordinal,
Expand Down
1,649 changes: 1,122 additions & 527 deletions poetry.lock

Large diffs are not rendered by default.

23 changes: 13 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ extend-exclude = "langtest/transform/constants.py"
exclude = 'langtest/errors.py'

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
pydantic = "1.10.11"
johnsnowlabs = { version = "4.3.5", optional = true }
python = ">=3.9,<4.0"
pydantic = "2.9.2"
johnsnowlabs = {version = "5.5.0", optional = true}
rouge-score = { version = "^0.1.2", optional = true }
evaluate = { version = "^0.4.0", optional = true }
transformers = "^4.44.2"
Expand All @@ -68,46 +68,49 @@ tqdm = "^4.65.0"
cohere = { version = "^4.10.0", optional = true}
ai21 = {version = "^1.1.0", optional = true}
metaflow = {version = ">=2.9.0", optional = true}
accelerate = {version = "0.33.0", optional = true}
accelerate = {version = "0.34.2", optional = true}
seqeval = {version = "^1.2.0", optional = true}
mlflow = {version = "^2.16.2", optional = true}
datasets = {version = ">=2.14.0", optional = true}
matplotlib = {version = "^3.7.2", optional = true}
tenacity = {version = "^8.2.2", optional = true}
langchain = {version = "^0.1.11", optional = true}
langchain = {version = "0.3.6", optional = true}
typing-extensions = "^4.10.0"
langchain-openai = {version = "^0.1.4", optional = true}
langchain-openai = {version = "0.2.5", optional = true}
boto3 = {version = "^1.34.93", optional = true}
importlib-resources = "^6.4.0"
click = "^8.1.7"
openpyxl = "^3.1.5"
tables = "3.8.0"
pillow = "10.0.0"
langchain-databricks = {version = "0.1.1", optional = true}
langchain-community = {version = "0.3.5", optional = true}

[tool.poetry.extras]
transformers = ["transformers", "torch", "accelerate", "datasets"]
evaluate = ["evaluate", "rouge-score", "seqeval"]
spacy = ["spacy"]
langchain = ["langchain", "langchain-openai"]
johnsnowlabs = ["johnsnowlabs"]
openai = ["openai", "langchain", "langchain-openai"]
cohere = ["cohere", "langchain"]
ai21 = ["ai21", "langchain"]
cohere = ["cohere", "langchain", "langchain-community"]
ai21 = ["ai21", "langchain", "langchain-community"]
huggingface_hub = ["huggingface_hub", "langchain"]
metaflow = ["metaflow"]
mlflow = ["mlflow"]
datasets = ["datasets"]
matplotlib = ["matplotlib"]
databricks = ["langchain", "langchain-databricks"]

[tool.poetry.group.dev.dependencies]
ipdb = "^0.13.13"
pytest = "^7.4.0"
taskipy = "^1.11.0"
en-core-web-sm = { url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.5.0/en_core_web_sm-3.5.0.tar.gz" }
en-core-web-sm = { url = "https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0.tar.gz" }
black = "^23.3.0"
pyproject-flake8 = "<6.0.0"
pre-commit = "^3.3.3"
pydocstyle = "^6.3.0"
ipykernel = "^6.29.5"

[tool.taskipy.tasks]
test = "pytest tests/* -v --disable-warnings"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_modelhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ def test_ai21_model(self) -> None:
"""
Test loading a model from the Ai21 hub
"""
with self.assertRaises(ConfigError) as _:
with self.assertRaises(Exception) as _:
task = TaskManager("question-answering")
task.model(model_path="j2-jumbo-instruct", model_hub="ai21")

def test_openai_model(self) -> None:
"""
Test loading a model from the OpenAI hub
"""
with self.assertRaises(ConfigError) as _:
with self.assertRaises(Exception) as _:
task = TaskManager("question-answering")
task.model(model_path="gpt-3.5-turbo", model_hub="openai")

def test_cohere_model(self) -> None:
"""
Test loading a model from Cohere
"""
with self.assertRaises(ConfigError) as _:
with self.assertRaises(Exception) as _:
task = TaskManager("question-answering")
task.model(model_path="command-xlarge-nightly", model_hub="cohere")

Expand Down
Loading