This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docarray import Document, DocumentArray | |
from jina import Executor, requests | |
from transformers import AutoModelForCausalLM, AutoTokenizer | |
class StableLM(Executor): | |
def __init__(self, **kwargs): | |
super().__init__(**kwargs) | |
self.tokenizer = AutoTokenizer.from_pretrained( | |
'StabilityAI/stablelm-base-alpha-3b' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`. | |
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages (raised from /mnt/data/work/repos/scene-alexcg/env/lib/python3.10/site-packages/pkg_resources/__init__.py:2804) | |
DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google.logging')`. | |
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages (raised from /mnt/data/work/repos/scene-alexcg/env/lib/python3.10/site-packages/pkg_resources/__init__.py:2804) | |
DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`. | |
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docarray import BaseDoc, DocArray | |
from docarray.documents import TextDoc | |
from docarray.typing import AnyUrl | |
from jina import Deployment, Executor, requests | |
class TextChunk(TextDoc): | |
tags: dict = {} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with flow: | |
client = Client(port=flow.port) | |
indexed_docs = client.post("/index", docs, request_size=1, show_progress=True, target_executor="(index_*|all_*)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(response[0].matches.texts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = client.search(search_doc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docarray import Document | |
search_doc = Document(text="statistic visualization") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jina import Client | |
client = Client(host="grpcs://<unique_id>.wolf.jina.ai") # Your gateway from earlier | |
client.index(docs, show_progress=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from docarray import DocumentArray | |
docs = DocumentArray.from_csv("Questions.csv", field_resolver={"Title": "text"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jtype: Flow | |
with: | |
protocol: grpc | |
executors: | |
- name: encoder | |
uses: jinahub+docker://SpacyTextEncoder/v0.4 | |
uses_with: | |
model_name: 'en_core_web_md' | |
resources: | |
memory: 8G # encoding is hungry. add more memory |
NewerOlder