diff --git a/.github/workflows/translate_docs.yaml b/.github/workflows/translate_docs.yaml new file mode 100644 index 000000000..7ec12d7b3 --- /dev/null +++ b/.github/workflows/translate_docs.yaml @@ -0,0 +1,59 @@ +name: Translate Docs + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - docs/** + +jobs: + translate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get changed files in docs + run: | + git fetch origin main + git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- docs/ > changed_files.txt + cat changed_files.txt + + - name: Run translate_docs.py + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + run: | + pip install litellm + python tools/translate_docs.py $(cat changed_files.txt) + rm changed_files.txt + + - name: Get current commit hash + id: get_hash + run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Commit and create PR + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add . + if [ -n "$(git diff --cached --name-only)" ]; then + git commit -m "Translate docs and copy files" + git push origin HEAD:translate-output-${{ steps.get_hash.outputs.hash }} + echo "changes_committed=true" >> $GITHUB_ENV + else + echo "No changes to commit." + echo "changes_committed=false" >> $GITHUB_ENV + fi + + - name: Create PR + if: env.changes_committed == 'true' + uses: peter-evans/create-pull-request@v5 + with: + branch: translate-output-${{ steps.get_hash.outputs.hash }} + title: "Automated translation and file copy" + body: | + Processed changed docs files. + Commit hash: ${{ steps.get_hash.outputs.hash }} diff --git a/docs/weaviate/best-practices/index.md b/docs/weaviate/best-practices/index.md index dcb7f8e9f..d5ce37c00 100644 --- a/docs/weaviate/best-practices/index.md +++ b/docs/weaviate/best-practices/index.md @@ -99,8 +99,8 @@ As the size of your dataset grows, the accompanying vector indexes can lead to h If you have a large number of vectors, consider using vector quantization to reduce the memory footprint of the vector index. This will reduce the required memory, and allow you to scale more effectively at lower costs. -![Overview of quantization schemes](../../../_includes/images/concepts/quantization_overview_light.png#gh-light-mode-only "Overview of quantization schemes") -![Overview of quantization schemes](../../../_includes/images/concepts/quantization_overview_dark.png#gh-dark-mode-only "Overview of quantization schemes") +![Overview of quantization schemes](@site/_includes/images/concepts/quantization_overview_light.png#gh-light-mode-only "Overview of quantization schemes") +![Overview of quantization schemes](@site/_includes/images/concepts/quantization_overview_dark.png#gh-dark-mode-only "Overview of quantization schemes") For HNSW indexes, we suggest enabling product quantization (PQ) as a starting point. It provides a good set of default trade-offs between memory usage and query performance, as well as tunable parameters to optimize for your specific use case. diff --git a/docusaurus.config.js b/docusaurus.config.js index d6673d25e..6c016a7e5 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -30,7 +30,7 @@ const config = { i18n: { defaultLocale: "en", - locales: ["en"], + locales: ["en", "ja"], }, headTags: [commonRoomScript, hubspotScript], @@ -144,6 +144,10 @@ const config = { position: "right", className: "hiddenSearch", }, + { + type: "localeDropdown", + position: "right", + } ], }, prism: { diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/_customization/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_customization/index.md new file mode 100644 index 000000000..554b281cb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_customization/index.md @@ -0,0 +1,20 @@ +--- +title: 2. Weaviate のカスタマイズ +sidebar_position: 200 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +TBC + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/academy.clients.graphql.raw.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/academy.clients.graphql.raw.mdx new file mode 100644 index 000000000..f044bd172 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/academy.clients.graphql.raw.mdx @@ -0,0 +1,50 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +import weaviate +```python + +client = weaviate.Client("https://WEAVIATE_INSTANCE_URL") # Replace WEAVIATE_INSTANCE_URL with your instance URL + +query = ''' +{ + Get { + WikiArticle { + title + wiki_summary + } + } +} +''' + +result = client.query.raw(query) + +print(result) +``` + + + + +```js +Coming soon +``` + + + + +```go +TBC +``` + + + + +```java +TBC +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/example_schema.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/example_schema.mdx new file mode 100644 index 000000000..097da4fdc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/example_schema.mdx @@ -0,0 +1,83 @@ +
+ + スキーマの例 + +
+ +```json +{ + "classes": [ + { + "class": "Category", + "description": "A Jeopardy! category", + ... + "properties": [ + { + "dataType": [ + "text" + ], + "description": "The title of the category", + "name": "title", + "tokenization": "word" + } + ], + ... + "vectorizer": "text2vec-openai" + }, + { + "class": "Question", + ... + "properties": [ + { + "dataType": [ + "text" + ], + "description": "Question asked to the contestant", + ... + "name": "question", + "tokenization": "word" + }, + { + "dataType": [ + "text" + ], + "description": "Answer provided by the contestant", + ... + "name": "answer", + "tokenization": "word" + }, + { + "dataType": [ + "int" + ], + "description": "Points that the question was worth", + ... + "name": "points" + }, + { + "dataType": [ + "text" + ], + "description": "Jeopardy round", + ... + "name": "round" + }, + { + "dataType": [ + "Category" + ], + "description": "The category of the question", + ... + "name": "hasCategory" + } + ... + ], + ... + "vectorizer": "text2vec-openai" + } + ] +} +``` + +
+
\ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/preview.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/preview.mdx new file mode 100644 index 000000000..9d73c849a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/_snippets/preview.mdx @@ -0,0 +1,5 @@ +:::note プレビュー版ユニット +このユニットはプレビュー版です。 +そのため、動画やクイズ問題など、いくつかのセクションがまだ完成していません。 +完全版が公開されるまで、しばらくお待ちください。その間、下のコメント欄からご意見・ご感想をお寄せいただければ幸いです。 +::: \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/_category_.json new file mode 100644 index 000000000..ae3b74b9a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Deployment", + "position": 50 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/10_kubernetes_basics.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/10_kubernetes_basics.mdx new file mode 100644 index 000000000..5eef81823 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/10_kubernetes_basics.mdx @@ -0,0 +1,122 @@ +--- +title: Kubernetes クラスターの作成 +--- + + **Kubernetes** はオープンソースの *コンテナー オーケストレーション* プラットフォームです。つまり、 Kubernetes を使用すると、 [コンテナ化](https://www.docker.com/resources/what-container/) されたアプリケーションをデプロイ、スケール、および管理できます。 + +本番環境では、 Kubernetes は AWS、 Google Cloud、 Azure などのクラウド プロバイダー上やオンプレミスのインフラストラクチャ上にあるノード クラスターを管理するために使用されます。 + +ここでは、 **Minikube** という便利なツールを使って、開発およびテスト目的でローカル マシン上に Kubernetes クラスターを実行する方法を学びます。 + +:::info 本番環境の Kubernetes クラスターをお持ちの場合 +本番環境の Kubernetes クラスターに Weaviate をデプロイしたい場合も手順はほぼ同じです。 Minikube を本番環境の Kubernetes クラスターに置き換えるだけです。 + +Kubernetes デプロイメントには多くのバリエーションがあるため、ご利用のクラウド プロバイダーや Kubernetes ディストリビューションが提供するデプロイ手順に従うことをおすすめします。 +::: + +## 前提条件 + +このチュートリアルでは、次のツールが必要です。 + +- ** Minikube ** : ローカル マシン上で Kubernetes クラスターを実行するツール。ローカルで Kubernetes デプロイメントをテストするために使用します。 +- ** kubectl ** : Kubernetes のコマンドライン ツール。 Kubernetes クラスターとの対話に使用します。 +- ** Docker ** : アプリケーションをコンテナーで開発、配布、実行できるプラットフォーム。 Minikube の [*driver*](https://minikube.sigs.k8s.io/docs/drivers/) として Docker をインストールし、ローカル マシン上で Kubernetes クラスターを仮想化します。 Minikube は別のドライバーを使用してもかまいませんが、 Docker が最も一般的です。 +- ** Helm ** : Kubernetes 用のパッケージ マネージャー。 Kubernetes 上でアプリケーションをインストールおよび管理するために使用します。 + +### インストール + +これらのツールがインストールされていない場合は、以下のリンク先の手順に従ってインストールしてください。 + +- [ Minikube ](https://minikube.sigs.k8s.io/docs/start/) +- [ kubectl ](https://kubernetes.io/docs/tasks/tools/#kubectl) +- [ Docker ](https://docs.docker.com/get-docker/) +- [ Helm ](https://helm.sh/docs/intro/install/) + +インストール後、次のコマンドを実行してインストールを確認します。 + +```bash +minikube version +kubectl version --client +docker --version +helm version +``` + +次のような出力が表示されます。 + +```bash +minikube version: v1.32.0 +commit: 8220a6eb95f0a4d75f7f2d7b14cef975f050512d +Client Version: v1.28.2 +Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 +Docker version 24.0.7, build afdd53b +version.BuildInfo{Version:"v3.12.2", GitCommit:"1e210a2c8cc5117d1055bfaa5d40f51bbc2e345e", GitTreeState:"clean", GoVersion:"go1.20.6"} +``` + +同様の出力が得られれば、準備完了です。 + +表示されるバージョンは上記と異なる場合があります。最新バージョンがインストールされていることを確認してください。 + +## Minikube の実行 + +準備ができたら Minikube を起動します。以下のコマンドを実行してください。 + +```bash +minikube start +``` + +すると、次のような出力が表示される場合があります。 + +```bash +😄 minikube v1.32.0 on Darwin 14.4.1 (arm64) +✨ Automatically selected the docker driver. Other choices: vmware, ssh +📌 Using Docker Desktop driver with root privileges +👍 Starting control plane node minikube in cluster minikube +🚜 Pulling base image ... +💾 Downloading Kubernetes v1.28.3 preload ... + > preloaded-images-k8s-v18-v1...: 341.16 MiB / 341.16 MiB 100.00% 42.00 M + > gcr.io/k8s-minikube/kicbase...: 410.56 MiB / 410.58 MiB 100.00% 42.28 M +🔥 Creating docker container (CPUs=2, Memory=8100MB) ... +🐳 Preparing Kubernetes v1.28.3 on Docker 24.0.7 ... + ▪ Generating certificates and keys ... + ▪ Booting up control plane ... + ▪ Configuring RBAC rules ... +🔗 Configuring bridge CNI (Container Networking Interface) ... +🔎 Verifying Kubernetes components... + ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 +🌟 Enabled addons: storage-provisioner, default-storageclass +🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default +``` + +素晴らしいです! Minikube を使って Kubernetes クラスターを起動できました。最後のコメントに `kubectl is now configured to use "minikube" cluster and "default" namespace by default` と表示されている点に注目してください。これで `kubectl` を使用して Kubernetes クラスターと対話できます。 + +### クラスターの確認 + +次のコマンドを実行すると、 + +```bash +kubectl get pods -A +``` + +クラスター内で稼働している Pod が表示されます。例としては以下のようになります。 + +```bash +NAMESPACE NAME READY STATUS RESTARTS AGE +kube-system coredns-5dd5756b68-qhfch 1/1 Running 0 26s +kube-system etcd-minikube 1/1 Running 0 42s +kube-system kube-apiserver-minikube 1/1 Running 0 40s +kube-system kube-controller-manager-minikube 1/1 Running 0 42s +kube-system kube-proxy-xwdgf 1/1 Running 0 26s +kube-system kube-scheduler-minikube 1/1 Running 0 40s +kube-system storage-provisioner 1/1 Running 0 39s +``` + +上記と似た出力が得られれば、おめでとうございます! Minikube を使用してローカル マシン上に Kubernetes クラスターを立ち上げることに成功しました。 + +次は、 Helm を利用して Weaviate を Kubernetes クラスターにデプロイする方法を学びます。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/30_setup_weaviate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/30_setup_weaviate.mdx new file mode 100644 index 000000000..21b147a72 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/30_setup_weaviate.mdx @@ -0,0 +1,149 @@ +--- +title: Kubernetes で Weaviate を実行する +--- + +Kubernetes クラスターが用意できたので、Weaviate をデプロイできます。ここでは Helm を使って Kubernetes 上に Weaviate をデプロイする方法を説明します。 + +## Helm チャート + +前述のとおり、**Helm** は Kubernetes 用のパッケージマネージャーで、**チャート** と呼ばれるパッケージ形式を使用します。 + +**Helm チャート** とは、複数の Kubernetes リソースを記述したファイル群であり、pip や npm など他のパッケージマネージャーにおける **パッケージ** に相当します。 + +Weaviate では、Kubernetes へのデプロイに利用できる [Helm チャート](https://github.com/weaviate/weaviate-helm) を提供しています。本ガイドでは、この Helm チャートを用いて Kubernetes クラスターに Weaviate をデプロイします。 + +## デプロイ + +まず、[Weaviate Helm リポジトリ](https://weaviate.github.io/weaviate-helm) を Helm に追加します。これにより Weaviate の Helm チャートを利用できるようになります。 + +```bash +helm repo add weaviate https://weaviate.github.io/weaviate-helm +``` + +:::tip Tip: Helm リポジトリを更新する + +すでに `weaviate` Helm リポジトリを追加済みの場合、次のコマンドで最新版へ更新してください。 + +```bash +helm repo update weaviate +``` + +定期的に [Helm リポジトリを更新](https://helm.sh/docs/helm/helm_repo_update/) し、最新のチャート情報を取得することをおすすめします。 + +::: + +次に、Weaviate Helm チャート用の設定ファイル(`values.yaml`)を生成します。 + +```bash +helm show values weaviate/weaviate > values.yaml +``` + +このコマンドは Weaviate Helm チャートのデフォルト値を取得し、`values.yaml` という名前で保存します。このファイルを編集してデプロイ設定をカスタマイズできます。 + +設定できる項目は多数あります。`values.yaml` 内のインラインコメントや [公式 Weaviate ドキュメント](/weaviate/index.mdx) を参考に、必要に応じて調整してください。 + +ここではデプロイ前に重要な設定をいくつか行います。 + +## 設定 + +以下の設定を更新します。 + +- gRPC サービスを有効化 +- Cohere 連携を有効化 + +テキストエディターで `values.yaml` を開き、次のセクションを更新してください。 + +#### gRPC サービスを有効化 + +:::info デフォルト設定 +Helm チャートバージョン `17.0.0` 以降では、gRPC サービスはデフォルトで有効化されています。以前のバージョンを使用している場合は、gRPC を利用するために手動で有効化が必要です。 +::: + +サービスの `enabled` フィールドが `true`、`type` フィールドが `LoadBalancer` になっていることを確認してください。これにより gRPC サービスが外部に公開され、[gRPC API](https://weaviate.io/blog/grpc-performance-improvements) を利用できるようになります。 + +```yaml +grpcService: + enabled: true # ⬅️ Make sure this is set to true + name: weaviate-grpc + ports: + - name: grpc + protocol: TCP + port: 50051 + type: LoadBalancer # ⬅️ Set this to LoadBalancer (from NodePort) for this example +``` + +#### Cohere 連携を有効化 + +```yaml + text2vec-cohere: + + enabled: true # ⬅️ Make sure this is set to true + + # ... settings not shown ... + generative-cohere: + + enabled: true # ⬅️ Make sure this is set to true +``` + +変更を保存したら、Kubernetes クラスターに Weaviate をデプロイする準備が整いました。 + +## Weaviate を実行する + +Kubernetes クラスターが起動していること(例: `minikube start`)と、`kubectl` の接続設定が済んでいることを確認してください。 + +まず、Weaviate 用のネームスペースを作成します。 + +```bash +kubectl create namespace weaviate +``` + +これにより、[別のネームスペース](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/#when-to-use-multiple-namespaces) に Weaviate をデプロイできます。必須ではありませんが、リソースの整理がしやすくなるため推奨されます。 + +続いて、次のコマンドを実行します。 + +```bash +helm upgrade --install \ + "weaviate" \ + weaviate/weaviate \ + --namespace "weaviate" \ + --values ./values.yaml +``` + +`values.yaml` に記載した設定を用いて、Kubernetes クラスターの `weaviate` ネームスペースに Weaviate がデプロイされます。 + +次のコマンドで状態を確認してみましょう。 + +```bash +kubectl get pods -n weaviate +``` + +`weaviate` ネームスペースで Weaviate の Pod が稼働しているはずです。 + +Pod の起動には少し時間がかかる場合があります。以下のコマンドを複数回実行してステータスを確認できます。 + +```bash +❯ kubectl get pods -n weaviate +NAME READY STATUS RESTARTS AGE +weaviate-0 0/1 Pending 0 15s + +❯ kubectl get pods -n weaviate +NAME READY STATUS RESTARTS AGE +weaviate-0 1/1 Running 0 59s +``` + +上記の例では、`weaviate-0` Pod が `Pending` から `Running` へ移行していることが分かります。 + +おめでとうございます! ローカルの Kubernetes クラスターに Weaviate を正常にデプロイできました。次は、Weaviate と基本的なやり取りを確認しましょう。 + +:::tip `1.25` 以上へのアップグレード + +`1.25` 未満のバージョンから `1.25` 以上へアップグレードする場合、デプロイ済みの `StatefulSet` を削除し、Helm チャートをバージョン `17.0.0` 以上に更新してから Weaviate を再デプロイする必要があります。 + +詳細は [Kubernetes 向け 1.25 移行ガイド](/deploy/migration/weaviate-1-25.md) を参照してください。 +::: + +## 質問やフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/50_access_weaviate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/50_access_weaviate.mdx new file mode 100644 index 000000000..36b3de9a8 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/50_access_weaviate.mdx @@ -0,0 +1,176 @@ +--- +title: Weaviate へのアクセスと構成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/connect.py'; + +これで、Kubernetes クラスター内に Weaviate インスタンスを起動できました。次は何をするのでしょうか。このセクションでは、Weaviate サービスへアクセスする方法と、ニーズに合わせて構成する方法を見ていきます。 + +## Weaviate へのアクセス + +Weaviate サービスは正常に稼働していますが、まだ外部からはアクセスできません。これは、サービスを外部に公開していないためです。ここで公開処理を行いましょう。 + +### サービスの公開 + +次のコマンドを実行します。 + +```bash +minikube tunnel +``` + +Helm チャートで `weaviate` サービスを `LoadBalancer` タイプとして設定したことを思い出してください。そのため `minikube tunnel` を実行すると、サービスが外部 ― 少なくともローカルマシン ― からアクセス可能になります。 + +次のようなメッセージが表示されます。 + +```bash +✅ Tunnel successfully started + +📌 NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ... + +❗ The service/ingress weaviate requires privileged ports to be exposed: [80] +🔑 sudo permission will be asked for it. +🏃 Starting tunnel for service weaviate. +🏃 Starting tunnel for service weaviate-grpc. +``` + +ここでパスワードを求められます。入力するとトンネルが確立されます。ターミナルを閉じる、またはプロセスを停止するとトンネルも閉じ、サービスへ再びアクセスできなくなる点に注意してください。 + +:::info About `minikube tunnel` +[`minikube tunnel`](https://minikube.sigs.k8s.io/docs/handbook/accessing/#using-minikube-tunnel) はローカルマシンと Minikube クラスター間にルートを作成します。これにより、Minikube クラスター内で LoadBalancer として公開されたサービスを、開発目的でローカルマシンから利用できます。 + +ローカルマシンからサービスへアクセスする必要があるときだけトンネルを起動することを推奨します。作業が終わったら `Ctrl+C` でトンネルを停止してください。 +::: + +### アクセスの確認 + +次のコマンドを実行すると: + +```bash +kubectl get svc weaviate -n weaviate +``` + +サービスの外部 IP アドレスが表示されます。例: + +```bash +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +weaviate LoadBalancer 10.110.44.231 127.0.0.1 80:31230/TCP 61m +``` + +ブラウザで `http://:80/v1`(通常は `http://127.0.0.1:80/v1`)へアクセスしてください。Weaviate の REST ルートエンドポイントが表示され、各種エンドポイントへのリンクが確認できます。 + +また、Kubernetes 設定で gRPC サービスも開放したことを思い出してください。このサービスはポート `50051` で利用できます。次のコマンドで確認できます。 + +```bash +kubectl get svc weaviate-grpc -n weaviate +``` + +出力例: + +```bash +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +weaviate-grpc LoadBalancer 10.109.237.21 127.0.0.1 50051:32150/TCP 90m +``` + +
+ + gRPC サービスへのアクセス確認のもう一つの方法 + + +`netcat` がインストールされている場合、次のコマンドも試せます。 + +```bash +nc -zv 127.0.0.1 50051 +``` + +出力例: + +```bash +Connection to 127.0.0.1 port 50051 [tcp/*] succeeded! +``` + +多くのシステムでは `nc` がデフォルトでインストールされていません。インストールされていなくても問題ありません。`kubectl get svc` の出力で gRPC サービスへのアクセスを十分確認できます。 +
+ +### クラスターへの接続 + +外部 IP アドレスによって、クラスターへの接続方法が異なる場合があります。 + +2 つのサービスいずれも外部 IP が `127.0.0.1` の場合、Weaviate へは次のように接続します。 + + + +一方、`weaviate` と `weaviate-grpc` サービスで外部 IP が異なる場合は、次のように接続します。 + + + +ここで `WEAVIATE_SVC_EXTERNAL_IP` と `GRPC_SVC_EXTERNAL_IP` は、それぞれ `weaviate` と `weaviate-grpc` サービスの外部 IP アドレスです。 + +## Weaviate の構成 + +Kubernetes の利点の一つは、サービスを簡単に構成できる点です。Weaviate も例外ではありません。`weaviate` ディレクトリ内の `values.yaml` ファイルを更新することで Weaviate を構成できます。 + +たとえば、`text2vec-openai` や `generative-openai` などの追加モジュールを有効にするには、次のように `true` に設定します。 + +```yaml + text2vec-openai: + + enabled: true # ⬅️ Set to true + + # ... other settings not shown ... + + generative-openai: + + enabled: true # ⬅️ Set to true +``` + +また、Weaviate ポッドのリソース制限も設定できます。ここでは CPU を 30–50%、メモリを 150–300 Mi 使用するように設定してみましょう。 + +:::note リソース制限の設定箇所 +`values.yaml` には、ローカル ベクトル化モデルなど各種サービス向けに複数の `requests` と `limits` が存在します。ファイル上部(インデントなし)の Weaviate のスケールレプリカ用 `requests` と `limits` を設定してください。 +::: + +```yaml +# Scale replicas of Weaviate. ... +requests: + cpu: '300m' + memory: '150Mi' +limits: + cpu: '500m' + memory: '300Mi' +``` + +変更を適用するには、`values.yaml` を保存して次のコマンドを実行します。 + +```bash +helm upgrade --install \ + "weaviate" \ + weaviate/weaviate \ + --namespace "weaviate" \ + --values ./values.yaml +``` + +このコマンドは Weaviate をデプロイしたときと同じもので、新しい構成で Weaviate デプロイメントを更新します。 + +`values.yaml` では、認証・認可、バックアップ、モニタリング、リソース割り当てなど、他にも多数の設定が可能です。詳しくは `values.yaml` 内のインラインドキュメントと Weaviate ドキュメントを参照してください。 + +最後に、Weaviate デプロイメントを拡張し、ノードを追加する方法も確認しておきましょう。これにより、トラフィック増加や将来的な拡張に対応したり、ノード障害時の冗長性を確保したりできます。 + +次のセクションで詳しく見ていきます。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/70_multi_node.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/70_multi_node.mdx new file mode 100644 index 000000000..6a978a0f6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/70_multi_node.mdx @@ -0,0 +1,171 @@ +--- +title: マルチノードセットアップ +--- + +Minikube で Kubernetes クラスター内の単一ノードに Weaviate をデプロイしました。ここでは、それをマルチノード構成へスケールアップしてみましょう。 + +これを行うには、複数ノードを持つ Kubernetes クラスターが必要です。そのうえで、Weaviate がそれらのノードを利用できるように設定します。 + +## Weaviate クラスターにノードを追加する + +現在の Weaviate デプロイメントを停止し、[Minikube で複数ノード](https://minikube.sigs.k8s.io/docs/tutorials/multi_node/)を持つ新しいデプロイメントを行います。 + +:::note Minikube limitations +これは学習用途として同一ホストデバイス上で複数コンテナを実行します。実運用環境では、通常は複数の独立した物理または仮想ノードを持つマネージド Kubernetes クラスターを利用します。 +::: + +### 現在の Weaviate デプロイメントを停止する + +まず、`minikube tunnel` を実行していたターミナルで `Ctrl+C` を押してトンネルを停止します。 + +続いて Minikube を停止します。 + +```bash +minikube stop +``` + +既に minikube クラスターが存在しているため、マルチノードで新たに開始する前に削除する必要があります。 + +:::note Alternatively... +既存の Minikube クラスターにノードを追加することも可能です。しかし、ここではシンプルに現在のクラスターを削除して新しく開始します。 +::: + +```bash +minikube delete +``` + +### マルチノード Kubernetes クラスターを開始する + +Minikube でマルチノード Kubernetes クラスターを開始するには、次を実行します。 + +```bash +minikube start --nodes +``` + +`` をクラスター内で使用したいノード数に置き換えてください。ここでは 6 ノードのクラスターを立ち上げてみます。 + +```bash +minikube start --nodes 6 +``` + +完了したら、次を実行してノードの状態を確認できます。 + +```bash +kubectl get nodes +``` + +すると、次のような出力が得られるはずです。 + +```bash +NAME STATUS ROLES AGE VERSION +minikube Ready control-plane 78s v1.28.3 +minikube-m02 Ready 60s v1.28.3 +minikube-m03 Ready 50s v1.28.3 +minikube-m04 Ready 39s v1.28.3 +minikube-m05 Ready 29s v1.28.3 +minikube-m06 Ready 18s v1.28.3 +``` + +次に、Weaviate デプロイメントをこれらのノードで動作するよう更新します。そのために `values.yaml` ファイルの `replicas` フィールドをクラスターのノード数に合わせます。リソース要求と制限を減らした設定と合わせると、以下のようになります。 + +```yaml +replicas: 6 +updateStrategy: + type: RollingUpdate +resources: {} +requests: + cpu: '300m' + memory: '150Mi' +limits: + cpu: '500m' + memory: '300Mi' +``` + +Weaviate を再起動するには次を実行します。 + +```bash +helm upgrade --install \ + "weaviate" \ + weaviate/weaviate \ + --namespace "weaviate" \ + --values ./values.yaml +``` + +すると、クラスターの各ノードで Weaviate Pod が起動するはずです。次を実行して確認できます。 + +```bash +kubectl get pods -n weaviate +``` + +そして Pod が順番に作成されると、以下のような出力が表示されます。 + +```bash +NAME READY STATUS RESTARTS AGE +weaviate-0 1/1 Running 0 31s +weaviate-1 0/1 PodInitializing 0 9s +``` + +最終的には次のようになります。 + +```bash +NAME READY STATUS RESTARTS AGE +weaviate-0 1/1 Running 0 113s +weaviate-1 1/1 Running 0 91s +weaviate-2 1/1 Running 0 79s +weaviate-3 1/1 Running 0 57s +weaviate-4 1/1 Running 0 35s +weaviate-5 1/1 Running 0 13s +``` + +新しいターミナルを開き、以前と同様に `minikube tunnel` を実行して Weaviate サービスをローカルマシンへ公開してください。 + +## マルチノード構成の活用 + +マルチノード構成を活用する主な方法は **レプリケーション** と **水平スケーリング** の 2 つです。それぞれを見ていきましょう。 + +### レプリケーション + +レプリケーションは、同一データの複数コピーを複数ノードに作成するプロセスです。 + +これはデータ可用性と障害耐性を確保するのに有用です。マルチノード構成では、Weaviate データを複数ノードにレプリケートすることで、あるノードが障害を起こしても他ノードでデータが利用可能な状態を保てます。レプリケートされた構成は負荷を複数ノードに分散して性能を向上させたり、ダウンタイムなしのアップグレードやメンテナンスを可能にしたりします。 + +Weaviate ではデータベースコレクション定義でレプリケーションファクターを設定することでレプリケーションを扱えます。これはクラスターのノード間でデータをいくつコピーするかを Weaviate に伝えるものです。 + +コード例ではレプリケーションの設定方法を示しています。コード内に示されるポートは、ご利用環境では(例: `80` など)異なる場合があります。 + +import SchemaReplication from '/_includes/code/schema.things.create.replication.mdx'; + + + +### データベースシャーディング + +一方、シャーディングは Weaviate を水平スケールさせるために使用できます。シャーディングはデータベースをより小さな部分(シャード)に分割し、それらを複数ノードへ分散するプロセスです。 + +例えば 200 万件のレコードを保持するデータベースが、そのすべてを 1 つのノードに保存する必要はありません。代わりにレコードを小さな単位に分割し、異なるノードに保存できます。これにより、ノードを追加して水平方向にスケールさせることが可能になります。 + +### レプリケーション付きシャーディング + +シャーディングとレプリケーションを併用することで、水平スケールと障害耐性の両方を Weaviate に持たせることができます。 + +今回の 6 ノード構成では、レプリケーションファクターを 3 にし、データを 2 ノードずつにシャーディングするといった構成が考えられます。この方法では、6 ノード全体に 3 コピーのデータが分散され、障害耐性と高可用性が確保されます。 + +本番環境では、このアプローチが一般的であり、高負荷を処理し、ノード障害が起こっても可用性を維持できます。また、必要に応じてノード数を追加して水平スケールし、より多くのデータとリクエストを処理できるようにできます。 + +## クリーンアップ + +以上でガイドは終了です。マルチノード Kubernetes クラスターに Weaviate をデプロイし、レプリケーションとシャーディングについて学びました。 + +必要であれば、前述の方法で Weaviate にアクセスし、操作してみてください。[次のページでは追加のリソース](./90_next_steps.mdx) を用意していますので、ぜひご覧ください。 + +作業が完了したら、`minikube tunnel` を実行しているターミナルで `Ctrl+C` を押してトンネルを停止し、その後 Minikube を停止してクラスターを削除します。 + +```bash +minikube stop +minikube delete +``` + +## 質問やフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/90_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/90_next_steps.mdx new file mode 100644 index 000000000..d68aa4efe --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/90_next_steps.mdx @@ -0,0 +1,48 @@ +--- +title: 次のステップ +--- + +おめでとうございます。Weaviate を Kubernetes クラスターにデプロイし、マルチノード構成へスケールできました。🎉 + +これからは、Weaviate についてさらに学び、使い方を理解するために次のリソースをご覧ください。 + +Python 向けの入門コース: +- [101T: テキスト データの取り扱い](../../py/starter_text_data/index.md) +- [101V: 独自 ベクトル の取り扱い](../../py/starter_custom_vectors/index.md) +- [101T: マルチモーダル データの取り扱い](../../py/starter_multimodal_data/index.md) + +TypeScript/JavaScript 向け: +- [TypeScript で始める Weaviate 入門](/academy/js/starter_text_data) + +次のステップとしては、これらのサンプルをレプリケーションやシャーディングを用いたマルチノードのケースに適用する方法を試してみてください。 + +### 関連ドキュメント + +レプリケーションとシャーディングの基盤となるアーキテクチャに興味がある場合は、次のリソースをご覧ください: +- [レプリケーション](/weaviate/concepts/replication-architecture/index.md) +- [水平スケーリング](/weaviate/concepts/cluster.md) + +次に、[リソース計画](/weaviate/concepts/resources.md) のセクションを参照し、特定サイズの各ノードが扱えるリソース量を見積もり、クラスターを適切に計画してください。 + +レプリケーションを構成している場合、読み書き操作やクエリに [調整可能な整合性](/deploy/configuration/replication.md) の概念を適用できます。 + +### さらなる学習 + +- How-to ガイド + - - [How-to: Manage collections](/weaviate/manage-collections/index.mdx) と [How-to: Manage objects](/weaviate/manage-objects/index.mdx) では、コレクションおよびその中のオブジェクトに対する作成、読み取り、更新、削除のデータ操作方法を説明しています。 + - [How-to: search](/weaviate/search/index.mdx): すべての検索操作タイプのコード例。 + - [How-to: configure Weaviate](/weaviate/configuration/index.mdx): Weaviate の設定方法ガイド。たとえば [PQ](/weaviate/configuration/compression/pq-compression.md) と [BQ](/weaviate/configuration/compression/bq-compression.md) の圧縮、[バックアップ](/deploy/configuration/backups.md)、[レプリケーション](/deploy/configuration/replication.md) など。 +- [コンセプト ガイド](/weaviate/concepts/index.md): Weaviate のアーキテクチャと概念を理解するためのガイド。 +- [API リファレンス](/weaviate/api/index.mdx): Weaviate の API に関する詳細情報。 + +import CTASocials from '../../py/_snippets/cta_socials.mdx'; + + + +またお会いしましょう!👋 + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/_snippets/connect.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/_snippets/connect.py new file mode 100644 index 000000000..5dcf82870 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/_snippets/connect.py @@ -0,0 +1,28 @@ +# START BasicConnect +import weaviate + +client = weaviate.connect_to_local( + port=80, # The default REST port is 8080 + # grpc_port=50051 # Not needed, as the default gRPC port is 50051 +) +# END BasicConnect + +client.close() + +WEAVIATE_SVC_EXTERNAL_IP = "127.0.0.1" +GRPC_SVC_EXTERNAL_IP = "127.0.0.1" + +# START CustomConnect +import weaviate + +client = weaviate.connect_to_custom( + http_host=WEAVIATE_SVC_EXTERNAL_IP, # The external IP of the weaviate service + http_port=80, # The default REST port is 8080 + http_secure=False, # Whether to use https (secure) for the HTTP API connection + grpc_host=GRPC_SVC_EXTERNAL_IP, # The external IP of the weaviate-grpc service + grpc_port=50051, # The default gRPC port is 50051 + grpc_secure=False # Set to True if the gRPC connection is secure +) +# END CustomConnect + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/index.md new file mode 100644 index 000000000..4d0b90184 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/deployment/k8s/index.md @@ -0,0 +1,22 @@ +--- +title: "Kubernetes で Weaviate を実行する" +description: "Kubernetes を使用して Weaviate をデプロイする方法を学び、セットアップ、管理、スケーラビリティのヒントを解説します。" +sidebar_position: 100 +--- + + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## ユニット概要 + +この短いプロジェクトベースのユニットでは、コンテナーオーケストレーションプラットフォームとして人気のある Kubernetes 上で Weaviate をデプロイする方法を学びます。 + +ローカルの Kubernetes クラスターをセットアップし、その上で Weaviate インスタンスをデプロイする方法を学びます。また、Kubernetes 上で Weaviate インスタンスを設定する方法についても学びます。 + +## 学習目標 + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/index.mdx new file mode 100644 index 000000000..8e05ec957 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/index.mdx @@ -0,0 +1,20 @@ +--- +title: アカデミー - ホーム +sidebar_position: 0 +--- + +import Courses from '/src/components/Academy/courses.jsx'; +import Units from '/src/components/Academy/units.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +私たちは、 Weaviate を利用して素晴らしいものをより速く構築できるように、これらのコースを作りました。 + +----- +## コース +----- + + + +import CustomScriptLoader from '/src/components/scriptSwitch'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/10_set_up_typescript.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/10_set_up_typescript.mdx new file mode 100644 index 000000000..99eaecfb2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/10_set_up_typescript.mdx @@ -0,0 +1,76 @@ +--- +title: Weaviate 用 JavaScript / TypeScript セットアップ +sidebar_position: 10 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import WeaviateTypescriptImgUrl from './img/js-ts-weaviate.png'; + +この短いガイドでは、TypeScript / JavaScript クライアントで Weaviate を利用できるよう、セットアップ方法を説明します。 + + +Image alt + +## Node.js のインストール + +### Node.js インストール確認 + +ターミナルウィンドウ(例: bash、zsh、Windows PowerShell、Windows Terminal)を開き、次を実行します。 + +```shell +node --version # or node -v +``` + +Node.js がインストールされている場合、`v22.3.0` のような応答が表示されます。Weaviate TypeScript / JavaScript ライブラリがサポートする Node.js の最小バージョンは `v18` です。 + + +### Node.js のインストール + +インストールするには、[nodejs.org](https://nodejs.org/en/download/package-manager) にあるシステム別の手順に従ってください。 + +Node.js のインストール後、再度バージョンを確認し、推奨バージョンが入っていることを確かめましょう。 + +:::tip Advanced option: `nvm` +Python をインストールするもう一つの良い方法は `nvm` をインストールすることです。これにより、システム上で複数バージョンの Node.js を管理できます。`nvm` のインストール方法は [こちら](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating) を参照してください。 +::: + + +### (任意) TypeScript のセットアップ + +インストール方法は [typescriptlang.org](https://www.typescriptlang.org/download/) にあるシステム別ガイドをご覧ください。インストール後、Weaviate クライアントで TypeScript を利用するための設定方法は [こちら](../../weaviate/client-libraries/typescript/index.mdx) に記載されています。 + +これで TypeScript を Weaviate クライアントと一緒に使用する準備ができました。 + +## Weaviate クライアントのインストール + +次に、[Weaviate クライアントライブラリ](../../weaviate/client-libraries/index.mdx) をインストールします。これにより、TypeScript で Weaviate とやり取りするのが格段に簡単になります。 + +プロジェクト用の新しいフォルダーで、次を実行して Weaviate クライアントをインストールします。 + +```shell +npm install weaviate-client +``` + +### インストール確認 + +Weaviate クライアントがインストールされているか確認するには、ターミナルで次を実行してください。 + +```shell +npm view weaviate-client +``` + +以下のような出力が得られます。 + +```text +3.1.4. +``` + +これで Weaviate TypeScript / JavaScript クライアントライブラリを使用するための準備が完了しました。おめでとうございます! + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_category_.json new file mode 100644 index 000000000..8e708216c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "JavaScript/TypeScript", + "position": 20 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/cta_socials.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/cta_socials.mdx new file mode 100644 index 000000000..63a2c4304 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/cta_socials.mdx @@ -0,0 +1,3 @@ +## 最新情報の入手 + +ドキュメントは常に改善を続けています。最新のリソースやアップデートを受け取るには、 [newsletter](https://newsletter.weaviate.io/) に登録するか、ソーシャルメディア( [Twitter](https://x.com/weaviate_io)、 [LinkedIn](https://www.linkedin.com/company/weaviate-io/) )でフォローしてください。 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/intro_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/intro_next_steps.mdx new file mode 100644 index 000000000..f2832e140 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/intro_next_steps.mdx @@ -0,0 +1,32 @@ +おめでとうございます! Weaviate の入門コースを修了しました。 + +このコースを終えた今は、より高度なコースに向けて、私たちのドキュメントや Academy をご覧いただくことをお勧めします。 + +私たちの人気リソースの一部をご紹介します。 + +### ドキュメント + +- How-to ガイド + - [How-to: コレクションの管理](/weaviate/manage-collections/index.mdx) と [How-to: オブジェクトの管理](/weaviate/manage-objects/index.mdx) のガイドでは、コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除などのデータ操作方法を説明します。 + - [How-to: 検索](/weaviate/search/index.mdx): すべての検索操作に関するコード例をご覧いただけます。 + - [How-to: Weaviate の設定](/weaviate/configuration/index.mdx): [ PQ ](/weaviate/configuration/compression/pq-compression.md) や [ BQ ](/weaviate/configuration/compression/bq-compression.md) の圧縮、[バックアップ](/deploy/configuration/backups.md)、[レプリケーション](/deploy/configuration/replication.md) など、 Weaviate を設定するためのガイドです。 +- [コンセプトガイド](/weaviate/concepts/index.md): Weaviate のアーキテクチャと概念を理解するためのガイドです。 +- [ API リファレンス](/weaviate/api/index.mdx): Weaviate の API についての詳細情報です。 + +### Academy + +- [Named ベクトル](/academy/py/named_vectors): Named ベクトル を使用して、 Weaviate でデータを柔軟に表現する方法を学びます。 +- [どの検索が自分に合っているか?](/academy/py/standalone/which_search): Weaviate にはさまざまな検索方法があります。それぞれの用途と使い分けを学びます。 +- [チャンク化](/academy/py/standalone/chunking): 長いドキュメントの検索を最適化するためにチャンク化を利用する方法を学びます。 + +import CTASocials from './cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/intro_next_steps_js.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/intro_next_steps_js.mdx new file mode 100644 index 000000000..a5736e074 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/_snippets/intro_next_steps_js.mdx @@ -0,0 +1,32 @@ +おめでとうございます!この Weaviate 入門コースを修了しました。 + +本コースを完了された今、より高度なコースとして当社のドキュメントや Academy をぜひご覧ください。 + +特に人気のリソースは次のとおりです。 + +### ドキュメント + +- How-to ガイド + - [How-to: コレクションを管理する](/weaviate/manage-collections/index.mdx) と [How-to: オブジェクトを管理する](/weaviate/manage-objects/index.mdx) ガイドでは、データ操作 (つまり、コレクションおよびその内部のオブジェクトの作成・読み取り・更新・削除) の方法を紹介しています。 + - [How-to: 検索](/weaviate/search/index.mdx):すべての種類の検索操作に関するコード例。 + - [How-to: Weaviate を設定する](/weaviate/configuration/index.mdx): Weaviate の設定方法に関するガイド。例として、[PQ](/weaviate/configuration/compression/pq-compression.md) と [BQ](/weaviate/configuration/compression/bq-compression.md) の圧縮、[バックアップ](/deploy/configuration/backups.md)、[レプリケーション](/deploy/configuration/replication.md) などがあります。 +- [概念ガイド](/weaviate/concepts/index.md): Weaviate のアーキテクチャと概念を理解するためのガイド。 +- [API リファレンス](/weaviate/api/index.mdx): Weaviate の API に関する詳細情報。 + +### アカデミー + +- [テキストを扱う](/academy/js/starter_text_data): Weaviate でテキストデータを扱う方法を学びます。 +- [どの検索が自分に適しているか?](/academy/js/standalone/which-search): Weaviate のさまざまな検索タイプとその利用シーンを学びます。 + + +import CTASocials from './cta_socials.mdx'; + + + +またお会いしましょう!👋 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/img/js-ts-weaviate.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/img/js-ts-weaviate.png new file mode 100644 index 000000000..164f3d8e5 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/img/js-ts-weaviate.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/_want-stack/_snippets/index.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/_want-stack/_snippets/index.ts new file mode 100644 index 000000000..e69de29bb diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/_want-stack/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/_want-stack/index.md new file mode 100644 index 000000000..a794f1217 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/_want-stack/index.md @@ -0,0 +1,60 @@ +--- +title: WANT スタックとは +sidebar_position: 10 +--- + +## WANT とは + +### WANT とは + + Weaviate、 AI、 Next.js、 TypeScript。 + + WANT スタックは、 AI ネイティブアプリケーションを構築するプロセスを簡素化するテクノロジーの集合体です。 + + +#### Weaviate + + Weaviate は ベクトル データベースで、次の利点を提供します +- ベクトル検索 +- 動的な生成モデルの選択(行き詰まらない) + +#### AI + + AI は WANT の中心にあり、 Weaviate の柔軟性と膨大な統合機能を活用して、埋め込みから生成モデル、リランカーやレコメンダーまでアプリケーションに AI を組み込めます。特定の技術に縛られることなく、最大限の柔軟性を提供することが目的です。 + +#### Next.js (または Nuxt.js) + + 最新の Web 開発フレームワークを提供します。 + +#### TypeScript + + TypeScript … コンテンツを追加してください。 + + + +### WANT アプリケーションの構築 + +- リソース +- スターターテンプレート +- 学習 + +[Embed Youtube Course] + +ベクトル検索は多用途で、複数のデータモダリティ(例: テキスト、画像、音声など)や複数言語を横断した検索にも利用できます。 + + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/10_why-client-server.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/10_why-client-server.mdx new file mode 100644 index 000000000..8aecde9d8 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/10_why-client-server.mdx @@ -0,0 +1,36 @@ +--- +title: クライアントサーバーアプリケーションとは +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import WeaviateTypescriptImgUrl from '/docs/academy/js/standalone/client-server/_img/architecture.jpg'; + + + +### クライアントサーバーアプリケーションとは + +クライアントサーバーアプリケーションとは、クライアントデバイス上で動作しながらリモートサーバーから情報を取得するアプリケーションです。 + +Weaviate を用いたアプリケーション構築では、クライアントアプリケーションから直接データベースへアクセスするのではなく、すべてのやり取りを仲介するサーバーを設けます。 + +Image alt + +本セクションでは、Weaviate Typescript v3 クライアントである [weaviate-client](https://www.npmjs.com/package/weaviate-client) を使用してアプリケーションを構築する方法を解説します。 + + + +### クライアントサーバーアプリケーションでの weaviate-client の使用 + +v3 クライアントは gRPC を使用してお客様の Weaviate インスタンスに接続します。クライアントは Node.js を用いたサーバーサイド開発をサポートしており、ブラウザベースの Web クライアント開発には対応していません。 + +クライアントのインストール手順は [こちら](../../../../weaviate/client-libraries/typescript/index.mdx#installation) をご覧ください。新しい v3 クライアントを使用する大きな利点は、gRPC プロトコルの導入です。gRPC は大規模なデータベース操作を高速かつ信頼性高く処理できます。ただし、gRPC はブラウザベースのクライアント開発をサポートしていません。 + +[weaviate-client](../../../../weaviate/client-libraries/typescript/index.mdx) を実行するための要件に加え、クライアントサーバーアーキテクチャはクライアントから直接やり取りする場合よりも安全性が高いというメリットがあります。 + +クライアントサーバー方式を採用することで、ロードバランシング、ユーザーおよびセッション管理、ミドルウェアの導入など、さまざまな最適化を行いながら Weaviate を活用できます。 + +次のセクションでは、クライアントサーバーアプリケーションの構築方法を紹介します。 +- [バックエンド Web フレームワークの使用](./20_building-client-server.mdx) +- [フルスタック Web フレームワークの使用](./30_fullstack.mdx) \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/20_building-client-server.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/20_building-client-server.mdx new file mode 100644 index 000000000..87ee7e0f5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/20_building-client-server.mdx @@ -0,0 +1,130 @@ +--- +title: バックエンド Web フレームワークの利用 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!./_snippets/20_backend.js'; +import ClientCode from '!!raw-loader!./_snippets/index.html'; +import WeaviateTypescriptImgUrl from '/docs/academy/js/standalone/client-server/_img/backend.jpg'; + + + +このアプローチでは、ツールを 2 つに分けます。1 つはサーバーアプリケーションを構築するためのバックエンドフレームワーク、もう 1 つはクライアントアプリケーションを構築するためのツールです。ここではバックエンドサーバーを構築するために Express.js を、クライアントとして Thunder Client を使用してバックエンドサーバーへ API コールを行います。 + +Image alt + + +## サーバーの構築 + +このサーバーには、`searchTerm` をクエリパラメーターとして受け取る 1 つのルートを用意します。 + +### 1. Node.js アプリケーションの初期化 + +新しいディレクトリで次のコマンドを実行し、 Node.js プロジェクトを初期化して Express を使ったサーバーを構築します。 + +```bash +npm init +``` +### 2. プロジェクト依存関係のインストール + +プロジェクトを初期化したら、環境変数を管理するための `dotenv`、サーバーを構築するための `express`、そして Weaviate データベースとの通信を行う `weaviate-client` をインストールします。 + +```bash +npm install express dotenv weaviate-client +``` + + +### 3. Weaviate データベースのセットアップ + +まず [Weaviate Cloud](https://console.weaviate.cloud/) で無料のサンドボックスアカウントを作成します。サンドボックスプロジェクトのセットアップで問題がある場合は、[こちらのガイド](/cloud/manage-clusters/connect) を参照してください。 + +Weaviate クラスターの URL と API キーが必要です。まだお持ちでない場合は、Cohere の [API キー](https://dashboard.cohere.com/api-keys) を新規作成してください。Cohere を私たちの埋め込みモデルとして使用します。準備ができたら、これら 3 つを `.env` ファイルに追加します。 + + + + + + +#### 3.5 Weaviate へのデータ追加 + +[データのロード](https://github.com/weaviate/recipes-ts/blob/main/similarity-search/cohere/load.ts) レシピに従って、 Weaviate データベースへデータをインポートしてください。 + +### 4. Weaviate への接続 + +`config/weaviate.js` に次のコードを貼り付けます。 + + + + + +上記のコードにより、 Weaviate Cloud 上にホストされている Weaviate インスタンスへの接続が作成されます。 + +### 5. Search ルートの作成 + +プロジェクトルートに `app.js` ファイルを作成し、次のコードを貼り付けます。 + + + + + +これで `/search` ルートで検索を実行できます。`nearText()` を使用してセマンティック検索を行います。 + +#### 6. サーバーの実行 +ターミナルで次のコマンドを実行してサーバーを起動します。 + +```bash +node app.js +``` + +サーバーは `localhost:3005` で稼働しているはずです。 + + + +## クライアントアプリケーションの構築 + +サーバーが完成したので、クライアントアプリケーションから呼び出しを行えます。ここでは HTML と JavaScript で基本的なクライアントアプリケーションを作成します。 + +または [Thunder Client](https://www.thunderclient.com/) で `http://localhost:3005/search?searchTerm=countries in asia` にリクエストを送ってサーバーをクエリすることもできます。 + + +### 1. クライアントアプリケーションの作成 + +ルートフォルダーに `index.html` ファイルを作成し、次のコードを貼り付けます。 + + + + + + +### 2. クライアントアプリケーションの実行 + +ルートフォルダーでターミナルから次のコマンドを実行します。 + +```bash +npx http-server +``` + + +このクライアントアプリケーションは、先ほど構築した Express サーバーにリクエストを送り、結果を表示します。 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/30_fullstack.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/30_fullstack.mdx new file mode 100644 index 000000000..fb3b1c40b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/30_fullstack.mdx @@ -0,0 +1,129 @@ +--- +title: フルスタック Web フレームワークの使用 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import WeaviateTypescriptImgUrl from '/docs/academy/js/standalone/client-server/_img/fullstack.jpg'; +import TSCode from '!!raw-loader!./_snippets/20_backend.js'; + +このアプローチでは、サーバーアプリケーションとクライアントアプリケーションの両方を 1 つのツールで構築します。現代の Web 開発の用語では、このようなツールをフルスタック Web フレームワークと呼びます。この例では Next.js を使用します。 + +Image alt + +## Next.js での開発 + +### 1. Next.js アプリケーションの作成 + +Next.js で新しいアプリケーションを作成するには、ターミナルで次のコマンドを実行します。 + +```bash +create-next-app –ts –app +``` +### 2. プロジェクト依存関係のインストール + +プロジェクトが初期化できたら、`weaviate-client` をインストールして Weaviate データベースとの通信を管理します。 + +```bash +npm install weaviate-client +``` + +### 3. Weaviate データベースのセットアップ + +まず、Weaviate Cloud で無料のサンドボックスアカウントを作成します。サンドボックスプロジェクトのセットアップに問題がある場合は、[こちらのガイド](/cloud/manage-clusters/connect)を参照してください。 + +Weaviate クラスターの URL と API キーが必要です。まだお持ちでない場合は、新しい Cohere API キーを作成してください。当社は Cohere を埋め込みモデルとして使用しています。準備ができたら、これら 3 つを `.env` ファイルに追加します。 + + + + + +#### 3.5 Weaviate へのデータ追加 + +Weaviate にデータをインポートするには、[ロードレシピ](https://github.com/weaviate/recipes-ts/blob/main/similarity-search/cohere/load.ts)を参照してください。 + +### 4. Weaviate の初期化 + +`utils/weaviate.ts` にファイルを作成し、次のコードを貼り付けます。このコードは、Weaviate Cloud 上にホストされている Weaviate インスタンスへの接続を作成するのに役立ちます。 + +```ts +import weaviate from "weaviate-client"; + +const client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL as string,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-Cohere-Api-Key': process.env.COHERE_API_KEY as string + } + }, +); +``` + +### 4. 検索サーバーアクションの作成 + +次に、`./utils/action.ts` に次のコードを貼り付けます。これにより、アプリケーションの他の部分から `vectorSearch()` 関数を呼び出すことで、`nearText()` を使ったセマンティック検索を実行できます。 + +```ts +"use server"; + +import { connectToDB } from './weaviate.ts' + +export async function vectorSearch(searchTerm: string) { + + const myCollection = client.collections.use('MyCollectionName'); + + const response = await myCollection.query.nearText(searchTerm, { + limit: 8, + returnMetadata: ['distance'], + }) + + return response + } +``` + +### 5. クライアントアプリケーションでサーバーからデータを取得する + +`./app` フォルダーの `page.tsx` に次のコードを貼り付けます。クライアント側で検索を実行し、結果を Web ページに表示します。 + +```tsx + +import { vectorSearch } from '@/utils/action.ts'; + +export default async function Home() { + const search = "water sports i can win a medal in" + const data = await vectorSearch(search); + + return ( + + +

+ { data } +

+ + + ) + +} + +``` +#### 6. フルスタックアプリの実行 + +ターミナルで次のコマンドを実行してアプリケーションを起動します。 + +```bash +npm run dev +``` + +アプリケーションは `localhost:3000` で実行されているはずです。 + +## その他のフレームワーク + +本ガイドでは Next.js のみを詳しく説明しましたが、Nuxt、Solid、Angular など、さまざまなフルスタックフレームワークを使用して Weaviate と連携した開発が可能です。 + +試していただける[スターター](https://github.com/topics/weaviate-starter)アプリケーションの一覧も用意しています。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/architecture.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/architecture.jpg new file mode 100644 index 000000000..9a8ddb7cf Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/architecture.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/backend.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/backend.jpg new file mode 100644 index 000000000..c5fe962ce Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/backend.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/fullstack.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/fullstack.jpg new file mode 100644 index 000000000..417f0d518 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_img/fullstack.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/20_backend.js b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/20_backend.js new file mode 100644 index 000000000..fdac27ebb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/20_backend.js @@ -0,0 +1,62 @@ +// START weaviate.js +import weaviate from 'weaviate-client' +import 'dotenv/config'; + +export const connectToDB = async () => { + try { + const client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY), + headers: { + 'X-Cohere-Api-Key': process.env.COHERE_API_KEY || '', + } + } + ) + console.log(`We are connected! ${await client.isReady()}`); + return client + } catch (error) { + console.error(`Error: ${error.message}`); + process.exit(1); + } +}; + +// END weaviate.js +const dotEnv = ``` +// START .env +COHERE_API_KEY= +WEAVIATE_URL= +WEAVIATE_API_KEY= +// END .env +``` + +// START app.js +import express from 'express'; +import { connectToDB } from './config/weaviate.js'; + +const app = express(); +const port = 3005 + +const client = await connectToDB(); + +app.get('/', async function(req, res, next) { + var searchTerm = req.query.searchTerm; + + const wikipedia = client.collections.use("Wikipedia") + + try { + const response = await wikipedia.query.nearText(searchTerm, { + limit: 3 + }) + + res.send(response.objects) + } catch (error) { + console.error(`Error: ${error.message}`); + } + }) + +app.listen(port, () => { + console.log(`App listening on port ${port}`) +}) + + + +// END app.js diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/30_fullstack.js b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/30_fullstack.js new file mode 100644 index 000000000..2458d472a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/30_fullstack.js @@ -0,0 +1,67 @@ +// START weaviate.js + +import weaviate from 'weaviate-client' +import 'dotenv/config'; + +export const connectToDB = async () => { + try { + const client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY), + headers: { + 'X-Cohere-Api-Key': process.env.COHERE_API_KEY || '', + } + } + ) + console.log(`We are connected! ${await client.isReady()}`); + return client + } catch (error) { + console.error(`Error: ${error.message}`); + process.exit(1); + } +}; + +// END weaviate.js + +// .env +` +COHERE_API_KEY= +WEAVIATE_URL= +WEAVIATE_API_KEY= +` +// END .env + + +// START app.js +import express from 'express'; +import { connectToDB } from './config/weaviate.js'; + +const app = express(); +const port = 3005 + +const client = await connectToDB(); + + + +app.get('/', async function(req, res, next) { + var searchTerm = req.query.searchTerm; + + const wikipedia = client.collections.use("Wikipedia") + + try { + const response = await wikipedia.query.nearText(searchTerm, { + limit: 5 + }) + + res.send(response.objects) + } catch (error) { + console.error(`Error: ${error.message}`); + } + }) + +app.listen(port, () => { + console.log(`App listening on port ${port}`) +}) + + + +// END app.js diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/index.html b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/index.html new file mode 100644 index 000000000..0819a2dfe --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/_snippets/index.html @@ -0,0 +1,83 @@ + + + + + Weaviate Search Client + + + +
+

Semantic Search Results

+ +
Loading...
+
+
+
+ + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/index.md new file mode 100644 index 000000000..fb3c257c1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/client-server/index.md @@ -0,0 +1,44 @@ +--- +title: クライアント-サーバー アプリケーションの構築 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; + + +## 概要 + +JavaScript で Weaviate を使用し、[weaviate-client](https://www.npmjs.com/package/weaviate-client) を利用して Web アプリケーションを構築する場合は、クライアント-サーバー アーキテクチャを採用することを推奨します。 + +使用する開発ツールによって、この推奨事項は変わる場合があります。 + +Next.js のようなフルスタック フレームワークは、サーバーサイド開発や Weaviate と通信するための API 作成をサポートしています。これは REST 呼び出し、または Next.js では Server 関数を通じて実現されます。このアプローチではクライアント アプリケーションとサーバー アプリケーションが密に結合されます。 + +Express などのバックエンド Web フレームワークを使用すると、Weaviate と通信するための API を作成できます。クライアント アプリケーションはこの API を REST 呼び出しで利用します。この方法ではクライアント アプリケーションとサーバー アプリケーションを完全に分離できます。 + + +### 前提条件 + +- `weaviate-client` がインストールされた Node.js 環境 +- Weaviate の検索機能に関する知識 +- JavaScript でモダンな Web アプリケーションを構築した経験 +- 中級程度のコーディングスキル (例: JavaScript) + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/index.md new file mode 100644 index 000000000..dcf277770 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/index.md @@ -0,0 +1,16 @@ +--- +title: 短いユニット +sidebar_position: 900 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## 概要 + +このセクションには、短く独立したユニットが含まれており、他のトピックとは関係なく読むことができます。 + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/10_embedding.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/10_embedding.mdx new file mode 100644 index 000000000..cc26ca1ff --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/10_embedding.mdx @@ -0,0 +1,137 @@ +--- +title: Weaviate における Embedding モデルの利用 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!./_snippets/10_embedding.ts'; +import EmbeddingModelImage from '/docs/academy/js/standalone/using-ml-models/_img/embedding-models.jpg'; +import Unimodal from '/docs/academy/js/standalone/using-ml-models/_img/unimodal.jpg'; +import Multimodal from '/docs/academy/js/standalone/using-ml-models/_img/multimodal.jpg'; + + +## Embedding モデル + +Embedding モデルとは、情報を数値の配列――しばしば ベクトル 埋め込みと呼ばれるもの――として表現するように学習された機械学習モデルです。 ベクトル または ベクトル 埋め込みは、データの特定の属性や特徴を表す数値表現であり、この表現を用いることで ベクトル 空間内のオブジェクトを効率よく検索できます。 + +Image alt + + +## Embedding モデルの利用シーン + +Embedding は、現代の検索および Retrieval-Augmented Generation (RAG) アプリケーションを支える屋台骨です。主に次の用途に適しています。 + +- **検索:** 検索結果は、入力クエリの ベクトル からの距離でランキングされます。 +- **分類:** オブジェクトは、その ベクトル 表現が最も近いカテゴリーに分類されます。 +- **レコメンデーション:** 類似した ベクトル 表現を持つアイテムがユーザーに推薦されます。 + + +## Embedding モデルの応用 + +Embedding モデルは、ほとんどの機械学習モデルと同様に、1 つまたは複数のモダリティに限定されます。 + +ここでモダリティとは、モデルが入力として処理できる、または出力として扱えるデータの種類を指します。Embedding モデルは大きく分けてユニモーダルとマルチモーダルの 2 つに分類されます。 + + +- **ユニモーダル Embedding:** 単一のモダリティを多次元 ベクトル 空間で表現します。例としては、Cohere のテキスト埋め込みモデル embed-multilingual-v3.0 や Twelve Labs の動画埋め込みモデル marengo 2.7 があります。 + +Image alt + + +- **マルチモーダル Embedding:** 複数モダリティを多次元空間で表現し、クロスモーダル検索やクラスタリングを可能にします。 [CLIP](https://openai.com/index/clip/) は、テキスト・音声・動画データの埋め込みを生成できる代表的なマルチモーダルモデルです。 + +Image alt + + + +## Weaviate での Embedding モデル利用 + +Weaviate は、Embedding の生成と管理に関する複雑さを大幅に軽減します。Weaviate は多彩な ベクトライザー モデルや ベクトライザー サービスプロバイダーをサポートし、独自に ベクトル を指定することも可能です。 + +Weaviate では、 ベクトル 埋め込みがハイブリッド検索とセマンティック検索の駆動力となります。 + +ここでは、Weaviate で Embedding モデルを設定し、セマンティック検索を実行する手順を説明します。まずは [Weaviate Cloud](https://console.weaviate.cloud/) で無料のサンドボックスアカウントを作成します。セットアップに問題がある場合は、[こちらのガイド](/cloud/manage-clusters/connect) を参照してください。 + +### Step 1: Weaviate インスタンスへ接続 + + + + + +Weaviate への接続を初期化し、サードパーティの Embedding モデルにアクセスするために必要な環境変数を設定します。 + +### Step 2: コレクションと Embedding モデルの定義 + + + + + +コレクションを作成するときに、使用する Embedding モデルを定義します。この例では、 `text2vecCohere()` モジュールを用いて Cohere のテキスト埋め込みモデル embed-multilingual-v3.0 を利用し、データの ベクトル 埋め込みを生成します。 + + +### Step 3: データのインポート + + + + + +コレクションが作成できたら、データをインポートします。インポート時に、定義済みの Embedding モデルと連携します。Weaviate の ベクトライザー は、コレクション作成時に指定した Embedding モデルへオブジェクトを送信します。処理が完了すると、データオブジェクトと対応する ベクトル 表現が ベクトル データベースに保存され、セマンティック検索クエリを実行できるようになります。 + + +### Step 4: セマンティック検索の実行 + + + + + + +ここではクエリを実行し、 `return` を true に設定してレスポンスにオブジェクトの ベクトル を含めています。検索の詳細は [こちら](/weaviate/concepts/search) をご覧ください。 + + + + +## 追加学習 + +### ベクトル表現 +ベクトル表現は、Embedding モデルの基本的な出力です。複雑なデータ (テキスト、画像など) を、意味を捉えた固定長の数値配列へと変換します。 + +- **次元数** : 通常はモデルによって 384 から 1536 次元の範囲です。次元数が大きいほど精度は向上しますが、生成されるベクトルのメモリ使用量も増加します。 +- **フォーマット** : ベクトルは一般的に浮動小数点数で構成され、特定の範囲に正規化されています。 + +### 距離メトリクス + +[距離メトリクス](/weaviate/config-refs/distances) はベクトル埋め込み間の類似度を定量化します。Weaviate は、意味的な類似度を測るためのデフォルトの距離メトリクスとして **[コサイン類似度](https://weaviate.io/blog/distance-metrics-in-vector-search#cosine-similarity)** を使用します。 + + + + +Embedding モデルは性能や能力がさまざまです。複数のモデルを比較して選択する際のポイントを把握するために、[この記事をお読みください](https://weaviate.io/blog/how-to-choose-an-embedding-model)。 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/20_generative.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/20_generative.mdx new file mode 100644 index 000000000..00a901363 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/20_generative.mdx @@ -0,0 +1,138 @@ +--- +title: Weaviate における生成モデルの利用 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!./_snippets/20_generative.ts'; +import WeaviateTypescriptImgUrl from '/docs/academy/js/standalone/using-ml-models/_img/generative.jpg'; +import Unimodal from '/docs/academy/js/standalone/using-ml-models/_img/unimodal-gen.jpg'; +import Multimodal from '/docs/academy/js/standalone/using-ml-models/_img/multimodal-gen.jpg'; + + +## 生成モデルの概要 + +生成モデルとは、プロンプトを受け取ると、その指示に従ってテキスト・画像などのオリジナル データを生成できる機械学習モデルです。生成されるデータは学習時のデータに由来しますが、単純にそのまま模倣するわけではありません。 + +Image alt + +生成モデルにはさまざまなタイプがありますが、ここでは特に大規模言語モデル (LLM) に焦点を当てます。 + +## 生成モデルを使うタイミング + +生成モデルは、検索拡張生成 (RAG) や エージェント 指向のワークフローで脚光を浴びています。主な用途は以下のとおりです。 + +- **翻訳:** モデルはゼロショットで高精度に異なる言語へ翻訳できます。 +- **コード生成:** 高レベルな instructions を受け取り、機能するカスタム コードへ変換できます。 +- **画像生成:** プロンプトに含まれるテキスト指示から、高品質な画像を安定して生成できます。 + + +## 生成モデルの応用 + +Anthropic の [Claude](https://www.anthropic.com/claude) ファミリーや Google の [Gemini](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference) などの LLM は、テキスト データに特化した生成モデルです。ほとんどの機械学習モデルと同様に、これらのモデルも 1 種類以上のモダリティに限定されます。 + +モダリティとは、モデルが処理・入出力できるデータの種類を指します。生成モデルは一般的に以下の 2 つに分類されます。 + +- **ユニモーダル生成:** LLM の文脈で言えば、入力も出力も 1 つのモダリティ (通常はテキスト) に限定される生成能力です。 + +Image alt + +- **マルチモーダル生成:** LLM の文脈で言えば、複数のモダリティで入力・出力を扱える生成能力です。テキスト入力から画像生成、あるいは画像入力から音声生成など、さまざまな組み合わせが可能です。 + +Image alt + + +### Weaviate での生成モデル利用 + +Weaviate は多くの生成モデルおよびプロバイダーをサポートしており、必要に応じて独自モデルを組み込むこともできます。 + +Weaviate では、生成モデルが RAG (生成検索) を支えています。ここでは Weaviate で生成モデルを使用する流れを順に見ていきます。まずは [Weaviate Cloud](https://console.weaviate.cloud/) で無料のサンドボックス アカウントを作成しましょう。セットアップがうまくいかない場合は、[こちらのガイド](/cloud/manage-clusters/connect) を参照してください。 + +## ステップ 1: Weaviate インスタンスへの接続 + + + + + +まず Weaviate への接続を初期化し、サードパーティの生成モデルへアクセスするために必要な環境変数を設定します。 + +## ステップ 2: コレクションと生成モデルの定義 + + + + + +コレクションを作成するときに、使用する生成モデルを指定します。この例では、Cohere のテキスト生成モデルを利用して新しいデータを生成します。デフォルトでは **command-r** です。 + +## ステップ 3: データのインポート + + + + + +コレクションの作成後、データをインポートします。インポート時にベクトライザーが動作し、コレクション作成時に指定した埋め込みモデルにオブジェクトを送信します。その結果、データ オブジェクトと対応するベクトル表現が ベクトル データベース に保存され、セマンティック検索や RAG が可能になります。 + +## ステップ 4: シングルタスク生成検索の実行 + + + + + +ここでは `singlePrompt` を使用し、セマンティック検索で取得した件数 `n` 分だけ言語モデルへリクエストします。`limit` を設定することで取得件数を厳密に制御できます。各検索結果から取得した値は `{ answer }` の形式でプロンプトに埋め込めます。たとえば、検索結果の `answer` プロパティをフランス語に翻訳したい場合などに便利です。 + +## ステップ 5: グループ化生成検索の実行 + + + + + +ここでは `groupedTask` プロンプト形式を使用し、検索結果をまとめて言語モデルへコンテキストとして渡します。`groupedProperties` で `answer` プロパティのみを指定しているため、モデルの出力に影響を与える情報を細かく制御できます。 +## 追加学習 +### プロンプト エンジニアリング & アウトプット 制御 +プロンプト エンジニアリングとは、AI モデルに与える入力、すなわち「プロンプト」を洗練し、望ましい、またはより効果的な出力を得るための技術です。これには.. + +- **明確な指示:** 具体的かつ明示的に依頼することで、AI がニーズを正確に理解しやすくなります。「これを分析して」ではなく、「主要なテーマと裏付けとなる証拠を詳細に分析してください」のように依頼しましょう。 + + +### コンテキスト ウィンドウ +コンテキスト ウィンドウとは、AI モデルが一度に「見て」処理できる情報量を表します。会話ごとにおけるモデルの作業メモリのようなものです。 + +- **トークン制限:** コンテキスト ウィンドウはトークン数(英語でおおよそ 3/4 語に相当)で測定されます。モデルによって数千から数十万トークンまで上限が異なります。 + +コンテキスト ウィンドウの管理とプロンプト エンジニアリングの双方は、RAG 実装を洗練し始めるための優れた方法です。 + +生成モデルの性能と能力には大きな幅があります。Weaviate で利用できるオプションを把握するには、[統合ページを閲覧する](/weaviate/model-providers) をご覧ください。 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/embedding-models.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/embedding-models.jpg new file mode 100644 index 000000000..d81264c35 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/embedding-models.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/generative.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/generative.jpg new file mode 100644 index 000000000..d3696882e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/generative.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/multimodal-gen.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/multimodal-gen.jpg new file mode 100644 index 000000000..f23f1917d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/multimodal-gen.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/multimodal.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/multimodal.jpg new file mode 100644 index 000000000..c9c0af6b2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/multimodal.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/unimodal-gen.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/unimodal-gen.jpg new file mode 100644 index 000000000..11626ef27 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/unimodal-gen.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/unimodal.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/unimodal.jpg new file mode 100644 index 000000000..195c9dc49 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_img/unimodal.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_snippets/10_embedding.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_snippets/10_embedding.ts new file mode 100644 index 000000000..eb6bd425a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_snippets/10_embedding.ts @@ -0,0 +1,71 @@ +// START Connect +import weaviate, { WeaviateClient, configure } from 'weaviate-client' + +// END Connect +import 'dotenv/config' + +// START Connect +const weaviateURL = process.env.WEAVIATE_URL as string +const weaviateKey = process.env.WEAVIATE_API_KEY as string +const cohereKey = process.env.COHERE_API_KEY as string + +// Connect to your Weaviate instance +const client: WeaviateClient = await weaviate.connectToWeaviateCloud(weaviateURL,{ + authCredentials: new weaviate.ApiKey(weaviateKey), + headers: { + 'X-Cohere-Api-Key': cohereKey, // Replace with your inference API key + } + } +) +// END Connect + // Delete the "JeopardyQuestion" collection if it exists + await client.collections.delete('JeopardyQuestion'); + + if (await client.collections.exists('JeopardyQuestion') == false) { + + // Create a collection with both a vectorizer and generative model +// START Collection +await client.collections.create({ + name: 'JeopardyQuestion', + properties: [ + { name: 'Category', dataType: configure.dataType.TEXT }, + { name: 'Question', dataType: configure.dataType.TEXT }, + { name: 'Answer', dataType: configure.dataType.TEXT} + ], + // Define your Cohere vectorizer and generative model + vectorizers: weaviate.configure.vectors.text2VecCohere({ + sourceProperties: ["Question", "Answer"] + }), +}); +// END Collection + + } + + try { +// START Importing +let jeopardyCollection = client.collections.use('JeopardyQuestion'); +// Download data to import into the "JeopardyQuestion" collection +const url = 'https://raw.githubusercontent.com/weaviate/weaviate-examples/main/jeopardy_small_dataset/jeopardy_tiny.json' +const response = await fetch(url); +const jeopardyQuestions = await response.json(); + +// Bulk insert downloaded data into the "JeopardyQuestion" collection +await jeopardyCollection.data.insertMany(jeopardyQuestions.data) +// END Importing + console.log('Data Imported'); + } catch (e) { + console.error(e); + } +// START Search +const jeopardyCollection = client.collections.use('JeopardyQuestion'); + +const searchResults = await jeopardyCollection.query.nearText(['question about animals'], { + limit: 3, + returnMetadata: ['distance'], // Return the distance of results from the query vector + includeVector: false // Change to true to include objects' vectors in your response +}) + +console.log("Near Text objects for:", JSON.stringify(searchResults, null, 2)); +// END Search + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_snippets/20_generative.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_snippets/20_generative.ts new file mode 100644 index 000000000..ee593a7ac --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/_snippets/20_generative.ts @@ -0,0 +1,81 @@ +// START Connect +import weaviate, { WeaviateClient, configure } from 'weaviate-client' + +// END Connect + +import 'dotenv/config' + +// START Connect +const weaviateURL = process.env.WEAVIATE_URL as string +const weaviateKey = process.env.WEAVIATE_API_KEY as string +const cohereKey = process.env.COHERE_API_KEY as string + +// Connect to your Weaviate instance +const client: WeaviateClient = await weaviate.connectToWeaviateCloud(weaviateURL,{ + authCredentials: new weaviate.ApiKey(weaviateKey), + headers: { + 'X-Cohere-Api-Key': cohereKey, // Replace with your inference API key + } + } +) +// END Connect + + // Delete the "JeopardyQuestion" collection if it exists + await client.collections.delete('JeopardyQuestion'); + + if (await client.collections.exists('JeopardyQuestion') == false) { +// START Collection +await client.collections.create({ + name: 'JeopardyQuestion', + properties: [ + { name: 'Category', dataType: configure.dataType.TEXT }, + { name: 'Question', dataType: configure.dataType.TEXT }, + { name: 'Answer', dataType: configure.dataType.TEXT} + ], + // Define your Cohere vectorizer and generative model + vectorizers: weaviate.configure.vectors.text2VecCohere(), + // highlight-start + generative: weaviate.configure.generative.cohere() + // highlight-start +}); +// END Collection + +} + + try { +// START Importing +let jeopardyCollection = client.collections.use('JeopardyQuestion'); + +// Download data to import into the "JeopardyQuestion" collection +const url = 'https://raw.githubusercontent.com/weaviate/weaviate-examples/main/jeopardy_small_dataset/jeopardy_tiny.json' +const response = await fetch(url); +const jeopardyQuestions = await response.json(); + +// Bulk insert downloaded data into the "JeopardyQuestion" collection +await jeopardyCollection.data.insertMany(jeopardyQuestions.data) + +console.log('Data Imported'); +// END Importing + } catch (e) { + console.error(e); + } + + const myCollection = client.collections.use('JeopardyQuestion'); +// START SingleGenerative +const genResult = await myCollection.generate.nearText("african elephant in savanna", { + singlePrompt: "translate {answer} into french for me", +}) + +for (const item of genResult.objects) { + console.log("Single generated concept:", item.generated); +} +// END SingleGenerative + +// START GroupedGenerative +const groupedGenResult = await myCollection.generate.nearText("african elephant in savanna", { + groupedTask: "Summarize all the results received into a single informational paragraph?", + groupedProperties: ["answer"] +}) + +console.log("Grouped generated concept:", groupedGenResult.generated); +// END GroupedGenerative diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/index.md new file mode 100644 index 000000000..388ed1c58 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/using-ml-models/index.md @@ -0,0 +1,42 @@ +--- +title: Weaviate における機械学習モデルの利用 +sidebar_position: 10 +--- + +# Weaviate における機械学習モデルの利用 + +## 概要 + +Weaviate は、AI ネイティブアプリケーションを支えるために 2 種類の基本的な機械学習モデルを活用します。 + +1. **Embedding Models** - データを高次元の ベクトル 表現へ変換します +2. **Generative Models** - 入力プロンプトとコンテキストに基づき新しいコンテンツを生成します + +本ガイドでは、これらのモデルを Weaviate で設定・利用する方法と、その高レベルでの動作を簡潔にご紹介します。 + +Weaviate がサポートする 2 種類の埋め込みモデル、**テキスト埋め込み** と **マルチモーダル埋め込み** によって実現される検索の使い方を見ていきます。 + +また、セマンティック検索からエージェント型 RAG アプリケーションまで、実践的なユースケースも取り上げます。 + +### 前提条件 + +- `weaviate-client` がインストールされた Node.js 環境 +- Weaviate の検索機能に関する基本的な理解 +- 中級レベルの JavaScript プログラミングスキル +- [クイックスタート](/weaviate/quickstart) を完了していること + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/05_review.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/05_review.mdx new file mode 100644 index 000000000..aed0bb1c9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/05_review.mdx @@ -0,0 +1,118 @@ +--- +title: 検索タイプの確認 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!./_snippets/05_review.ts'; + +## 概要 + +Weaviate は主に 3 種類の検索タイプ、つまり ベクトル 検索、キーワード 検索、ハイブリッド 検索を提供しています。ここでは、それぞれが何であるか、どのように機能するかを簡単に振り返ります。 + +### コード例 + +以下のコード例は、[`v3` Weaviate Typescript クライアント](../../../../weaviate/client-libraries/typescript/index.mdx)で実行できます。次のコードで事前設定済みのデモインスタンスに接続し、例を試してみてください。 + + + + + + + + + +## ベクトル検索 + +ベクトル検索は、クエリ ベクトル に最も近い ベクトル を持つオブジェクトを見つけます。 + +各 ベクトル は基になるオブジェクトを数値で表現しているため、ベクトル同士の類似度は意味の類似度と捉えられます。そのため、ベクトル検索は「セマンティック検索」とも呼ばれます。 + +Weaviate では、次のいずれかの方法で類似した ベクトル を持つオブジェクトを検索できます: + +ソースメディア (例: テキストや画像) を使用する場合: + + + + + + + + + +ベクトル を直接指定する場合: + + + + + + + + + +既存の Weaviate オブジェクトを使用する場合: + + + + + + + + + +## キーワード検索 + +キーワード検索は、クエリのキーワード (トークン) に最も関連性の高いキーワード (トークン) を含むオブジェクトを見つけます。関連性は [BM25F アルゴリズム](https://en.wikipedia.org/wiki/Okapi_BM25) によって判断されます。 + +直感的には、BM25F アルゴリズムは、キーワードがオブジェクト内の各フィールドにどれだけ頻繁に出現するかを、キーワードがデータセット全体でどれだけ一般的かと比較して「関連性」を決定します。 + + + + + + + + + +## ハイブリッド検索 + +ハイブリッド検索は、ベクトル検索とキーワード検索の結果を組み合わせます。両方の検索を実行し、その 2 つの検索結果を「融合 (fusion)」アルゴリズムで結合します。 + + + + + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/10_strengths.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/10_strengths.mdx new file mode 100644 index 000000000..1c7af0bc0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/10_strengths.mdx @@ -0,0 +1,201 @@ +--- +title: 各検索タイプの強み +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!./_snippets/10_strengths.ts'; + + +## 概要 + +これらの検索タイプはそれぞれ異なる特性を持ち、そのため強みも異なります。 + +各検索タイプの相対的な強みを見ていきましょう。 + +## ベクトル検索の強み + +### ロバスト性 + +ベクトルとは、対象オブジェクトの意味を数値で表現したものです。そのため、意味に影響しない変化に対してもベクトル検索はロバストです。 + +具体的には、たとえば 「 cat 」 のベクトルは、綴りが大きく異なる 「 kitten 」「 feline 」「 pet 」 のベクトルとも近くなります。 + +ベクトル検索を使って 「 cat 」 と 「 kitten 」 を検索した例をご覧ください。 + + + + + + + + + +結果は、「 cat 」 と 「 kitten 」 が非常に近いことがわかります。 + +つまり、モデルが意味を「理解」できるため、「 cat 」 と 「 kitten 」 のベクトルは意味的に近いということです。 + + + +同様に、「 cat 」 のスペルミスである 「 caat 」 や 「 catt 」 のベクトルも、「 cat 」 のベクトルと近くなります。 + + + + + + + + + +ここでも、結果はほぼ同一になります。 + + + +このロバスト性こそがベクトル検索の大きな強みです。検索者はデータセット内で使われている正確な単語を知っている必要がありません。検索対象の概念がはっきり定義されていない場合や、検索者がデータセットに詳しくない場合に特に役立ちます。 + +### 汎用性 + +ベクトル検索は汎用性も高いです。テキスト、画像、音声など複数のデータモダリティや、多言語にわたる検索に利用できます。 + +ベクトルは対象の意味を数値化したものなので、モダリティや言語が異なっていても、同じ意味なら同じベクトルで表現できます。 + +実際に、複数モダリティまたは複数言語(あるいはその両方)をまたいで検索できるモデルも存在します。これは、モダリティや言語にかかわらずデータを比較可能なベクトルへ変換できるモデルを使用することで実現しています。 + +![複数モダリティ間でのベクトル化](./_img/multimodal_example.png) + +## キーワード検索の強み + +### 正確性 + +キーワード検索は、正確な一致を見つける必要があるシーンに最適です。学術研究、ドメイン特化データの検索、技術的トラブルシューティングなど、検索したい正確な用語が存在する場面で特に有用です。 + +検索語と完全に一致する結果を返せることで、ユーザーは自身のクエリに対して最も関連性の高い情報を確実に得られます。 + +具体的な例として、以下では 「 imaging 」 を検索します。 + + + + + + + + + +結果を確認すると、 + + + +キーワード検索で 「 imaging 」 を検索すると、その単語を含む 1 件の結果のみが返されます。 +## ハイブリッド検索の強み + +ハイブリッド検索の主な強みは、そのレジリエンスです。詳細を見ていきましょう。 + +### レジリエンス + +ハイブリッド検索は、ベクトル検索とキーワード検索の両方から上位結果を組み合わせるため、いずれかの検索方式の弱点を補完できます。 + +以下のハイブリッド検索の例をご覧ください。 + + + + + + + + + +ここで結果を確認してみましょう。 + + + +キーワード検索による「imaging」の結果に加えて、意味的に関連性の高い「X-rays」の結果も取得できていることがわかります。 + +ハイブリッド検索はベクトル検索とキーワード検索の結果を組み合わせることで、少なくともどちらか一方で高いスコアを持つオブジェクトを見つけられます。このアプローチにより、両検索方式が相互補完的に働きます。 + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/20_selection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/20_selection.mdx new file mode 100644 index 000000000..9b6a33bb7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/20_selection.mdx @@ -0,0 +1,106 @@ +--- +title: 適切な検索タイプの選択 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!./_snippets/20_selection.ts'; + + +## 概要 + +適切な検索タイプを選択することは、効果的な検索タスクの鍵です。ここでは、ニーズに合った検索タイプを選ぶ方法を説明します。 + + +## 経験則 + + +### ベクトル検索の使用タイミング + +ベクトル検索は、最も堅牢で汎用性の高い検索タイプです。そのため、意味やベクトル表現が最重要となる場面に適しています。 + +クロスモーダル、オブジェクトベース、または多言語検索では、ベクトル検索が唯一の現実的な選択肢となる場合があります。 + +まずはベクトル検索を検討してください: + +- **非テキストまたはクロスモーダル検索** : 画像をテキスト説明で探す、またはその逆など、異なるメディア間で検索する際に不可欠です。 +- **オブジェクトベース検索** : 抽出したテキストチャンク・画像・動画と類似するオブジェクトを探す場合、ベクトル検索がほぼ唯一の解決策です。 +- **多言語コンテキスト** : 従来のキーワード検索では不足することがある多言語検索に最適です。 +- **複雑なクエリ理解** : 文脈やニュアンスの理解が求められる複雑なクエリに強みを発揮します。 + + +### キーワード検索の使用タイミング + +キーワード検索は、検索語を正確に一致させる必要がある、またはそう期待される場合に有用です。法務・医療・技術など、専門用語が重要な領域では特に有効です。 + +また、ユーザーが入力ミスをしにくく、フォームやドロップダウンメニューで決められた語を入力するような予測可能な状況でも効果的です。 + +まとめると、キーワード検索を選ぶ場面は次のとおりです: + +- **正確な用語一致** : 法務・医療・技術分野など、専門用語が重要な領域に最適です。 +- **予測可能なユーザー入力** : フォームやドロップダウンメニューなど、定義済みの語を入力するケースに向いています。 +- **シンプルかつ直接的なクエリ** : 自然言語処理の複雑さが不要な、単純な検索ニーズに適しています。 +- **高速かつ特定の結果** : 特定のキーワードやフレーズに基づく情報を迅速に取得したい場合に適しています。 + + +### ハイブリッド検索の使用タイミング + +ハイブリッド検索は「複雑な」状況に最適です。 + +ベクトル検索とキーワード検索の結果セットを組み合わせることで、ベクトル検索の堅牢性とキーワード検索の正確性をバランス良く提供します。 + +そのため、ベクトル検索やキーワード検索の特定用途に当てはまらない、大多数の検索ニーズに対して一般的に優れた選択肢となります。 + +まとめると、ハイブリッド検索を検討すべき場面は次のとおりです: + +- **幅広いトピック範囲** : コーパスが多岐にわたる場合に有効で、柔軟な検索アプローチを提供します。 +- **多様な検索シナリオ** : ベクトル検索とキーワード検索の両結果が求められる現実的なシナリオに役立ちます。 +- **予測しづらいユーザー入力** : ユーザーが自由にクエリを入力する多くの実際場面で理想的です。直接一致を狙うクエリもあれば、意味全体を重視するクエリもあります。 + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/30_strategies.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/30_strategies.mdx new file mode 100644 index 000000000..ad9380f5f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/30_strategies.mdx @@ -0,0 +1,162 @@ +--- +title: 検索結果を改善するための戦略 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!./_snippets/30_strategies.ts'; + + +## 概要 + +適切な検索タイプを選択することに加えて、検索結果の品質を向上させるために活用できる戦略もあります。 + +ここでは、これらの戦略のいくつかを見ていきます。 + +## ベクトル検索を改善する + +ベクトル検索を改善する鍵は、検索のニーズに合った目的適合的なベクトル表現を確保することです。 + +### ベクトライザーの選択 + +独自のベクトルを持つデータを挿入しない限り、Weaviate ベクトライザー モジュールおよびそのモジュール内のモデルを使用して、データのベクトルを生成します。 + +どのベクトライザー モジュールとモデルを選ぶかは重要で、データのどの側面がベクトル表現に取り込まれるか、そしてモデルがどれだけデータを「理解」できるかが決まります。 + +まず第一に、データタイプに最適なベクトライザー モジュールを選択する必要があります。たとえば、テキストデータを扱う場合は `text2vec` モジュールを、画像やマルチモーダルデータを扱う場合は `multi2vec` モジュールを使用するのが適切です。 + +ベクトライザーの選択については別のユニットで取り上げますが、どこから始めればよいか分からない場合は次を試してみてください。 +- テキストデータ向け( API ベース)には `text2vec-cohere` または `text2vec-openai` + - Cohere には 100 以上の言語で使用できる多言語モデルがあります。 +- 画像または画像とテキストのデータには `multi2vec-clip` + +テキストデータを扱い、ローカル推論コンテナを実行したい場合は `text2vec-transformers` として `sentence-transformers/all-MiniLM-L12-v2` のような一般的なモデルを試してください。 + +### リランカーを試す + +リランカー モジュールは検索結果の品質を向上させる優れた方法です。 + +リランカー モジュールは、ベクトル検索の結果を受け取り、追加の基準や別のモデルに基づいて結果を再ランク付けします。これにより、遅いが高品質なモデルをリランキングに使用しつつ、高速な一次検索の恩恵を受けられます。 + +たとえば、`text2vec-cohere` モジュールでベクトル検索を行い、その結果を `reranker-cohere` モジュールで別のモデルを用いてリランクすることができます。 + +### プロパティの選択 + +ベクトル化はオブジェクトの「意味」を捉えます。そのため、検索に適用する基準と関連のないプロパティは、ベクトル化プロセスから除外すべきです。 + +例として、商品オブジェクトに製造工程や製造場所などのメタデータが含まれている場合で、ベクトル検索を商品の特徴に基づいて行いたいのであれば、製造工程と製造場所のプロパティはベクトル化から除外する必要があります。 + +これは、以下のようにプロパティをベクトル化時にスキップするかどうかを指定することで行えます。コレクション名やプロパティ名でも同様に指定可能です。 + + + + + + + + + +### チャンク化 + +チャンク化とは、テキストを小さなチャンクに分割し、それぞれを個別にベクトル化するプロセスを指します。これは、各ベクトルが含む情報量を定義するため非常に重要です。 + +経験則として、検索の粒度が細かいほど、チャンクサイズは小さくする必要があります。例えば、特定の概念やアイデアを検索する場合は、文や小さなテキストウィンドウのような小さな単位にチャンク化します。一方で、章や本全体のようなより広い概念を検索する場合は、それに合わせてテキストをチャンク化します。 + +## キーワード検索を改善する + +### トークナイゼーション + +BM25 検索を「キーワード」検索と呼んでいますが、実際には正確に一致するのは「単語」ではなく「トークン」です。これはベクトル埋め込み生成に使用されるトークナイゼーションとは異なり、BM25 検索やフィルタリングのための転置インデックスを構築するために使用されます。 + +したがって、どのトークンがマッチングに用いられるかを決定するトークナイゼーションプロセスは非常に重要です。 + +使用可能なオプションは `word`、`lowercase`、`whitespace`、`field` です。デフォルトの `word` は散文には十分かもしれませんが、大文字小文字や記号を含む完全一致が重要なテキストでは `whitespace` などがより適切な場合があります。 + +利用可能なトークナイゼーションオプション: + +import TokenizationDefinition from '/_includes/tokenization_definition.mdx'; + + + +コレクションの設定でトークナイゼーションを指定できます。 + + + + + + + + + +### プロパティの選択とブースト + +特定のプロパティでのマッチが結果に過度に影響している場合、そのプロパティを検索から除外する、または特定のプロパティの重要度をブーストすることができます。 + +たとえば、`description` プロパティでの一致は `notes` プロパティでの一致よりも重要かもしれません。これはクエリ時に指定できます。 + + + + + + + + +## ハイブリッド検索の改善 + +### alpha パラメーター + +`alpha` パラメーターは、ベクトル検索結果とキーワード検索結果のバランスを決定します。 + +検索をよりベクトルベースにしたい場合は `alpha` 値を大きくしてください。 +反対に、検索をよりキーワードベースにしたい場合は `alpha` 値を小さくしてください。 + + + + + + + + + +### フュージョンアルゴリズム + +フュージョンアルゴリズムは、ベクトル検索とキーワード検索から得られた結果をどのように統合するかを決定します。 + +既定では、各結果セットのランクの逆数を合計する「ランクドフュージョン」アルゴリズムが使用されます。 +ただし、各結果セットのスコアを正規化して合計する「相対スコアフュージョン」アルゴリズムを使用することもできます。 + +一般的に「相対スコアフュージョン」のほうが精度が高いことが多いですが、ユースケースに応じて両方を試してみることをおすすめします。 + + + + + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_30_improve_search.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_30_improve_search.mdx new file mode 100644 index 000000000..b36f3a121 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_30_improve_search.mdx @@ -0,0 +1,13 @@ +--- +title: 検索の改善 +--- + +- 検索品質の評価 +- 検索品質の向上 + - ベクトライザー + - データ構造 + - 検索タイプ +- 検索速度の向上 + - 推論速度 + - リソース要求 + - クエリのボトルネック \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_img/multimodal_example.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_img/multimodal_example.png new file mode 100644 index 000000000..628d4d5be Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_img/multimodal_example.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/05_review.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/05_review.ts new file mode 100644 index 000000000..7be057a22 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/05_review.ts @@ -0,0 +1,112 @@ +import weaviate, { WeaviateClient, WeaviateReturn } from "weaviate-client" +// START connectionCode +let client: WeaviateClient + + +client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL as string, { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, // Replace with your inference API key + } +} +) +// END connectionCode + + +// START nearTextExample // START nearVectorExample // START nearObjectExample // START bm25Example // START hybridExample +type NonGenericReturn = WeaviateReturn +let response: NonGenericReturn + +const questions = client.collections.use("JeopardyQuestion") + +// END nearTextExample // END nearVectorExample // END nearObjectExample // END bm25Example // END hybridExample + +// START nearTextExample +response = questions.query.nearText("space travel", // Your query string + { + limit: 2 + } +) + +for (const item of response.objects) { + console.log(item.uuid) + console.log(item.properties) +} +// END nearTextExample +// assert len(response.objects) == 2 +// assert "question" in response.objects[0].properties.keys() + +response = questions.query.nearText("space travel", { + limit: 1, + includeVector: true +} +) +let vectorInput = response.objects[0].vectors +let objectInput = response.objects[0].uuid + +// START nearVectorExample +response = questions.query.nearVector(vectorInput, // Your vectors + { + limit: 2 + } +) + +for (const item of response.objects) { + console.log(item.uuid) + console.log(item.properties) +} +// END nearVectorExample + +// assert len(response.objects) == 2 +// assert "question" in response.objects[0].properties.keys() + +// START nearObjectExample +response = questions.query.nearObject(objectInput, // Your object UUID + { + limit: 2 + } +) + +for (const item of response.objects) { + console.log(item.uuid) + console.log(item.properties) +} +// END nearObjectExample + + +// assert len(response.objects) == 2 +// assert "question" in response.objects[0].properties.keys() + +// START bm25Example +response = questions.query.bm25("space travel", // Your query string + { + limit: 2 + } +) + +for (const item of response.objects) { + console.log(item.uuid) + console.log(item.properties) +} +// END bm25Example + +// assert len(response.objects) == 2 +// assert "question" in response.objects[0].properties.keys() + + +// START hybridExample +response = questions.query.hybrid("space travel", // Your query string + { + limit: 2 + } +) + +for (const item of response.objects) { + console.log(item.uuid) + console.log(item.properties) +} + +// END hybridExample + +// assert len(response.objects) == 2 +// assert "question" in response.objects[0].properties.keys() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/10_strengths.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/10_strengths.ts new file mode 100644 index 000000000..8315bf1db --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/10_strengths.ts @@ -0,0 +1,164 @@ +import weaviate, { WeaviateClient, WeaviateReturn } from "weaviate-client" + +let client: WeaviateClient +type NonGenericReturn = WeaviateReturn +let response: NonGenericReturn +// # END-ANY + +client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL as string,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, // Replace with your inference API key + } + } + ) + +// START robustnessExampleWords +for (const query of ["cat", "kitten"]) { + const question = client.collections.use("JeopardyQuestion") + + response = await question.query.nearText(query,{ + limit: 1, + returnMetadata: ['distance'], + returnProperties: ["question", "answer"] + }) + + for (const item of response.objects) { + console.log(`\n===== Search results for ${query} =====`) + console.log("Distance:", item.metadata?.distance) + console.log(item.properties) + } +} +// END robustnessExampleWords +// assert length(response.objects) == 1 +// assert "question" in response.objects[0].properties.keys() + + +const example = ` +// START responseRobustnessExampleWords +===== Search results for cat ===== +Distance: 0.170 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} + +===== Search results for kitten ===== +Distance: 0.150 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} +// END responseRobustnessExampleWords +` + +// START robustnessExampleSpelling +for (const query of ["cat", "catt", "caat"]) { + const question = client.collections.use("JeopardyQuestion") + + response = await question.query.nearText(query,{ + limit: 1, + returnMetadata: ['distance'], + returnProperties: ["question", "answer"] + }) + + for (const item of response.objects) { + console.log(`\n===== Search results for ${query} =====`) + console.log("Distance:", item.metadata?.distance) + console.log(item.properties) + } +} + +// END robustnessExampleSpelling + +// assert len(response.objects) == 1 +// assert "question" in response.objects[0].properties.keys() + + +const example2 = ` +// START responseRobustnessExampleSpelling +===== Search results for cat ===== +Distance: 0.170 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} + +===== Search results for catt ===== +Distance: 0.177 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} + +===== Search results for caat ===== +Distance: 0.184 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} +// END responseRobustnessExampleSpelling +` + +// START bm25Example // START hybridExample +const question = client.collections.use("JeopardyQuestion") +// END bm25Example // END hybridExample + +// START bm25Example + +response = await question.query.bm25("imaging",{ // Your query string + limit: 2, + returnProperties: ["question", "answer"] + }) + +for (const item of response.objects) { + console.log(item.uuid) + console.log(item.properties) +} +// END bm25Example + +// assert "question" in response.objects[0].properties.keys() + +const example3 = ` +// START bm25Results +49fe3d7c-61a5-5916-99bb-052d07c7c251 +{ + "answer": "magnetic resonance imaging", + "question": "MRI, which stands for this, cannot be used on patients with pacemakers or artificial metal joints" +} +// END bm25Results +` + +// START hybridExample + +response = await question.query.hybrid("imaging", { // Your query string + limit: 2, + returnMetadata: ["score"], + returnProperties: ["question", "answer"] + }) + +for (const item of response.objects) { + console.log(item.uuid) + console.log(item.metadata?.score) + console.log(item.properties) +} + +// END hybridExample + +// assert "question" in response.objects[0].properties.keys() + + +` +// START hybridResults +49fe3d7c-61a5-5916-99bb-052d07c7c251 +{ + "answer": "magnetic resonance imaging", + "question": "MRI, which stands for this, cannot be used on patients with pacemakers or artificial metal joints" +} +9041bce6-b5d1-5637-bcbe-2ebb8a689fe0 +{ + "answer": "X-rays", + "question": "These electromagnetic rays used to take pictures of your insides were originally known as Roentgen rays" +} +// END hybridResults +` diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/20_selection.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/20_selection.ts new file mode 100644 index 000000000..e69de29bb diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/30_strategies.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/30_strategies.ts new file mode 100644 index 000000000..45c1ab252 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/_snippets/30_strategies.ts @@ -0,0 +1,127 @@ +import weaviate, { CollectionConfig, CollectionConfigCreate, WeaviateClient, WeaviateReturn } from "weaviate-client" + +let client: WeaviateClient + +client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL as string,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, // Replace with your inference API key + } + } +) + +client.collections.delete("Product") + +// START skipVectorizationExample // START tokenizationExample +let products: CollectionConfigCreate +// END skipVectorizationExample // END tokenizationExample + +// START skipVectorizationExample +products = await client.collections.create({ + name: "Product", + vectorizers: weaviate.configure.vectors.text2VecOpenAI({ + // highlight-start + vectorizeCollectionName: true + // highlight-end + }), + properties: [{ + name: "name", + dataType: weaviate.configure.dataType.TEXT, + // highlight-start + vectorizePropertyName: true + // highlight-end + }, + { + name: "description", + dataType: weaviate.configure.dataType.TEXT, + }, + { + name: "manufacturing_process", + dataType: weaviate.configure.dataType.TEXT, + // highlight-start + skipVectorization: true, // Skip unwanted property + //highlight-end + }] +}) +// END skipVectorizationExample + +client.collections.delete("Product") + +client.collections.delete("SomeCollection") + +// START tokenizationExample + +products = await client.collections.create({ + name: "SomeCollection", + properties: [{ + name: "name", + dataType: weaviate.configure.dataType.TEXT, + // highlight-start + tokenization: weaviate.configure.tokenization.WORD // Default + // highlight-end + }, + { + name: "description", + dataType: weaviate.configure.dataType.TEXT, + tokenization: weaviate.configure.tokenization.WHITESPACE // Will keep case & special characters + }, + { + name: "email", + dataType: weaviate.configure.dataType.TEXT, + // highlight-start + tokenization: weaviate.configure.tokenization.FIELD // Do not tokenize at all + // highlight-end + }] +}) +// END tokenizationExample + + +client.collections.delete("SomeCollection") + +// START selectAndBoostExample // START adjustAlpha // START changeFusionType +type NonGenericReturn = WeaviateReturn +let response: NonGenericReturn + +const questions = client.collections.use("JeopardyQuestion") + +// END selectAndBoostExample // END adjustAlpha // END changeFusionType + + +// START selectAndBoostExample +response = questions.query.bm25("animal",{ // Your query string + limit: 5, + queryProperties: ["question^3", "answer"] // Boost the impact of "question" property by 3 + } +) + +for (const item of response.objects) { + console.log(item.properties) +} +// END selectAndBoostExample + +// START adjustAlpha +response = questions.query.hybrid("imaging",{ // Your query string + limit: 5, + alpha: 0.1, // Mostly a vector search (Try it with alpha=0.9) + } +) + +for (const item of response.objects) { + console.log(item.properties) +} +// END adjustAlpha + + + +// START changeFusionType +response = questions.query.hybrid("imaging",{ // Your query string + limit: 5, + fusionType: "RelativeScore", + alpha: 0.1, // Mostly a vector search (Try it with alpha=0.9) + } +) + +for (const item of response.objects) { + console.log(item.properties) +} +// END changeFusionType diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/index.md new file mode 100644 index 000000000..aa41389e5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/standalone/which-search/index.md @@ -0,0 +1,50 @@ +--- +title: 自分に最適な検索方式 +sidebar_position: 10 +--- + +## ユニット概要 + + + + + + + +Weaviate は、** ベクトル **、** キーワード **、** ハイブリッド ** の 3 つの検索方法を提供しています。 + +それぞれに固有の強みと適用範囲があり、どの方法を選ぶかは検索関連タスクの成否を左右します。 + +本セクションでは、これらの検索タイプを比較し、いつ・なぜ各手法を使用すべきかを直感的に判断できるようにします。 + +検索タイプの選択が検索結果の品質だけでなく、検索処理全体のパフォーマンスにもどのように影響するかを探ります。 + +さらに、検索結果の品質および検索処理のパフォーマンスを向上させるための戦略についても説明します。 + + +### 前提条件 + +- `weaviate-client` がインストールされた Node.js 環境 +- Weaviate の検索機能に精通していること +- 中級レベルのコーディングスキル(例: JavaScript) + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/10_client.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/10_client.mdx new file mode 100644 index 000000000..91aa8be19 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/10_client.mdx @@ -0,0 +1,39 @@ +--- +title: Weaviate TypeScript クライアント +description: Weaviate でマルチモーダルデータを扱うためのクライアントセットアップ +--- + +## インストール + +最新の Weaviate TypeScript クライアントライブラリは npm でインストールできます。 +このクライアントライブラリは Node v18 以降でテストされています。 +以下のコマンドでインストールしてください: + +```bash +npm install weaviate-client +``` + +最新のメジャーバージョンは `v3`(例: `3.x.x`)です。 +バージョンは次のように確認できます: + +```bash +npm view weaviate-client version +``` + +## 基本的な使い方 + +Weaviate クライアントライブラリは次のようにインポートできます: + +```typescript +import weaviate, { generateUuid5, ApiKey } from "weaviate-client" +``` + +クライアントには、Weaviate とのやり取りを簡単にするための補助関数(例: `generateUuid5, ApiKey`)が用意されています。 + +次に、Weaviate インスタンスを作成して接続する方法を示します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx new file mode 100644 index 000000000..7ca954922 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx @@ -0,0 +1,67 @@ +--- +title: "オプション 1: WCD クラウドインスタンス" +description: "スケーラブルなクラウドベースのデータプロジェクト向けに WCS 上で Weaviate インスタンスを作成します。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../../_snippets/101_connect.mts'; + +ここでは、Weaviate Cloud (WCD) インスタンスを作成します。WCD はクラウドで稼働する完全マネージドの Weaviate インスタンスで、インストールや保守が不要なため Weaviate を始めるのに最適です。 + +### WCD Console にログインする + +[WCD Console](https://console.weaviate.cloud/) にアクセスし、認証情報でログインします。まだアカウントをお持ちでない場合は、ログイン画面の Register here リンクからサインアップできます。 + +### Weaviate インスタンスを作成する + +コンソールで Dashboard に移動し、Create cluster ボタンをクリックします。次の画面で以下を設定します。 + +- 「Free sandbox」タブを選択 +- クラスター名を入力 +- 「Enable authentication」を「Yes」に設定 + +Create ボタンをクリックして Weaviate インスタンスを作成します。完了まで数分かかります。 + +### Weaviate インスタンスの詳細を取得する + +インスタンスが作成されたら、Details ボタンをクリックして詳細を確認できます。クラスター URL と API キーを探してください。 + +これらの情報は Weaviate インスタンスへ接続する際に必要です。 + +### WCD インスタンスへ接続する + +Weaviate Cloud (WCD) インスタンスへ接続するには、クラスター URL と API キーが必要です。これらは WCD Console で確認できます。 + +`connectToWeaviateCloud()` 関数を使用して WCD インスタンスへ接続します。 + + + +#### 推論 API キーを設定する + +一部の Weaviate モジュールでは、データのベクトル化や大規模言語モデル統合のために推論 API を利用できます。これらのサービス用 API キーは、インスタンス生成時に Weaviate へ渡せます。 + +この講座では VoyageAI を使用するため、以下のように `headers: {"X-VoyageAI-Api-Key": }` を通じて VoyageAI API キーを Weaviate に提供してください。 + + + +:::note 次のステップ +これが完了したら、次のページ [オプション 2: ローカル Weaviate インスタンス](./20_create_docker.mdx) をスキップし、[Weaviate との通信](../30_communicate.mdx) へ進んでください。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx new file mode 100644 index 000000000..b1c9b1f67 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx @@ -0,0 +1,93 @@ +--- +title: "オプション 2: ローカル Docker インスタンス" +description: "素早くカスタマイズ可能なローカル環境として Docker で Weaviate をセットアップします。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../../_snippets/101_connect.mts'; + +:::note すでに Weaviate インスタンスを作成しましたか? +Weaviate の [クラウドインスタンスを作成済み](./10_create_wcs.mdx) の場合は、このページをスキップして [Weaviate との通信](../30_communicate.mdx) に進んでください。 +::: + +ここでは、Docker を使用して Weaviate インスタンスを作成します。 + +### docker-compose ファイルのダウンロードと実行 + +お使いのマシンに Docker をインストールしてください。インストールには [公式 Docker インストールガイド](https://docs.docker.com/get-docker/) を参照することをお勧めします。 + +新しいディレクトリを作成し、ターミナルでそのディレクトリに移動します。そして `docker-compose.yml` というファイルを作成し、次の内容を追加します: + +```yaml +--- +version: '3.4' +services: + weaviate_anon: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + COHERE_APIKEY: $COHERE_APIKEY + VOYAGEAI_APIKEY: $VOYAGEAI_APIKEY + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + DEFAULT_VECTORIZER_MODULE: 'none' + ENABLE_MODULES: 'text2vec-cohere,multi2vec-voyageai,generative-cohere' + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node1' +... +``` + +### Weaviate インスタンスの作成 + +次のコマンドを実行して Weaviate を起動します: + +```bash +docker compose up -d +``` + +### Weaviate インスタンスの詳細 + +インスタンスが作成されると、`http://localhost:8080` でアクセスできます。 + +### Weaviate インスタンスへの接続 + +Weaviate インスタンスに接続するには、`connectToLocal()` 関数を使用します。 + + + +#### 推論 API キーの指定 + +一部の Weaviate モジュールは、データのベクトル化や大規模言語モデルとの統合に推論 API を利用できます。これらのサービスの API キーは、Weaviate のインスタンス化時に渡すことができます。 + +このコースでは VoyageAI を使用します。以下のように `headers: {"X-VoyageAI-Api-Key": }` を設定して VoyageAI の API キーを Weaviate に渡してください: + + + +## 質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/index.mdx new file mode 100644 index 000000000..2053714ea --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/20_create_instance/index.mdx @@ -0,0 +1,19 @@ +--- +title: Weaviate インスタンスの作成 +description: "テキスト データ アプリケーション向けに最適化された新しい Weaviate インスタンスを作成します。" +--- + +このユニットでは、 Weaviate Cloud (WCD) インスタンスまたはローカル Docker インスタンスを作成できます。 + +- [Weaviate Cloud (WCD) インスタンスを作成](./10_create_wcs.mdx) + - インストールや保守を気にせずにマネージドサービスを利用したい場合に選択してください。 +- [ローカル Docker インスタンスを作成](./20_create_docker.mdx) + - Weaviate をローカルマシンで実行したい、またはインストールと保守を完全に制御したい場合に選択してください。 + +どちらの選択肢でも本コースの受講に支障はありません。迷った場合は、まず WCD インスタンスから始めることをおすすめします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/30_communicate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/30_communicate.mdx new file mode 100644 index 000000000..95f7ec38d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/30_communicate.mdx @@ -0,0 +1,64 @@ +--- +title: Weaviate と通信する +description: マルチモーダルデータ用の通信設定 +--- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/101_connect.mts'; + +ここでは、 TypeScript クライアントライブラリを使用して Weaviate と通信する基本的な操作を行います。 + +### Weaviate のステータス確認 + +`isLive` 関数を使用して、 Weaviate インスタンスが稼働しているかを確認できます。 + + + +### サーバーメタ情報の取得 + +`getMeta` 関数を使用して、 Weaviate インスタンスのメタ情報を取得できます。 + + + +これにより、サーバーのメタ情報がコンソールに出力されます。出力例は次のとおりです: + +
+ `getMeta()` の出力例 + + +
+ +### 接続の終了 + +Weaviate クライアントの使用が終わったら、接続を終了する必要があります。これによりリソースが解放され、接続が正しくクローズされます。 + +ベストプラクティスとして、 `try`-`finally` ブロックの使用を推奨します。簡潔にするため、以降のコードスニペットでは `try`-`finally` ブロックを省略します。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/index.mdx new file mode 100644 index 000000000..15568f094 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/101_setup_weaviate/index.mdx @@ -0,0 +1,25 @@ +--- +title: Weaviate のセットアップ +description: マルチモーダルデータ向け Weaviate セットアップ +--- + + + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/10_preparation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/10_preparation.mdx new file mode 100644 index 000000000..acb03feb4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/10_preparation.mdx @@ -0,0 +1,36 @@ +--- +title: 準備 +--- + +このセクションでは、映画データセットを使用して Weaviate インスタンスにデータを投入し、マルチモーダルの Cohere Embed 3 モデルでテキストおよび画像データをベクトル化します。 + +### Weaviate インスタンス + +Weaviate インスタンスの準備ができていることを確認してください。[インスタンスを作成](../101_setup_weaviate/20_create_instance/index.mdx)し、接続できる状態になっている必要があります。 + +### ソースデータ + +映画データセットとして [TMDB](https://www.themoviedb.org/) から取得したデータを使用します。データセットはこの [GitHub リポジトリ](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json) にあり、1990 年から 2024 年に公開された約 700 本の映画に関する書誌情報が含まれています。 + +マルチモーダルプロジェクトとして、同じリポジトリにある [各映画のポスター](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024_posters.zip) も使用します。 + +
+ サンプルテキストデータを見る + +| | backdrop_path | genre_ids | id | original_language | original_title | overview | popularity | poster_path | release_date | title | video | vote_average | vote_count | +|---:|:---------------------------------|:----------------|-----:|:--------------------|:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------:|:---------------------------------|:---------------|:----------------------------|:--------|---------------:|-------------:| +| 0 | /3Nn5BOM1EVw1IYrv6MsbOS6N1Ol.jpg | [14, 18, 10749] | 162 | en | Edward Scissorhands | A small suburban town receives a visit from a castaway unfinished science experiment named Edward. | 45.694 | /1RFIbuW9Z3eN9Oxw2KaQG5DfLmD.jpg | 1990-12-07 | Edward Scissorhands | False | 7.7 | 12305 | +| 1 | /sw7mordbZxgITU877yTpZCud90M.jpg | [18, 80] | 769 | en | GoodFellas | The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway. | 57.228 | /aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg | 1990-09-12 | GoodFellas | False | 8.5 | 12106 | +| 2 | /6uLhSLXzB1ooJ3522ydrBZ2Hh0W.jpg | [35, 10751] | 771 | en | Home Alone | Eight-year-old Kevin McCallister makes the most of the situation after his family unwittingly leaves him behind when they go on Christmas vacation. But when a pair of bungling burglars set their sights on Kevin's house, the plucky kid stands ready to defend his territory. By planting booby traps galore, adorably mischievous Kevin stands his ground as his frantic mother attempts to race home before Christmas Day. | 3.538 | /onTSipZ8R3bliBdKfPtsDuHTdlL.jpg | 1990-11-16 | Home Alone | False | 7.4 | 10599 | +| 3 | /vKp3NvqBkcjHkCHSGi6EbcP7g4J.jpg | [12, 35, 878] | 196 | en | Back to the Future Part III | The final installment of the Back to the Future trilogy finds Marty digging the trusty DeLorean out of a mineshaft and looking for Doc in the Wild West of 1885. But when their time machine breaks down, the travelers are stranded in a land of spurs. More problems arise when Doc falls for pretty schoolteacher Clara Clayton, and Marty tangles with Buford Tannen. | 28.896 | /crzoVQnMzIrRfHtQw0tLBirNfVg.jpg | 1990-05-25 | Back to the Future Part III | False | 7.5 | 9918 | +| 4 | /3tuWpnCTe14zZZPt6sI1W9ByOXx.jpg | [35, 10749] | 114 | en | Pretty Woman | When a millionaire wheeler-dealer enters a business contract with a Hollywood hooker Vivian Ward, he loses his heart in the bargain. | 97.953 | /hVHUfT801LQATGd26VPzhorIYza.jpg | 1990-03-23 | Pretty Woman | False | 7.5 | 7671 | + +
+ +次に、対応するオブジェクトコレクションを作成し、データをインポートします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/20_create_collection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/20_create_collection.mdx new file mode 100644 index 000000000..07bbe1c75 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/20_create_collection.mdx @@ -0,0 +1,89 @@ +--- +title: コレクションの作成 +description: マルチモーダルデータコレクションの作成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/102_collection.mts'; + + Weaviate はデータを「コレクション」に保存します。コレクションとは、同じデータ構造を共有するオブジェクトの集合です。映画データベースでは、映画のコレクション、俳優のコレクション、レビューのコレクションなどを作成できます。 + +ここでは映画のコレクションを作成します。 + +## コード + +次の例では、映画データ用のコレクションを作成しています。 + + + +各コレクション定義には名前が必須です。そのうえで、この例のように追加パラメーターを設定できます。 + +## コードの説明 + +### プロパティ + +プロパティは、コレクションに保存したいオブジェクト属性です。各プロパティには名前とデータ型があります。 + +映画データベースでは、`title`、`release_date`、`genre_ids` といったプロパティがあり、データ型は `TEXT`(文字列)、`DATE`(日付)、`INT`(整数)などです。`genre_ids` のように整数の配列を持つことも可能です。 + +マルチモーダルオブジェクトとして、画像データである `poster` プロパティもあり、これは `BLOB`(バイナリ大規模オブジェクト)型で保存されます。 + +#### 自動スキーマ + + Weaviate はデータから自動で [スキーマを推論](/weaviate/config-refs/collections#auto-schema)できます。ただし、制御性を高め予期せぬ挙動を防ぐために、プロパティを明示的に定義することを推奨します。 + +### ベクトライザー設定 + +自分でベクトルを指定しない場合、 Weaviate は指定された ベクトライザー を使用してデータからベクトル埋め込みを生成します。 + +このコード例では `multi2vec-voyageai` モジュールを指定しています。このモジュールは **voyage-multimodal-3** モデルを用いてテキストと画像データからベクトル埋め込みを生成します。 + +ベクトル化に利用するテキストおよび画像プロパティを任意の数だけ指定でき、それぞれに異なる重みを設定できます。重みは、ベクトル埋め込み生成プロセスにおける各プロパティの相対的重要度を決定します。この例では、`poster` プロパティ(画像)に 90% の重み、`title` プロパティ(文字列)に 10% の重みを設定しています。 + + + +### 生成設定 + +コレクションを生成モデル(例: 大規模言語モデル)で使用する場合、生成モジュールの指定が必要です。 + +このコード例では、`cohere` モジュール(正式名称は `generative-cohere`)をデフォルト設定で指定しています。 + + + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +### TypeScript の名前付きインポート + +このコード例では、`vectorizer` や `configure` などの名前付きインポートを使用しています。これらは `weaviate` モジュールで定義されており、コレクション定義時に利用します。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/30_import_data.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/30_import_data.mdx new file mode 100644 index 000000000..01ee32176 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/30_import_data.mdx @@ -0,0 +1,106 @@ +--- +title: データのインポート +description: マルチモーダルデータコレクションへのデータ取り込み +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/102_collection.mts'; + +## コード + +この例では、映画データをコレクションにインポートします。 + + + +コードの概要: +- ソースのテキストと画像データを読み込みます +- コレクションを取得します +- データをループ処理し、次を行います: + - テキストに対応する画像を探す + - 画像を base64 に変換する + - 20 件ずつオブジェクトを一括挿入する +- インポート時のエラーを表示します + +## コードの説明 + +### 準備 + +ネイティブの Node.js `fetch()` を使用して、ソースからデータを読み込みます。ここではテキストデータが入った JSON ファイルとポスターが入った Zip ファイルです。テキストデータは操作しやすいように JSON オブジェクトへ変換し、画像は Zip から展開します。 + +次に、`client.collections.get` でコレクションオブジェクトを作成し、コレクションとやり取りできるようにします。 + +### データの反復処理 + +`for` ループと `Object.keys()` を組み合わせて、JSON ファイル内の要素を反復処理します。反復しながらカウンター変数をインクリメントし、バッチ単位でオブジェクトを一括挿入できるようにします。 + + + +### オブジェクトへのデータ追加 + +#### データ型の変換とオブジェクト構築 + +データを文字列から Weaviate 用の正しいデータ型に変換します。たとえば、`release_date` は `Date` オブジェクトへ、`genre_ids` は整数のリストへ変換します。 + + + +画像データを `BLOB` (Binary Large Object) 型で保存するために、Weaviate クライアント付属の便利な `toBase64FromMedia` ユーティリティを使って画像を base64 に変換します。 + + + +データを正しい形式に変換した後、プロパティを設定してオブジェクトを構築し、 Weaviate へ挿入できるように準備します。 + +#### データの一括挿入 + +`generateUuid5` で生成した uuid と、先ほど定義したプロパティを持つオブジェクトを作成し、これを `itemsToInsert` にプッシュします。バッチが準備できたら `insertMany()` で一括挿入します。 + + + +### エラー処理 + +一括挿入でエラーが発生した場合、問題が起こったことを把握したいものです。たとえば例外を投げるなどの対処が考えられます。この例では、インポートにエラーがあったことを単に出力しています。 + + + +## ベクトルの生成元 + + がアイテムを Weaviate に送信すると、オブジェクトはコレクション (ここでは映画コレクション) に追加されます。 + +コレクションにはベクトライザーモジュールが設定されており、ここではベクトルを指定していません。そのため、 Weaviate は指定されたベクトライザーを使用してデータからベクトル埋め込みを生成します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/index.mdx new file mode 100644 index 000000000..5d6864a3d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/102_mm_collections/index.mdx @@ -0,0 +1,26 @@ +--- +title: データベースの入力 +description: マルチモーダルデータコレクションの概要 +--- + + + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/10_multimodal.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/10_multimodal.mdx new file mode 100644 index 000000000..0f2937d5c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/10_multimodal.mdx @@ -0,0 +1,145 @@ +--- +title: マルチモーダル検索 +description: マルチモーダル検索の方法論 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/103_searches.mts'; + +Weaviate を使用すると、アイテムの意味に基づいて類似アイテムを見つけるセマンティック検索を実行できます。これは、データベース内のアイテムの ベクトル 埋め込みを比較することで行われます。 + +マルチモーダルモデルを使用しているため、サポートされている任意のモダリティとの類似度に基づいてオブジェクトを検索できます。つまり、テキストや画像との類似度をもとに映画を検索することが可能です。 + +## 画像クエリ + +### コード + +この例では、「Movie」から [国際宇宙ステーションのこの画像](https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/International_Space_Station_after_undocking_of_STS-132.jpg/440px-International_Space_Station_after_undocking_of_STS-132.jpg) との類似度に基づいてエントリを検索し、上位 5 件のタイトルと公開年を出力します。 + +
+ クエリ画像 + +![International Space Station](https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/International_Space_Station_after_undocking_of_STS-132.jpg/440px-International_Space_Station_after_undocking_of_STS-132.jpg) + +
+ + + +### コードの解説 + +結果は、クエリとデータベースオブジェクト間の ベクトル 埋め込みの類似度に基づいています。この場合、ベクトライザー モジュールが入力画像の埋め込みを生成します。 + +`limit` パラメーターは、返される結果の最大数を設定します。 + +`returnMetadata` パラメーターは、検索結果に含めるメタデータを文字列配列で指定します。このクエリでは、クエリとの ベクトル 距離を返します。 + + +
+ 結果例 + +上位 5 件のポスター: +Interstellar +Gravity +Arrival +Armageddon +Godzilla + +Weaviate の出力: + +```text +Interstellar 2014 157336 +Distance to query: 0.354 + +Gravity 2013 49047 +Distance to query: 0.384 + +Arrival 2016 329865 +Distance to query: 0.386 + +Armageddon 1998 95 +Distance to query: 0.400 + +Godzilla 1998 929 +Distance to query: 0.441 +``` + +
+ +### レスポンスオブジェクト + +返されるオブジェクトはカスタムクラスのインスタンスです。その `objects` 属性は検索結果のリストで、各オブジェクトも別のカスタムクラスのインスタンスです。 + +各オブジェクトは次のとおりです: +- BLOB データ型を除くすべてのプロパティと UUID がデフォルトで含まれます。 + - `poster` プロパティは BLOB のため、デフォルトでは含まれません。 + - `poster` を含めるには、他の取得したいプロパティとともに `returnProperties` パラメーターで指定する必要があります。 +- 参照、メタデータ、 ベクトル など、その他の情報はデフォルトでは含まれません。 + + +## テキスト検索 + +### コード + +この例では、「Movie」からクエリ「red」との類似度に基づいてエントリを検索し、上位 5 件のタイトルと公開年を出力します。 + + + +### コードの解説 + +結果は、クエリとデータベースオブジェクト間の ベクトル 埋め込みの類似度に基づいています。この場合、ベクトライザー モジュールが入力テキストの埋め込みを生成します。 + +その他のパラメーターは前の例と同じです。 + +
+ 結果例 + +上位 5 件のポスター: +Deadpool 2 +Bloodshot +Deadpool +300 +The Hunt for Red October + +Weaviate の出力: + +```text +Deadpool 2 2018 383498 +Distance to query: 0.670 + +Bloodshot 2020 338762 +Distance to query: 0.677 + +Deadpool 2016 293660 +Distance to query: 0.678 + +300 2007 1271 +Distance to query: 0.682 + +The Hunt for Red October 1990 1669 +Distance to query: 0.683 +``` + +
+ +### レスポンスオブジェクト + +返されるオブジェクトの形式は前の例と同じです。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/20_keyword_hybrid.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/20_keyword_hybrid.mdx new file mode 100644 index 000000000..cf3116243 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/20_keyword_hybrid.mdx @@ -0,0 +1,105 @@ +--- +title: キーワード & ハイブリッド検索 +description: マルチモーダルコレクションでのハイブリッドキーワード検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/103_searches.mts'; + +キーワード( BM25 )検索を実行してキーワード類似度に基づいてアイテムを検索したり、BM25 とセマンティック / ベクトル検索を組み合わせたハイブリッド検索を行うこともできます。 + +## キーワード検索 + +### コード + +この例では、「Movie」クラス内で「history」という語に対してキーワード検索スコアが最も高いエントリを取得し、上位 5 件のタイトルと公開年を出力します。 + + + +### コードの説明 + +結果は、キーワード検索スコアである BM25f アルゴリズムに基づいています。 + +`limit` パラメーターは、返される結果の最大数を設定します。 + +`returnMetadata` パラメーターは、検索結果で返すメタデータを設定する文字列の配列を受け取ります。現在のクエリでは、結果の BM25 スコアである `score` を返します。 + +
+ 結果例 + +```text +American History X 1998 +BM25 score: 2.707 + +A Beautiful Mind 2001 +BM25 score: 1.896 + +Legends of the Fall 1994 +BM25 score: 1.663 + +Hacksaw Ridge 2016 +BM25 score: 1.554 + +Night at the Museum 2006 +BM25 score: 1.529 +``` + +
+ + +## ハイブリッド検索 + +### コード + +この例では、「Movie」クラス内で「history」という語に対してハイブリッド検索スコアが最も高いエントリを取得し、上位 5 件のタイトルと公開年を出力します。 + + + +### コードの説明 + +結果はハイブリッド検索スコアに基づいています。ハイブリッド検索は、BM25 とセマンティック / ベクトル検索の結果をブレンドします。 + +`limit` パラメーターは、返される結果の最大数を設定します。 + +`returnMetadata` パラメーターは、検索結果で返すメタデータを設定する文字列の配列を受け取ります。現在のクエリでは、結果のハイブリッドスコアである `score` を返します。 + +
+ 結果例 + +```text +Legends of the Fall 1994 +Hybrid score: 0.016 + +Hacksaw Ridge 2016 +Hybrid score: 0.016 + +A Beautiful Mind 2001 +Hybrid score: 0.015 + +The Butterfly Effect 2004 +Hybrid score: 0.015 + +Night at the Museum 2006 +Hybrid score: 0.012 +``` + +
+ + +## ご質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/30_filters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/30_filters.mdx new file mode 100644 index 000000000..8f97bd690 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/30_filters.mdx @@ -0,0 +1,55 @@ +--- +title: フィルター +description: マルチモーダル検索のフィルター +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/103_searches.mts'; + +フィルターを使用すると、検索結果をより正確に絞り込むことができます。プロパティだけでなくメタデータでもフィルターでき、`and` や `or` 条件を組み合わせてさらに結果を狭めることも可能です。 + +### コード + +この例では、クエリ「dystopian future」に類似するエントリーを "Movie" クラスから検索し、そのうち 2010 年以降に公開されたものに限定しています。上位 5 件のタイトルと公開年を出力します。 + + + +## コードの説明 + +このクエリは検索の [前述の例](./10_multimodal.mdx) と同じですが、フィルターが追加されています。`filters` パラメーターでは `filter` 名前空間を利用して条件を設定しています。現在のクエリでは、公開年が 2010 年より後のエントリーのみを結果に含めるようフィルターしています。 + +
+ 結果例 + +```text +Dune 2021 +Distance to query: 0.199 + +Tenet 2020 +Distance to query: 0.200 + +Mission: Impossible - Dead Reckoning Part One 2023 +Distance to query: 0.207 + +Onward 2020 +Distance to query: 0.214 + +Jurassic World Dominion 2022 +Distance to query: 0.216 +``` + +
+ + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/index.mdx new file mode 100644 index 000000000..483eccbce --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/103_mm_searches/index.mdx @@ -0,0 +1,26 @@ +--- +title: 検索を実行する +description: マルチモーダル検索の概要 +--- + + + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/10_setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/10_setup.mdx new file mode 100644 index 000000000..bfdbf0787 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/10_setup.mdx @@ -0,0 +1,40 @@ +--- +title: "RAG:概要" +description: マルチモーダル RAG の設定 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/102_collection.mts'; + +### 目的 + +検索拡張生成 ( RAG ) は、セマンティック検索の検索能力と、大規模言語モデルなどの AI モデルの生成能力を組み合わせる方法です。これにより、Weaviate インスタンスからオブジェクトを検索し、その結果に基づいて出力を生成できます。 + +### セットアップ + +コレクションを作成するときに、次のように `generative` パラメーターを指定しました。 + + + +これは、検索で取得したオブジェクトを基に出力を生成するための生成モジュールを選択します。ここでは `cohere` モジュールと、`command` ファミリーの大規模言語モデルを使用しています。 + +以前にベクトライザー モジュールで行ったように、生成モジュールの提供元から API キーを取得する必要があります。今回は Cohere の API キーが必要です。 + +### RAG クエリ + + RAG クエリは、Weaviate では「generative クエリ」とも呼ばれます。これらの機能には、コレクションオブジェクトの `generate` サブモジュールからアクセスできます。 + +各 generative クエリは通常の検索クエリに加えて動作し、取得された各オブジェクトに対して RAG クエリを実行します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/20_single_prompt.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/20_single_prompt.mdx new file mode 100644 index 000000000..f393970c2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/20_single_prompt.mdx @@ -0,0 +1,57 @@ +--- +title: "「シングルプロンプト」生成" +description: "マルチモーダル RAG のシングルプロンプト" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/104_rag.mts'; + +「シングルプロンプト」生成では、取得した各オブジェクトに対して RAG クエリを実行します。これは、同じプロンプトを用いて各オブジェクトを個別に変換したい場合に便利です。 + +### コード + +この例では、[国際宇宙ステーションの画像](https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/International_Space_Station_after_undocking_of_STS-132.jpg/440px-International_Space_Station_after_undocking_of_STS-132.jpg)との類似度に基づいて「 Movie 」内のエントリーを検索します。その後、大規模言語モデルに各映画のタイトルをフランス語へ翻訳するよう指示します。 + +結果はそれぞれコンソールに出力されます。 + + + +## コードの解説 + +`singlePrompt` パラメーターには、中括弧を用いて 1 つ以上のプロパティを渡す必要があります。ここでは `"... {title} ..."` として `title` プロパティを各取得オブジェクトから大規模言語モデルへ渡すように指定しています。 + +
+ 例の結果 + +```text +Interstellar +Interstellaire +Gravity +Gravité +Arrival +Arrivée +Armageddon +Armageddon +Godzilla +Godzilla +``` + +
+ +### レスポンスオブジェクト + +各レスポンスオブジェクトは通常の検索クエリの結果と似ていますが、追加で `generated` 属性が含まれます。この属性には、各オブジェクトに対して生成された出力が格納されます。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/30_grouped_task.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/30_grouped_task.mdx new file mode 100644 index 000000000..e143c6b68 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/30_grouped_task.mdx @@ -0,0 +1,58 @@ +--- +title: "'Grouped task' 生成" +description: マルチモーダル RAG 向け Grouped Task +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/104_rag.mts'; + +'grouped task' 生成では、取得したオブジェクトの集合に対して RAG クエリを実行します。1 つのプロンプトでオブジェクト全体をまとめて変換したい場合に便利です。 + +### コード + +この例では、「 MovieMM 」から、国際宇宙ステーションの画像と類似するエントリーを検索します。その後、大規模言語モデルに対して、それらのエントリー間の共通点を見つけるよう指示します。 + +各結果はコンソールに出力されます。 + + + +## コードの解説 + +`groupedTask` クエリでは、プロンプトをそのまま `groupedTask` パラメーターに渡すだけで構いません。これにより Weaviate は次の情報を大規模言語モデルに渡します。 +- すべての取得オブジェクトの text プロパティ +- プロンプト + +
+ 結果例 + +```text +Interstellar +Gravity +Arrival +Armageddon +Godzilla +These movies all involve space exploration, extraterrestrial beings, or catastrophic events threatening Earth. They all deal with themes of survival, human ingenuity, and the unknown mysteries of the universe. +``` + +
+ +### オプションパラメーター + +使用するプロパティのリストを `groupedProperties` パラメーターとして渡すこともできます。これにより、大規模言語モデルに渡すデータ量を減らし、不要なプロパティを省くことができます。 + +### レスポンスオブジェクト + +`groupedTask` パラメーター付きの RAG クエリは、追加の `generated` 属性を持つレスポンスを返します。この属性には、オブジェクト集合に対して生成された出力が格納されます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/index.mdx new file mode 100644 index 000000000..5efebbc33 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/104_mm_rag/index.mdx @@ -0,0 +1,26 @@ +--- +title: LLM と Weaviate ( RAG ) +description: マルチモーダル 検索拡張生成( RAG )の概要 +--- + + + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/900_next_steps.mdx new file mode 100644 index 000000000..7ac554d5f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/900_next_steps.mdx @@ -0,0 +1,7 @@ +--- +title: 次のステップ +--- + +import IntroNextSteps from '../_snippets/intro_next_steps_js.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/101_connect.mts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/101_connect.mts new file mode 100644 index 000000000..1aecc4488 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/101_connect.mts @@ -0,0 +1,171 @@ +// DockerInstantiation // WCDInstantiation // WCDAPIKeyInstantiation // DockerInstantiation // DockerAPIKeyInstantiation // TryFinallyCloseDemo +import weaviate, { WeaviateClient } from "weaviate-client"; +let client: WeaviateClient; +// END DockerInstantiation // END WCDInstantiation // END WCDAPIKeyInstantiation // END DockerInstantiation // END DockerAPIKeyInstantiation // END TryFinallyCloseDemo + + +// WCDInstantiation + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string, { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), +}) + +// END WCDInstantiation + +client.close() + +// WCDAPIKeyInstantiation + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string, { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-VoyageAI-Api-Key': process.env.VOYAGEAI_API_KEY as string, // Replace with your inference API key + } +}) +// END WCDAPIKeyInstantiation + +client.close() + +// DockerInstantiation + +client = await weaviate.connectToLocal() +// END DockerInstantiation + +client.close() + +// DockerAPIKeyInstantiation + +client = await weaviate.connectToLocal({ + host: '...', + headers: { + 'X-VoyageAI-Api-Key': process.env.VOYAGEAI_APIKEY as string, // Replace with your inference API key + } +}) +// END DockerAPIKeyInstantiation + +// PollLiveness +if (await client.isLive()) { + // Run operations with the client if it is live +} +// END PollLiveness + + +// GetMeta +console.log(await client.getMeta()) +// END GetMeta + + +const outputString = +// OutputGetMeta +{ + hostname: 'http://[::]:8080', + modules: { + 'backup-gcs': { + bucketName: 'weaviate-wcs-prod-cust-europe-west3-workloads-backups', + rootName: '55a78146-dae1-4609-90ce-556db01f4a61' + }, + 'generative-anyscale': { + documentationHref: 'https://docs.anyscale.com/endpoints/overview', + name: 'Generative Search - Anyscale' + }, + 'generative-aws': { + documentationHref: 'https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html', + name: 'Generative Search - AWS' + }, + 'generative-cohere': { + documentationHref: 'https://docs.cohere.com/reference/chat', + name: 'Generative Search - Cohere' + }, + 'generative-mistral': { + documentationHref: 'https://docs.mistral.ai/api/', + name: 'Generative Search - Mistral' + }, + 'generative-openai': { + documentationHref: 'https://platform.openai.com/docs/api-reference/completions', + name: 'Generative Search - OpenAI' + }, + 'generative-google': { + documentationHref: 'https://cloud.google.com/vertex-ai/docs/generative-ai/chat/test-chat-prompts', + name: 'Generative Search - Google' + }, + 'multi2vec-google': { + documentationHref: 'https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-multimodal-embeddings', + name: 'Google Multimodal Module' + }, + 'qna-openai': { + documentationHref: 'https://platform.openai.com/docs/api-reference/completions', + name: 'OpenAI Question & Answering Module' + }, + 'ref2vec-centroid': {}, + 'reranker-cohere': { + documentationHref: 'https://txt.cohere.com/rerank/', + name: 'Reranker - Cohere' + }, + 'reranker-voyageai': { + documentationHref: 'https://docs.voyageai.com/reference/reranker-api', + name: 'Reranker - VoyageAI' + }, + 'text2vec-aws': { + documentationHref: 'https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html', + name: 'AWS Module' + }, + 'text2vec-cohere': { + documentationHref: 'https://docs.cohere.ai/embedding-wiki/', + name: 'Cohere Module' + }, + 'text2vec-huggingface': { + documentationHref: 'https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task', + name: 'Hugging Face Module' + }, + 'text2vec-jinaai': { + documentationHref: 'https://jina.ai/embeddings/', + name: 'JinaAI Module' + }, + 'text2vec-openai': { + documentationHref: 'https://platform.openai.com/docs/guides/embeddings/what-are-embeddings', + name: 'OpenAI Module' + }, + 'text2vec-google': { + documentationHref: 'https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings', + name: 'Google Module' + }, + 'text2vec-voyageai': { + documentationHref: 'https://docs.voyageai.com/docs/embeddings', + name: 'VoyageAI Module' + } + }, + version: '1.25.5' +} +// END OutputGetMeta + + + +client.close() + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string, + { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-VoyageAI-Api-Key': process.env.VOYAGEAI_API_KEY as string, // Replace with your inference API key + } + } +) + +// TryFinallyCloseDemo + +// Instantiate your client (not shown). e.g.: +// client = weaviate.connectToWeaviateCloud(...) or +// client = weaviate.connectToLocal(...) + +try { + if (await client.isLive()) { + // Work with the client here + // ... + } +} finally { // This will always be executed, even if an exception is raised + client.close() // Close the connection & release resources +} +// END TryFinallyCloseDemo diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/102_collection.mts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/102_collection.mts new file mode 100644 index 000000000..0cfe1d6b3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/102_collection.mts @@ -0,0 +1,210 @@ +import { promises as fs } from 'fs'; +import { join } from 'path'; +import AdmZip from 'adm-zip'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; +import 'dotenv/config' + +// CreateMovieCollection // SubmoduleImport // BatchImportData +import weaviate from "weaviate-client"; +// END BatchImportData // END CreateMovieCollection // END SubmoduleImport +// CreateMovieCollection // SubmoduleImport +import { WeaviateClient, configure, vectorizer, toBase64FromMedia } from "weaviate-client"; +// END CreateMovieCollection // END SubmoduleImport + + +// BatchImportData +import { generateUuid5 } from "weaviate-client"; + +// END BatchImportData + +// BatchImportData +let client: WeaviateClient; +// CreateMovieCollection // END BatchImportData + +// END CreateMovieCollection + +const weaviateURL = process.env.WEAVIATE_URL as string; +const weaviateApikey = process.env.WEAVIATE_API_KEY as string; +const cohereApiKey = process.env.COHERE_API_KEY as string; +const voyageApiKey = process.env.VOYAGEAI_API_KEY as string; + + + +// client = await weaviate.connectToWeaviateCloud(weaviateURL, { +// authCredentials: new weaviate.ApiKey(weaviateApikey), +// } +// ) +// CreateMovieCollection +// Instantiate your client (not shown). e.g.: +// const requestHeaders = {'X-VoyageAI-Api-Key': process.env.VOYAGEAI_API_KEY as string,} +// client = weaviate.connectToWeaviateCloud(..., headers: requestHeaders) or +// client = weaviate.connectToLocal(..., headers: requestHeaders) + +// END CreateMovieCollection + +const requestHeaders = { 'X-VoyageAI-Api-Key': voyageApiKey, + 'X-Cohere-Api-Key': cohereApiKey + } + + +client = await weaviate.connectToWeaviateCloud(weaviateURL, { + authCredentials: new weaviate.ApiKey(weaviateApikey), + headers: requestHeaders +} +) +// END CreateMovieCollection + +// Actual instantiation + +client.collections.delete("Movie") + +// CreateMovieCollection +await client.collections.create({ + name: "Movie", + properties: [ + { name: "title", dataType: configure.dataType.TEXT }, + { name: "overview", dataType: configure.dataType.TEXT }, + { name: "vote_average", dataType: configure.dataType.NUMBER }, + { name: "genre_ids", dataType: configure.dataType.INT_ARRAY }, + { name: "release_date", dataType: configure.dataType.DATE }, + { name: "tmdb_id", dataType: configure.dataType.INT }, + { name: "poster", dataType: configure.dataType.BLOB } + ], + // Define the vectorizer module + vectorizers: vectorizer.multi2VecVoyageAI({ + imageFields: [{ name: "poster", weight: 0.9 }], + textFields: [{ name: "title", weight: 0.1 }], + model: "voyage-multimodal-3" + }), + // Define the generative module + generative: configure.generative.cohere(), + // END generativeDefinition // CreateMovieCollection +}) + +client.close() +// END CreateMovieCollection + +const weaviateURL = process.env.WEAVIATE_URL as string +const weaviateKey = process.env.WEAVIATE_API_KEY as string +const cohereKey = process.env.COHERE_API_KEY as string +const voyageaiKey = process.env.VOYAGEAI_API_KEY as string + +client = await weaviate.connectToWeaviateCloud(weaviateURL, { + authCredentials: new weaviate.ApiKey(weaviateKey), + headers: { + 'X-VoyageAI-Api-Key': voyageaiKey, // Replace with your inference API key + 'X-Cohere-Api-Key': cohereKey, // Replace with your inference API key + } +}) + +// BatchImportData + +// Instantiate your client (not shown). e.g.: +// client = weaviate.connectToWeaviateCloud(...) or +// client = weaviate.connectToLocal(...) + +// END BatchImportData + +// BatchImportData +const dataUrl = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json" +const textResponse = await fetch(dataUrl) +const data = await textResponse.json() + +// Get current file's directory +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); +const imgDir = join(__dirname, "images"); + + +// Create directory if it doesn't exist +await fs.mkdir(imgDir, { recursive: true }); + +// Download images +const postersUrl = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024_posters.zip"; +const postersPath = join(imgDir, "movies_data_1990_2024_posters.zip"); + +const response = await fetch(postersUrl); +if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); +} +const arrayBuffer = await response.arrayBuffer(); +const buffer = Buffer.from(arrayBuffer); + +// Write the zip file +await fs.writeFile(postersPath, buffer); + +// Unzip the files +const zip = new AdmZip(postersPath); +zip.extractAllTo(imgDir, true); + +// Get the collection +const movies = client.collections.use("Movie") + +// Set a counter and initialize Weaviate Object +let itemsToInsert: Object[] = [] +let counter = 0; + +// Iterate through data +for (const key of Object.keys(data['title'])) { + + counter++; + if (counter % 20 == 0) + console.log(`Import: ${counter}`) + // END Iterate through data // END BatchImportData + // BatchImportData + + let genreIds: [] + + // Format genre_ids and release_date + const parsedArray = JSON.parse(data['genre_ids'][key]); + genreIds = parsedArray.map((item: string) => parseInt(item, 10)); + let releaseDate = new Date(data['release_date'][key]) + + const imgPath = join(imgDir, `${data['id'][key]}_poster.jpg`) + // Convert poster to base64 + const posterBase64 = await toBase64FromMedia(imgPath) + + // Build the object payload + let movieObject = { + title: data['title'][key], + overview: data['overview'][key], + vote_average: data['vote_average'][key], + genre_ids: genreIds, + release_date: releaseDate, + tmdb_id: data['id'][key], + poster: posterBase64 + } + // Insert + let objectToInsert = { + properties: movieObject, + uuid: generateUuid5(data['title'][key]) + } + + // Add object to batching array + itemsToInsert.push(objectToInsert) + + if (itemsToInsert.length == 20) { + try { + const response = await movies.data.insertMany(itemsToInsert); + // END Insert + // Handle Errors // Insert + if (response.hasErrors) { + throw new Error("Error in batch import!"); + } + // END Insert // END Handle Errors + // Insert + console.log(`Successfully imported batch of ${itemsToInsert.length} items`); + itemsToInsert = []; + } catch (error) { + console.error('Error importing batch:', error); + } + } + // END BatchImportData // END Insert + // BatchImportData // Iterate through data + // ... other operations +} + + +client.close() +// END BatchImportData diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/103_searches.mts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/103_searches.mts new file mode 100644 index 000000000..19710f93d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/103_searches.mts @@ -0,0 +1,154 @@ +import 'dotenv/config' +// START-ANY +import weaviate, { WeaviateClient, WeaviateReturn } from "weaviate-client"; +let client: WeaviateClient; +let response: WeaviateReturn +// END-ANY + +client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL as string,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-VoyageAI-Api-Key': process.env.VOYAGEAI_API_KEY as string, // Replace with your inference API key + 'X-Cohere-Api-Key': process.env.COHERE_API_KEY as string, // Replace with your inference API key + + } + } +) + +// START-ANY + +// Instantiate your client (not shown). e.g.: +// const requestHeaders = {'X-VoyageAI-Api-Key': process.env.VOYAGEAI_API_KEY as string,} +// client = weaviate.connectToWeaviateCloud(..., headers: requestHeaders) or +// client = weaviate.connectToLocal(..., headers: requestHeaders) + +async function urlToBase64(imageUrl: string) { + const response = await fetch(imageUrl); + const arrayBuffer = await response.arrayBuffer(); + const content = Buffer.from(arrayBuffer); + return content.toString('base64'); +} +// END-ANY + +// MetadataMultimodalSearch // SinglePromptGeneration // MetadataSemanticSearch // MetadataBM25Search // MetadataHybridSearch // FilteredSemanticSearch + +// Get the collection +const movies = client.collections.use("Movie") + +// Perform query +const srcImgPath = "https://github.com/weaviate-tutorials/edu-datasets/blob/main/img/International_Space_Station_after_undocking_of_STS-132.jpg?raw=true" +const queryB64 = await urlToBase64(srcImgPath) +// END MetadataMultimodalSearch // END SinglePromptGeneration // END MetadataSemanticSearch // END MetadataBM25Search // END MetadataHybridSearch // END FilteredSemanticSearch + +// MetadataMultimodalSearch + +response = await movies.query.nearImage(queryB64, { + limit: 5, + returnMetadata: ['distance'], + returnProperties: ["title", "tmdb_id", "release_date", "poster"] + }, +) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year (note the release date is a datetime object) + console.log(`${item.properties.title} - ${item.properties.release_date}`) + // Print the distance of the object from the query + console.log(`Distance to query: ${item.metadata?.distance}`) +} + +client.close() +// END MetadataMultimodalSearch + +console.log("\n\n") + + +// MetadataSemanticSearch +response = await movies.query.nearText("red", { + limit: 5, + returnMetadata: ['distance'], + returnProperties: ["title", "tmdb_id", "release_date"] + }, +) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year (note the release date is a datetime object) + console.log(`${item.properties.title} - ${item.properties.release_date}`) + // Print the distance of the object from the query + console.log(`Distance to query: ${item.metadata?.distance}`) +} + +client.close() +// END MetadataSemanticSearch + +// MetadataBM25Search + +response = await movies.query.bm25("history", { + limit: 5, + returnMetadata: ['score'], +}, +) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year (note the release date is a datetime object) + console.log(`${item.properties.title} - ${item.properties.release_date}`) + // Print the distance of the object from the query + console.log(`BM25 score: ${item.metadata?.score}`) +} + +client.close() +// END MetadataBM25Search + + +console.log("\n\n") + +// client.connect() + +// MetadataHybridSearch + +response = await movies.query.hybrid("history", { + limit: 5, + returnMetadata: ['score'], + returnProperties: ["title", "tmdb_id", "release_date"] +}, +) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year (note the release date is a datetime object) + console.log(`${item.properties.title} - ${item.properties.release_date}`) + // Print the hybrid score of the object from the query + console.log(`Hybrid score: ${item.metadata?.score}`) +} + +client.close() +// END MetadataHybridSearch + + +console.log("\n\n") + +// client.connect() + +// FilteredSemanticSearch + +const filterTime = new Date(2010, 1, 1) + +response = await movies.query.nearText("dystopian future", { + limit: 5, + returnMetadata: ['distance'], + filters: movies.filter.byProperty("release_date").greaterThan(filterTime) + } +) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year (note the release date is a datetime object) + console.log(`${item.properties.title} - ${item.properties.release_date}`) + // Print the distance of the object from the query + console.log(`Distance to query: ${item.metadata?.distance}`) +} + +client.close() +// END FilteredSemanticSearch diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/104_rag.mts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/104_rag.mts new file mode 100644 index 000000000..a48450725 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/_snippets/104_rag.mts @@ -0,0 +1,88 @@ +import 'dotenv/config' +// START-ANY +import weaviate, { GenerativeReturn, WeaviateClient } from "weaviate-client"; +let client: WeaviateClient; +let response: GenerativeReturn +// END-ANY + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string, + { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-VoyageAI-Api-Key': process.env.VOYAGEAI_API_KEY as string, // Replace with your inference API key + } + } +) + +// START-ANY + +// Instantiate your client (not shown). e.g.: +// const requestHeaders = {'X-VoyageAI-Api-Key': process.env.VOYAGEAI_API_KEY as string,} +// client = weaviate.connectToWeaviateCloud(..., headers: requestHeaders) or +// client = weaviate.connectToLocal(..., headers: requestHeaders) + +async function urlToBase64(imageUrl: string) { + const response = await fetch(imageUrl); + const arrayBuffer = await response.arrayBuffer(); + const content = Buffer.from(arrayBuffer); + return content.toString('base64'); +} + +// END-ANY + +// SinglePromptGeneration // GroupedTaskGeneration +// Get the collection +const movies = client.collections.use("Movie") + +// Perform query +const srcImgPath = "https://github.com/weaviate-tutorials/edu-datasets/blob/main/img/International_Space_Station_after_undocking_of_STS-132.jpg?raw=true" +const queryB64 = await urlToBase64(srcImgPath) +// END SinglePromptGeneration // END GroupedTaskGeneration + +// SinglePromptGeneration + +response = await movies.generate.nearMedia(queryB64, "image",{ + // highlight-start + singlePrompt: "Translate this into French: {title}" + // highlight-end + }, { + limit: 5 +}) + +// Inspect the response +for (let item of response.objects) { + console.log(item.properties.title) + console.log(item.generated) +} + +client.close() +// END SinglePromptGeneration + + +console.log("\n\n") + + +// GroupedTaskGeneration + +response = await movies.generate.nearMedia(queryB64, "image",{ + // highlight-start + groupedTask: "What do these movies have in common?", + groupedProperties: ["title", "overview"] // Optional parameter; for reducing prompt length + // highlight-end + },{ + limit: 5 + } +) + +// Inspect the response +for (let item of response.objects) { + console.log('Title: ', item.properties.title) // Print the title +} + +// highlight-start +console.log(response.generated) // Print the generated text (the commonalities between them) +// highlight-end + +client.close() +// END GroupedTaskGeneration diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/index.md new file mode 100644 index 000000000..f9503de42 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_multimodal_data/index.md @@ -0,0 +1,23 @@ +--- +title: "101M マルチモーダル データの取り扱い" +description: Weaviate で多様なデータ統合のためにマルチモーダル データを扱う方法を学びます。 +sidebar_position: 102 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +このプロジェクトベースのコースでは、 Weaviate と映画データセットを用いてマルチモーダル データを扱う方法を学びます。 + +Weaviate のベクトライザー機能を使用し、テキストと画像データを意味で一緒に検索できるように保存・インデックスする手順を実践的に体験します。さらに、マルチモーダル検索手法やフィルターを使ってそのデータを検索する方法も学びます。また、 Weaviate の検索拡張生成 ( RAG ) 機能を利用し、取得したオブジェクトを基に出力を生成する方法についても学習します。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/10_client.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/10_client.mdx new file mode 100644 index 000000000..7a4c56e9d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/10_client.mdx @@ -0,0 +1,36 @@ +--- +title: Weaviate JavaScript/TypeScript クライアント +description: "効率的なデータアクセスと管理のために Weaviate JavaScript クライアントを設定します。" +--- + +## インストール + +最新の Weaviate TypeScript クライアントライブラリーは npm でインストールできます。クライアントライブラリーは Node v18 以降でテストされています。次のコマンドでインストールしてください: + +```bash +npm install weaviate-client +``` + +最新のメジャーバージョンは `v3` (例: `3.x.x`) です。バージョンは次のように確認できます: + +```bash +npm view weaviate-client version +``` + +## 基本的な使用方法 + +Weaviate クライアントライブラリーは次のようにインポートできます: + +```typescript +import weaviate, { generateUuid5, ApiKey } from "weaviate-client" +``` + +クライアントには、Weaviate とのやり取りを容易にするための補助関数 (例: `generateUuid5`, `ApiKey`) が用意されています。 + +次に、Weaviate インスタンスを作成して接続する方法を示します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx new file mode 100644 index 000000000..bed088509 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx @@ -0,0 +1,67 @@ +--- +title: "オプション 1: クラウド WCD インスタンス" +description: "スケーラブルなクラウドベースのデータプロジェクトのために WCS 上に Weaviate インスタンスを作成します。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../../_snippets/101_connect.ts'; + +ここでは、Weaviate Cloud ( WCD ) インスタンスを作成します。 WCD はクラウド上で稼働するフルマネージドの Weaviate インスタンスで、インストールやメンテナンスが不要なため、Weaviate を始める最適な方法です。 + +### WCD Console へのログイン + +[WCD Console](https://console.weaviate.cloud/) にアクセスし、ご自身の認証情報でログインしてください。まだアカウントをお持ちでない場合は、ログイン画面の Register here リンクからサインアップできます。 + +### Weaviate インスタンスの作成 + +コンソールの Dashboard から Create cluster ボタンをクリックします。表示された画面で次を設定してください。 + +- 「Free sandbox」タブを選択 +- クラスター名を入力 +- 「Enable authentication」を「Yes」に設定 + +Create ボタンをクリックすると、Weaviate インスタンスが作成されます。完了まで数分かかります。 + +### Weaviate インスタンス情報の取得 + +インスタンスが作成されると、Details ボタンをクリックして詳細を確認できます。ここでクラスター URL と API キーを取得してください。 + +これらの情報は Weaviate インスタンスへ接続する際に必要です。 + +### WCD インスタンスへの接続 + +Weaviate Cloud ( WCD ) インスタンスへ接続するには、クラスター URL と API キーが必要です。これらは WCD Console で確認できます。 + +`connectToWeaviateCloud()` 関数を使用して WCD インスタンスへ接続します。 + + + +#### 推論 API キーの設定 + +一部の Weaviate モジュールでは、データのベクトル化や大規模言語モデル連携のために推論 API を利用できます。Weaviate 起動時にこれらのサービスの API キーを渡すことが可能です。 + +この講座では OpenAI を使用するため、下記のように `headers: {"X-OpenAI-Api-Key": }` を通じて OpenAI API キーを設定します。 + + + +:::note 次のステップ +これを完了したら、次のページ [オプション 2: ローカル Weaviate インスタンス](./20_create_docker.mdx) をスキップし、[Weaviate との通信](../30_communicate.mdx) に進んでください。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx new file mode 100644 index 000000000..ff62f9517 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx @@ -0,0 +1,90 @@ +--- +title: "オプション 2: ローカル Docker インスタンス" +description: "Docker を使用して Weaviate をセットアップし、迅速かつカスタマイズ可能なローカルデプロイを行います。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../../_snippets/101_connect.ts'; + +:::note すでに Weaviate インスタンスを作成しましたか? +すでに Weaviate の [クラウドインスタンスを作成](./10_create_wcs.mdx) している場合は、このページをスキップして [Weaviate との通信](../30_communicate.mdx) に進めます。 +::: + +ここでは、Docker を使用して Weaviate インスタンスを作成します。 + +### docker-compose ファイルのダウンロードと実行 + +お使いのマシンに Docker をインストールしてください。公式の [Docker インストールガイド](https://docs.docker.com/get-docker/) を参照することをおすすめします。 + +新しいディレクトリを作成し、ターミナルでそのディレクトリに移動します。次に `docker-compose.yml` というファイルを作成し、以下の内容を追加します。 + +```yaml +--- +version: '3.4' +services: + weaviate_anon: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_API_BASED_MODULES: 'true' + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node1' +... +``` + +### Weaviate インスタンスの作成 + +次のコマンドを実行して Weaviate を起動します。 + +```bash +docker compose up +``` + +### Weaviate インスタンスの詳細 + +インスタンスが作成されると、`http://localhost:8080` でアクセスできます。 + +### Weaviate インスタンスへの接続 + +Weaviate インスタンスに接続するには、`connectToLocal()` 関数を使用します。 + + + +#### 推論 API キーの提供 + +一部の Weaviate モジュールでは、データのベクトル化や大規模言語モデル統合のために推論 API を使用できます。これらのサービスの API キーは、インスタンス作成時に Weaviate に渡すことができます。 + +このコースでは OpenAI を使用するため、以下のように `headers: {"X-OpenAI-Api-Key": }` を通じて OpenAI API キーを Weaviate に提供します。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/index.mdx new file mode 100644 index 000000000..ffdb057ec --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/20_create_instance/index.mdx @@ -0,0 +1,19 @@ +--- +title: Weaviate インスタンスの作成 +description: "テキスト データ アプリケーション向けに最適化された新しい Weaviate インスタンスを作成します。" +--- + +このユニットでは、Weaviate Cloud (WCD) インスタンスを作成するか、ローカル Docker インスタンスを作成するかを選択できます。 + +- [Weaviate Cloud (WCD) インスタンスを作成](./10_create_wcs.mdx) + - インストールやメンテナンスを気にせずにマネージドサービスを利用したい場合。 +- [ローカル Docker インスタンスを作成](./20_create_docker.mdx) + - ご自身のマシンで Weaviate を実行したい、またはインストールとメンテナンスを完全に管理したい場合。 + +どちらの方法でも本コースを進めることができます。迷った場合は、まず WCD インスタンスから始めることをおすすめします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/30_communicate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/30_communicate.mdx new file mode 100644 index 000000000..cc4a31af4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/30_communicate.mdx @@ -0,0 +1,64 @@ +--- +title: Weaviate との通信 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/101_connect.ts'; + +ここでは、 TypeScript クライアント ライブラリを使用して Weaviate と通信する基本的な操作を行います。 + +### Weaviate のステータス確認 + +`isLive` 関数を使用して、 Weaviate インスタンスが起動しているかどうかを確認できます。 + + + +### サーバーメタ情報の取得 + +`getMeta` 関数を使用して、 Weaviate インスタンスのメタ情報を取得できます。 + + + +これにより、サーバーのメタ情報がコンソールに出力されます。出力は次のようになります。 + +
+ getMeta() の出力 + + +
+ +### 接続の終了 + +Weaviate クライアントの使用が終わったら、接続を終了する必要があります。これによりリソースが解放され、接続が正常にクローズされます。 + +ベスト プラクティスとして `try`-`finally` ブロックの使用を推奨します。簡潔さを保つため、以降のコード スニペットでは `try`-`finally` ブロックを省略します。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/index.mdx new file mode 100644 index 000000000..5ad70398b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/101_setup_weaviate/index.mdx @@ -0,0 +1,24 @@ +--- +title: Weaviate のセットアップ +description: "テキスト データ プロジェクト向けに Weaviate をセットアップする方法を学び、環境の設定と構成を行います。" +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/10_preparation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/10_preparation.mdx new file mode 100644 index 000000000..6d052d8b7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/10_preparation.mdx @@ -0,0 +1,41 @@ +--- +title: 準備 +description: "Weaviate で最適化された保存と検索のためにテキストデータを準備します。" +--- + +このセクションでは、 OpenAI API を使用してテキストデータを埋め込み、映画データセットを Weaviate インスタンスに取り込みます。 + +### Weaviate インスタンス + +Weaviate インスタンスがセットアップされていることを確認してください。[インスタンスを作成](../101_setup_weaviate/20_create_instance/index.mdx)し、接続できる状態になっている必要があります。 + +### OpenAI キー + +このチュートリアルを進めるには OpenAI API キーが必要です。お持ちでない場合は、[OpenAI の Web サイト](https://openai.com/) でアカウントを作成し、API キーを発行してください。 + + + +### ソースデータ + +ここでは、 [TMDB](https://www.themoviedb.org/) から取得した映画データセットを使用します。データセットはこの [GitHub リポジトリ](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json) にあり、1990 年から 2024 年までに公開された約 700 本の映画の書誌情報が含まれています。 + +
+ サンプルデータを表示 + +| | backdrop_path | genre_ids | id | original_language | original_title | overview | popularity | poster_path | release_date | title | video | vote_average | vote_count | +|---:|:---------------------------------|:----------------|-----:|:--------------------|:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------:|:---------------------------------|:---------------|:----------------------------|:--------|---------------:|-------------:| +| 0 | /3Nn5BOM1EVw1IYrv6MsbOS6N1Ol.jpg | [14, 18, 10749] | 162 | en | Edward Scissorhands | A small suburban town receives a visit from a castaway unfinished science experiment named Edward. | 45.694 | /1RFIbuW9Z3eN9Oxw2KaQG5DfLmD.jpg | 1990-12-07 | Edward Scissorhands | False | 7.7 | 12305 | +| 1 | /sw7mordbZxgITU877yTpZCud90M.jpg | [18, 80] | 769 | en | GoodFellas | The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway. | 57.228 | /aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg | 1990-09-12 | GoodFellas | False | 8.5 | 12106 | +| 2 | /6uLhSLXzB1ooJ3522ydrBZ2Hh0W.jpg | [35, 10751] | 771 | en | Home Alone | Eight-year-old Kevin McCallister makes the most of the situation after his family unwittingly leaves him behind when they go on Christmas vacation. But when a pair of bungling burglars set their sights on Kevin's house, the plucky kid stands ready to defend his territory. By planting booby traps galore, adorably mischievous Kevin stands his ground as his frantic mother attempts to race home before Christmas Day. | 3.538 | /onTSipZ8R3bliBdKfPtsDuHTdlL.jpg | 1990-11-16 | Home Alone | False | 7.4 | 10599 | +| 3 | /vKp3NvqBkcjHkCHSGi6EbcP7g4J.jpg | [12, 35, 878] | 196 | en | Back to the Future Part III | The final installment of the Back to the Future trilogy finds Marty digging the trusty DeLorean out of a mineshaft and looking for Doc in the Wild West of 1885. But when their time machine breaks down, the travelers are stranded in a land of spurs. More problems arise when Doc falls for pretty schoolteacher Clara Clayton, and Marty tangles with Buford Tannen. | 28.896 | /crzoVQnMzIrRfHtQw0tLBirNfVg.jpg | 1990-05-25 | Back to the Future Part III | False | 7.5 | 9918 | +| 4 | /3tuWpnCTe14zZZPt6sI1W9ByOXx.jpg | [35, 10749] | 114 | en | Pretty Woman | When a millionaire wheeler-dealer enters a business contract with a Hollywood hooker Vivian Ward, he loses his heart in the bargain. | 97.953 | /hVHUfT801LQATGd26VPzhorIYza.jpg | 1990-03-23 | Pretty Woman | False | 7.5 | 7671 | + +
+ +次に、対応するオブジェクトコレクションを作成し、データをインポートします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/20_create_collection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/20_create_collection.mdx new file mode 100644 index 000000000..b7763f1e7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/20_create_collection.mdx @@ -0,0 +1,85 @@ +--- +title: コレクションの作成 +description: "構造化されたテキストデータを保存・管理するために Weaviate でテキストコレクションを作成します。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/102_collection.ts'; + + Weaviate はデータを「コレクション」に保存します。コレクションとは、同じデータ構造を共有するオブジェクトの集合です。映画データベースでは、映画のコレクション、俳優のコレクション、レビューのコレクションなどを持つことができます。 + +ここでは映画のコレクションを作成します。 + +## コード + +この例では、映画データ用のコレクションを作成しています。 + + + +各コレクション定義には名前が必須です。その後、この例のように追加のパラメーターを定義できます。 + +## コードの解説 + +### プロパティ + +プロパティとは、コレクションに保存したいオブジェクトの属性です。各プロパティには名前とデータ型があります。 + +映画データベースでは、`title`、`release_date`、`genre_ids` などのプロパティがあり、データ型として `TEXT`(文字列)、`DATE`(日付)、`INT`(整数)などを使用します。また、`genre_ids` のように整数の配列を持つこともできます。 + +#### 自動スキーマ + + Weaviate は [スキーマを自動推論](/weaviate/config-refs/collections.mdx#auto-schema) できます。ただし、より良い制御と予期しない動作を避けるために、プロパティを明示的に定義することを推奨します。 + +### ベクトライザーの設定 + +ベクトルを自分で指定しない場合、 Weaviate は指定された ベクトライザー を使用してデータからベクトル埋め込みを生成します。 + +このコード例では、`text2vec-openai` モジュールをデフォルト設定で指定しています。 + + + +### 生成設定 + +コレクションを生成モデル(例: 大規模言語モデル)で利用したい場合は、生成モジュールを指定する必要があります。 + +このコード例では、`openai` モジュール(正式名称は `generative-openai`)をデフォルト設定で指定しています。 + + + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +### TypeScript の名前付きインポート + +このコード例では、`vectorizer` や `configure` などの名前付きインポートを使用しています。これらは `weaviate` モジュールで定義されており、コレクション定義時に利用されます。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/30_import_data.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/30_import_data.mdx new file mode 100644 index 000000000..4ae1fb5bb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/30_import_data.mdx @@ -0,0 +1,94 @@ +--- +title: データのインポート +description: "Weaviate のテキストコレクションへデータをインポートして、データ処理を効率化します。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/102_collection.ts'; + +## コード + +この例では、映画データをコレクションにインポートします。 + + + +コードの概要: +- ソースデータを読み込み、コレクションを取得 +- データをループ処理してバッチャーにオブジェクトを追加 +- インポートエラーを出力 + +## コードの解説 + +### 準備 + +requests ライブラリを使用して、今回の場合は JSON ファイルからデータを読み込みます。 + +その後 `client.collections.get` でコレクションオブジェクトを作成し、コレクションとやり取りできるようにします。 + +### データの反復処理 + +`for` ループと `Object.keys()` を組み合わせて、JSON 内の要素を反復処理します。反復中はカウンター変数を増やし、オブジェクトをバッチ単位で一括挿入できるようにします。 + + + + +### オブジェクトへのデータ追加 + +#### データ型の変換とオブジェクト構築 + +データを文字列から Weaviate に適した型へ変換します。たとえば `release_date` は `Date` オブジェクトに、`genre_ids` は整数のリストに変換します。 + + + +正しい形式に変換した後、プロパティをまとめてオブジェクトを構築し、Weaviate への挿入に備えます。 + +#### データのバルク挿入 + +次に、Weaviate の `generateUuid5` で生成した uuid と、先ほど定義したプロパティを含むオブジェクトを作成します。このオブジェクトを `itemsToInsert` にプッシュし、バッチが準備できたら `insertMany()` でまとめて挿入します。 + + + +### エラー処理 + +バルク挿入でエラーが発生した場合、その原因を把握する必要があります。対処方法としては例外を発生させるなどがありますが、この例では単にインポート時のエラーを出力しています。 + + + +## ベクトル生成元 + +バッチャーがキューを Weaviate に送信すると、オブジェクトがコレクション(今回は映画コレクション)に追加されます。 + +このコレクションにはベクトライザーモジュールが設定されており、ここではベクトルを明示的に指定していません。そのため、Weaviate は指定されたベクトライザーを使ってデータからベクトル埋め込みを生成します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/index.mdx new file mode 100644 index 000000000..6ff992854 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/102_text_collections/index.mdx @@ -0,0 +1,24 @@ +--- +title: データベースへのデータ投入 +description: "Weaviate でテキストコレクションを構築し、データを整理・検索する方法を学びます。" +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/10_semantic.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/10_semantic.mdx new file mode 100644 index 000000000..eb179fb46 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/10_semantic.mdx @@ -0,0 +1,67 @@ +--- +title: セマンティック検索 +description: "Weaviate でセマンティック検索を使用して、正確で関連性の高いテキスト結果を取得します。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/103_searches.ts'; + +Weaviate では、アイテムの意味に基づいて類似するアイテムを検索するセマンティック検索を実行できます。これは、データベース内のアイテムのベクトル埋め込みを比較することで実現します。 + +### コード + +この例では、"Movie" 内からクエリ "dystopian future" に類似するエントリーを検索し、上位 5 件のタイトルと公開年を出力します。 + + + +## コードの説明 + +結果は、クエリとデータベースオブジェクトのテキスト間のベクトル埋め込みの類似度に基づいています。この例では、埋め込みはベクトライザーモジュールによって生成されています。 + +ここでの `limit` パラメーターは、返される結果の最大数を設定します。 + +`returnMetadata` パラメーターは文字列の配列を受け取り、検索結果に含めるメタデータを指定します。現在のクエリでは、クエリとのベクトル距離を返します。 + +
+ 例: 結果 + +```text +In Time 2011 +Distance to query: 0.179 + +Gattaca 1997 +Distance to query: 0.180 + +I, Robot 2004 +Distance to query: 0.182 + +Mad Max: Fury Road 2015 +Distance to query: 0.190 + +The Maze Runner 2014 +Distance to query: 0.193 +``` + +
+ +### レスポンスオブジェクト + +返されるオブジェクトはカスタムクラスのインスタンスです。その `objects` 属性は検索結果のリストで、各オブジェクトは別のカスタムクラスのインスタンスです。 + +各オブジェクトには次の特性があります: +- BLOB データ型を除き、すべてのプロパティと UUID がデフォルトで含まれます。 +- 参照、メタデータ、ベクトルなど、その他の情報はデフォルトでは含まれません。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/20_keyword_hybrid.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/20_keyword_hybrid.mdx new file mode 100644 index 000000000..85bf9ceda --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/20_keyword_hybrid.mdx @@ -0,0 +1,105 @@ +--- +title: キーワード & ハイブリッド検索 +description: "Weaviate で効率的にデータを取得するために、キーワード検索とハイブリッド検索を組み合わせます。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/103_searches.ts'; + +キーワード( BM25 )検索を実行してキーワード類似度に基づいてアイテムを検索したり、BM25 とセマンティック/ ベクトル 検索を組み合わせたハイブリッド検索を実行したりできます。 + +## キーワード検索 + +### コード + +この例では、"Movie" クラス内で「history」という語に対して最も高いキーワード検索スコアを持つエントリを取得し、上位 5 件のタイトルと公開年を表示します。 + + + +### コードの解説 + +結果は [BM25f](https://en.wikipedia.org/wiki/Okapi_BM25) アルゴリズムを用いたキーワード検索スコアに基づいています。 + +`limit` パラメーターは、返される結果の最大件数を指定します。 + +`returnMetadata` パラメーターには文字列の配列を渡し、検索結果に含めるメタデータを指定します。ここでは BM25 スコアである `score` を返しています。 + +
+ 例の結果 + +```text +American History X 1998 +BM25 score: 2.707 + +A Beautiful Mind 2001 +BM25 score: 1.896 + +Legends of the Fall 1994 +BM25 score: 1.663 + +Hacksaw Ridge 2016 +BM25 score: 1.554 + +Night at the Museum 2006 +BM25 score: 1.529 +``` + +
+ + +## ハイブリッド検索 + +### コード + +この例では、"Movie" クラス内で「history」という語に対して最も高いハイブリッド検索スコアを持つエントリを取得し、上位 5 件のタイトルと公開年を表示します。 + + + +### コードの解説 + +結果はハイブリッド検索スコアに基づいています。ハイブリッド検索は BM25 とセマンティック/ ベクトル 検索の結果を組み合わせます。 + +`limit` パラメーターは、返される結果の最大件数を指定します。 + +`returnMetadata` パラメーターには文字列の配列を渡し、検索結果に含めるメタデータを指定します。ここではハイブリッドスコアである `score` を返しています。 + +
+ 例の結果 + +```text +Legends of the Fall 1994 +Hybrid score: 0.016 + +Hacksaw Ridge 2016 +Hybrid score: 0.016 + +A Beautiful Mind 2001 +Hybrid score: 0.015 + +The Butterfly Effect 2004 +Hybrid score: 0.015 + +Night at the Museum 2006 +Hybrid score: 0.012 +``` + +
+ + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/30_filters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/30_filters.mdx new file mode 100644 index 000000000..aa9b6b81b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/30_filters.mdx @@ -0,0 +1,55 @@ +--- +title: フィルター +description: "Weaviate のテキスト検索にフィルターを適用して、クエリ結果を絞り込みます。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/103_searches.ts'; + +フィルターを使用すると、検索結果を正確に絞り込むことができます。プロパティだけでなくメタデータでもフィルターでき、`and` または `or` 条件を組み合わせることでさらに結果を絞り込めます。 + +### コード + +この例では、クエリ "dystopian future" と類似した "Movie" クラスのエントリーのうち、2020 年以降に公開されたものだけを検索します。上位 5 件のタイトルと公開年を表示します。 + + + +## コードの説明 + +このクエリは [前述](./10_semantic.mdx) のセマンティック検索と同じですが、フィルターが追加されています。`filters` パラメーターでは `filter` ネームスペースを利用して条件を指定しています。現在のクエリは、公開年が 2010 年より後のものだけに結果をフィルターしています。 + +
+ 例: 取得結果 + +```text +Dune 2021 +Distance to query: 0.199 + +Tenet 2020 +Distance to query: 0.200 + +Mission: Impossible - Dead Reckoning Part One 2023 +Distance to query: 0.207 + +Onward 2020 +Distance to query: 0.214 + +Jurassic World Dominion 2022 +Distance to query: 0.216 +``` + +
+ + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/index.mdx new file mode 100644 index 000000000..e1625c847 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/103_text_searches/index.mdx @@ -0,0 +1,24 @@ +--- +title: 検索の実行 +description: "JavaScript アプリケーション向け Weaviate のテキスト検索機能を探求します." +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/10_setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/10_setup.mdx new file mode 100644 index 000000000..f1cc7b3aa --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/10_setup.mdx @@ -0,0 +1,40 @@ +--- +title: "RAG: 概要" +description: "Weaviate でテキスト RAG をセットアップし、信頼性の高い質問応答を実現します。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/102_collection.ts'; + +### 動機 + +検索拡張生成 ( RAG ) は、セマンティック検索の検索機能と、大規模言語モデルなどの AI モデルの生成機能という両方の長所を組み合わせる手法です。これにより、Weaviate インスタンスからオブジェクトを取得し、そのオブジェクトに基づいて出力を生成できます。 + +### セットアップ + +コレクションを作成するときに、次のように `generative` パラメーターを指定しました。 + + + +これにより、取得したオブジェクトを基に出力を生成するための生成モジュールが選択されます。この例では `openai` モジュールと、`GPT` 系列の大規模言語モデルを使用しています。 + +ベクトライザー モジュールの場合と同様に、生成モジュールのプロバイダーから発行された API キーが必要です。この例では、OpenAI からの API キーが必要です。 + +### RAG クエリ + +RAG クエリは、Weaviate では「generative クエリ」とも呼ばれます。これらの機能には、コレクション オブジェクトの `generate` サブモジュールからアクセスできます。 + +各 generative クエリは通常の検索クエリに加えて実行され、取得された各オブジェクトに対して RAG クエリを実行します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/20_single_prompt.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/20_single_prompt.mdx new file mode 100644 index 000000000..e6e7572ed --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/20_single_prompt.mdx @@ -0,0 +1,57 @@ +--- +title: "'シングルプロンプト' 生成" +description: "Weaviate で text RAG を使用し、シングルプロンプトで直接的な質問応答を行います。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/104_rag.ts'; + +「シングルプロンプト」生成では、取得された各オブジェクトに対して RAG クエリを実行します。同じプロンプトで各オブジェクトを個別に変換したい場合に便利です。 + +### コード + +この例では、「dystopian future」に対するクエリ ベクトルと最も一致する「Movie」のエントリーを検索します。続いて、大規模言語モデルに各映画のタイトルをフランス語へ翻訳するよう指示します。 + +その後、各結果がコンソールに出力されます。 + + + +## コードの説明 + +`"... {title} ..."` のように中かっこを使って、`singlePrompt` パラメーターに 1 つ以上のプロパティを渡す必要があります。これにより、Weaviate は取得した各オブジェクトの `title` プロパティを大規模言語モデルへ渡します。 + +
+ 例: 結果 + +```text +In Time +À temps +Looper +Boucleur +I, Robot +Je, Robot +The Matrix +La Matrice +Children of Men +Les enfants des hommes +``` + +
+ +### レスポンスオブジェクト + +各レスポンスオブジェクトは通常の検索クエリとほぼ同じですが、追加で `generated` 属性が含まれます。この属性には、各オブジェクトに対して生成された出力が格納されます。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/30_grouped_task.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/30_grouped_task.mdx new file mode 100644 index 000000000..9a01001b4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/30_grouped_task.mdx @@ -0,0 +1,58 @@ +--- +title: "「Grouped task」生成" +description: "Weaviate でのテキスト RAG を通じて応答生成を洗練するためにタスクをグループ化します。" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSCode from '!!raw-loader!../_snippets/104_rag.ts'; + +「grouped task」生成では、取得したオブジェクトの集合に対して RAG クエリを実行します。これは、1 つのプロンプトでオブジェクト集合全体を変換したい場合に便利です。 + +### コード + +この例では、「dystopian future」に対するクエリ ベクトルと最も一致する「Movie」のエントリーを検索します。その後、大規模言語モデルに対して、それらのエントリー間の共通点を見つけるよう指示します。 + +各結果はコンソールに出力されます。 + + + +## コードの説明 + +`groupedTask` クエリでは、プロンプトをそのまま `groupedTask` パラメーターに渡すだけです。これにより Weaviate は以下を大規模言語モデルに渡します。 +- 取得したすべてのオブジェクトからのテキストプロパティ +- プロンプト + +
+ 例の結果 + +```text +In Time +Looper +I, Robot +The Matrix +Children of Men +These movies all involve futuristic settings and explore themes related to the manipulation of time, technology, and the potential consequences of advancements in society. They also touch on issues such as inequality, control, and the impact of human actions on the future of humanity. +``` + +
+ +### 追加パラメーター(任意) + +`groupedProperties` パラメーターとして使用するプロパティのリストを渡すこともできます。これにより、大規模言語モデルに渡すデータ量を削減し、不必要なプロパティを省くことができます。 + +### レスポンスオブジェクト + +`groupedTask` パラメーターを含む RAG クエリは、追加の `generated` 属性を持つレスポンスを返します。この属性には、オブジェクト集合に対して生成された出力が含まれます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/index.mdx new file mode 100644 index 000000000..083787e83 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/104_text_rag/index.mdx @@ -0,0 +1,24 @@ +--- +title: LLM と Weaviate(RAG) +description: "取得したデータに基づいて応答を生成するために、Weaviate でテキスト RAG を実装します。" +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/900_next_steps.mdx new file mode 100644 index 000000000..7ac554d5f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/900_next_steps.mdx @@ -0,0 +1,7 @@ +--- +title: 次のステップ +--- + +import IntroNextSteps from '../_snippets/intro_next_steps_js.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/101_connect.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/101_connect.ts new file mode 100644 index 000000000..f95a2d57c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/101_connect.ts @@ -0,0 +1,172 @@ +// WCDInstantiation // WCDAPIKeyInstantiation // DockerInstantiation // DockerAPIKeyInstantiation // TryFinallyCloseDemo +import weaviate, { WeaviateClient } from "weaviate-client"; +let client: WeaviateClient; +// END WCDInstantiation // END WCDAPIKeyInstantiation // END DockerInstantiation // END DockerAPIKeyInstantiation // END TryFinallyCloseDemo + + +// WCDInstantiation + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + } +) + +// END WCDInstantiation + +client.close() + +// WCDAPIKeyInstantiation + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, // Replace with your inference API key + } + } +) +// END WCDAPIKeyInstantiation + +client.close() + +// DockerInstantiation + +client = await weaviate.connectToLocal() +// END DockerInstantiation + +client.close() + +// DockerAPIKeyInstantiation + +client = await weaviate.connectToLocal({ + host: '...', + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, // Replace with your inference API key +}}) +// END DockerAPIKeyInstantiation + +// PollLiveness +if (await client.isLive()) { + // Run operations with the client if it is live +} +// END PollLiveness + + +// GetMeta +console.log(await client.getMeta()) +// END GetMeta + + +const outputString = +// OutputGetMeta +{ + hostname: 'http://[::]:8080', + modules: { + 'backup-gcs': { + bucketName: 'weaviate-wcs-prod-cust-europe-west3-workloads-backups', + rootName: '55a78146-dae1-4609-90ce-556db01f4a61' + }, + 'generative-anyscale': { + documentationHref: 'https://docs.anyscale.com/endpoints/overview', + name: 'Generative Search - Anyscale' + }, + 'generative-aws': { + documentationHref: 'https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html', + name: 'Generative Search - AWS' + }, + 'generative-cohere': { + documentationHref: 'https://docs.cohere.com/reference/chat', + name: 'Generative Search - Cohere' + }, + 'generative-mistral': { + documentationHref: 'https://docs.mistral.ai/api/', + name: 'Generative Search - Mistral' + }, + 'generative-openai': { + documentationHref: 'https://platform.openai.com/docs/api-reference/completions', + name: 'Generative Search - OpenAI' + }, + 'generative-google': { + documentationHref: 'https://cloud.google.com/vertex-ai/docs/generative-ai/chat/test-chat-prompts', + name: 'Generative Search - Google' + }, + 'multi2vec-google': { + documentationHref: 'https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-multimodal-embeddings', + name: 'Google Multimodal Module' + }, + 'qna-openai': { + documentationHref: 'https://platform.openai.com/docs/api-reference/completions', + name: 'OpenAI Question & Answering Module' + }, + 'ref2vec-centroid': {}, + 'reranker-cohere': { + documentationHref: 'https://txt.cohere.com/rerank/', + name: 'Reranker - Cohere' + }, + 'reranker-voyageai': { + documentationHref: 'https://docs.voyageai.com/reference/reranker-api', + name: 'Reranker - VoyageAI' + }, + 'text2vec-aws': { + documentationHref: 'https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html', + name: 'AWS Module' + }, + 'text2vec-cohere': { + documentationHref: 'https://docs.cohere.ai/embedding-wiki/', + name: 'Cohere Module' + }, + 'text2vec-huggingface': { + documentationHref: 'https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task', + name: 'Hugging Face Module' + }, + 'text2vec-jinaai': { + documentationHref: 'https://jina.ai/embeddings/', + name: 'JinaAI Module' + }, + 'text2vec-openai': { + documentationHref: 'https://platform.openai.com/docs/guides/embeddings/what-are-embeddings', + name: 'OpenAI Module' + }, + 'text2vec-google': { + documentationHref: 'https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings', + name: 'Google Module' + }, + 'text2vec-voyageai': { + documentationHref: 'https://docs.voyageai.com/docs/embeddings', + name: 'VoyageAI Module' + } + }, + version: '1.25.5' +} +// END OutputGetMeta + + + +client.close() + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string, + { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, // Replace with your inference API key + } + } +) + +// TryFinallyCloseDemo + +// Instantiate your client (not shown). e.g.: +// client = weaviate.connectToWeaviateCloud(...) or +// client = weaviate.connectToLocal(...) + +try { + // Work with the client here + if (await client.isLive()) { + // ... + } +} finally { // This will always be executed, even if an exception is raised + client.close() // Close the connection & release resources +} +// END TryFinallyCloseDemo diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/102_collection.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/102_collection.ts new file mode 100644 index 000000000..a98943b65 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/102_collection.ts @@ -0,0 +1,165 @@ +// CreateMovieCollection // SubmoduleImport // BatchImportData +import weaviate from "weaviate-client"; +// END BatchImportData // END CreateMovieCollection // END SubmoduleImport +// CreateMovieCollection // SubmoduleImport +import { WeaviateClient, configure, vectors } from "weaviate-client"; +// END CreateMovieCollection // END SubmoduleImport + + +// BatchImportData +import { generateUuid5 } from "weaviate-client"; + +// END BatchImportData + +// BatchImportData +let client: WeaviateClient; +// CreateMovieCollection // END BatchImportData + +// END CreateMovieCollection + +client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL as string,{ + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + } +) +// CreateMovieCollection +// Instantiate your client (not shown). e.g.: +// const requestHeaders = {'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string,} +// client = weaviate.connectToWeaviateCloud(..., headers: requestHeaders) or +// client = weaviate.connectToLocal(..., headers: requestHeaders) + +// END CreateMovieCollection + +const requestHeaders = {'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string,} + + +client = await weaviate.connectToWeaviateCloud( + process.env.WEAVIATE_URL as string, + { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_API_KEY as string), + headers: requestHeaders + } +) + +// END CreateMovieCollection + +// Actual instantiation + +client.collections.delete("Movie") + +// CreateMovieCollection +await client.collections.create({ + name: "Movie", + properties: [ + { name: "title", dataType: configure.dataType.TEXT}, + { name: "overview", dataType: configure.dataType.TEXT}, + { name: "vote_average", dataType: configure.dataType.NUMBER}, + { name: "genre_ids", dataType: configure.dataType.INT_ARRAY}, + { name: "release_date", dataType: configure.dataType.DATE}, + { name: "tmdb_id", dataType: configure.dataType.INT}, + ], + // Define the vectorizer module + vectorizers: vectors.text2VecOpenAI(), + // Define the generative module + generative: configure.generative.openAI(), + // END generativeDefinition // CreateMovieCollection + }) + +client.close() +// END CreateMovieCollection + +const weaviateURL = process.env.WEAVIATE_URL as string +const weaviateKey = process.env.WEAVIATE_API_KEY as string +const openaiKey = process.env.OPENAI_API_KEY as string + +client = await weaviate.connectToWeaviateCloud(weaviateURL,{ + authCredentials: new weaviate.ApiKey(weaviateKey), + headers: { + 'X-OpenAI-Api-Key': openaiKey, // Replace with your inference API key + } + } +) + +// BatchImportData + +// Instantiate your client (not shown). e.g.: +// client = weaviate.connectToWeaviateCloud(...) or +// client = weaviate.connectToLocal(...) + +// END BatchImportData + +// BatchImportData +const dataUrl = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json" +const response = await fetch(dataUrl) +const data = await response.json() + +// Get the collection +const movies = client.collections.use("Movie") + +// Set a counter and initialize Weaviate Object +let itemsToInsert: Object[] = [] +let counter = 0; + +// Iterate through data +for (const key of Object.keys(data['title'])) { + counter++; + if(counter % 1000 == 0) + console.log(`Import: ${counter}`) + // END Iterate through data // END BatchImportData + // BatchImportData + + let genreIds: [] + + // Format genre_ids and release_date + const parsedArray = JSON.parse(data['genre_ids'][key]); + genreIds = parsedArray.map(item => parseInt(item, 10)); + let releaseDate = new Date(data['release_date'][key]) + + // Build the object payload + let movieObject = { + title: data['title'][key], + overview: data['overview'][key], + vote_average: data['vote_average'][key], + genre_ids: genreIds, + release_date: releaseDate, + tmdb_id: data['id'][key], + } + // Insert + let objectToInsert = { + properties: movieObject, + uuid: generateUuid5(data['title'][key]) + } + + // Add object to batching array + itemsToInsert.push(objectToInsert) + + if(itemsToInsert.length == 2000) { + // Batch insert 2000 items and clear batch array + const response = await movies.data.insertMany(itemsToInsert) + itemsToInsert = [] + if(response.hasErrors) { + throw new Error("Something went wrong in import!") + } + } + // END BatchImportData // END Insert + // BatchImportData // Iterate through data + // ... other operations +} +// END Iterate through data // END BatchImportData +// BatchImportData +// insert the remaining objects +if(itemsToInsert.length > 0) { + // Batch insert any remaining items + const response = await movies.data.insertMany(itemsToInsert) + console.log("Done Importing") + + // END BatchImportData + // Handle Errors // BatchImportData + if(response.hasErrors) { + throw new Error("Something went wrong in import!") + } + // END BatchImportData // END Handle Errors + // BatchImportData +} + +client.close() +// END BatchImportData diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/103_searches.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/103_searches.ts new file mode 100644 index 000000000..fa87b00a2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/103_searches.ts @@ -0,0 +1,108 @@ +// # START-ANY +import weaviate, { WeaviateClient } from 'weaviate-client' + +let client: WeaviateClient +let response + +// # END-ANY + + +const weaviateURL = process.env.WEAVIATE_URL as string +const weaviateKey = process.env.WEAVIATE_API_KEY as string +const openaiKey = process.env.OPENAI_API_KEY as string + +// Connect to your Weaviate instance +client = await weaviate.connectToWeaviateCloud(weaviateURL, { +authCredentials: new weaviate.ApiKey(weaviateKey), +headers: { + 'X-OpenAI-Api-Key': openaiKey, // Replace with your inference API key +} +}) + +// # START-ANY +// Instantiate your client (not shown). e.g.: +// const requestHeaders = {'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string,} +// client = weaviate.connectToWeaviateCloud(..., headers: requestHeaders) or +// client = weaviate.connectToLocal(..., headers: requestHeaders) + +// # END-ANY + +// MetadataSemanticSearch +// Get the collection +// END MetadataSemanticSearch +// MetadataBM25Search // MetadataSemanticSearch // MetadataHybridSearch // FilteredSemanticSearch +const movies = client.collections.use("Movie") +// END MetadataBM25Search // END MetadataSemanticSearch // END MetadataHybridSearch // END FilteredSemanticSearch +// MetadataSemanticSearch + +// Perform query +response = await movies.query.nearText('dystopian future', { + limit: 5, + returnMetadata: ['distance'] +}) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year + console.log(`${item.properties.title}: ${item.properties.release_date.getUTCFullYear()} `) + // Print the distance of the object from the query + console.log(`Distance to query: ${item.metadata.distance}`) +} +// END MetadataSemanticSearch + +// MetadataBM25Search + +response = await movies.query.bm25('history', { + limit: 5, + returnMetadata: ['score'] +}) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year + console.log(`${item.properties.title}: ${item.properties.release_date.getUTCFullYear()} `) + // Print the BM25 score of the object from the query + console.log(`BM25 score: ${item.metadata.score}`) +} +// END MetadataBM25Search + + +// MetadataHybridSearch + +response = await movies.query.hybrid('history', { + limit: 5, + returnMetadata: ['score'] +}) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year + + console.log(`${item.properties.title}: ${item.properties.release_date.getUTCFullYear()} `) + // Print the hybrid search score of the object from the query + + console.log(`Hybrid score: ${item.metadata.score}`) +} +// END MetadataHybridSearch + + +// FilteredSemanticSearch + +// Perform query +response = await movies.query.nearText('dystopian future', { + limit: 5, + returnMetadata: ['distance'], + // highlight-start + filters: movies.filter.byProperty('release_date').greaterThan(new Date('December 17, 1995')) + // highlight-end +}) + +// Inspect the response +for (let item of response.objects) { + // Print the title and release year + console.log(`${item.properties.title}: ${item.properties.release_date.getUTCFullYear()} `) + // Print the distance of the object from the query + console.log(`Distance to query: ${item.metadata.distance}`) +} +client.close() +// END FilteredSemanticSearch diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/104_rag.ts b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/104_rag.ts new file mode 100644 index 000000000..2a359a754 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/_snippets/104_rag.ts @@ -0,0 +1,72 @@ +// # START-ANY +import weaviate, { WeaviateClient } from "weaviate-client" + +let client: WeaviateClient +let response +// # END-ANY + +const weaviateURL = process.env.WEAVIATE_URL as string + const weaviateKey = process.env.WEAVIATE_API_KEY as string + const openaiKey = process.env.OPENAI_API_KEY as string + + // Connect to your Weaviate instance + client = await weaviate.connectToWeaviateCloud(weaviateURL, { + authCredentials: new weaviate.ApiKey(weaviateKey), + headers: { + 'X-OpenAI-Api-Key': openaiKey, // Replace with your inference API key + } + }) + +// # START-ANY + +// Instantiate your client (not shown). e.g.: +// const requestHeaders = {'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string,} +// client = weaviate.connectToWeaviateCloud(..., headers: requestHeaders) or +// client = weaviate.connectToLocal(..., headers: requestHeaders) + +// # END-ANY + +// SinglePromptGeneration // GroupedTaskGeneration +// Get the collection +const movies = client.collections.use("Movie") +// END GroupedTaskGeneration // END SinglePromptGeneration + +// SinglePromptGeneration + +// Perform query +response = await movies.generate.nearText("dystopian future", { + // highlight-start + singlePrompt: "Translate this into French: {title}" }, + // highlight-end + { limit: 5 } +) + +// Inspect the response +for (let item of response.objects) { + console.log(`${item.properties.title} - ${item.generated}`) +} +// END SinglePromptGeneration + + +// GroupedTaskGeneration + +// Perform query +response = await movies.generate.nearText("dystopian future", { + // highlight-start + groupedTask: "What do these movies have in common?", + // highlight-end + groupedProperties: ['title', 'overview']}, + { limit: 5 } +) + +// Inspect the response +for (let item of response.objects) { + console.log('Title: ', item.properties.title) // Print the title +} + +// highlight-start +console.log(response.generated) // Print the generated text (the commonalities between them) +// highlight-end + +client.close() +// END GroupedTaskGeneration diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/index.md new file mode 100644 index 000000000..e23717768 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/js/starter_text_data/index.md @@ -0,0 +1,25 @@ +--- +title: "101T 実習: JavaScript でテキスト データを扱う" +description: "JavaScript で強力な検索とデータ整理を行うため、 Weaviate でテキスト データを使い始めましょう。" +sidebar_position: 101 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +このプロジェクトベースのコースでは、 Weaviate と映画データセットを使用してあらゆるテキスト データを扱う方法を学びます。 + + Weaviate のベクトル化機能を利用して、テキスト データを意味で保存・インデックス化する実践的な経験を得られます。さらに、セマンティック検索、キーワード検索、ハイブリッド検索、フィルターを用いた検索方法も習得します。 + +また、取得したオブジェクトを基に出力を生成するために、 Weaviate の検索拡張生成 (RAG) 機能を使う方法も学びます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/10_set_up_python.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/10_set_up_python.mdx new file mode 100644 index 000000000..8435ba8dd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/10_set_up_python.mdx @@ -0,0 +1,143 @@ +--- +title: 10 Weaviate 用 Python のセットアップ +sidebar_position: 10 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import PythonCodeExample from '!!raw-loader!./_snippets/10_setup_python.py'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import WeaviatePythonImgUrl from './img/Weaviate-release-1-22-python.png'; + +この短いガイドに従い、 Weaviate を Python クライアントと共に使用できるよう準備を行いましょう。 + +Image alt + +## Python のインストール + +### Python はインストールされていますか? + +ターミナル ウィンドウ(例: bash、 zsh、 Windows PowerShell、 Windows Terminal)を開き、次を実行します: + +```shell +python --version +``` + +うまくいかない場合は、 `python` の代わりに `python3` を使用してください: + +```shell +python3 --version +``` + +Python がインストールされている場合、 `Python 3.11.8` のような出力が表示されます。 Python 3.8 以上がインストールされている場合は、このセクションの残りをスキップできます。 + +### Python のインストール + +インストールするには、 [Python.org](https://www.python.org/downloads/) にあるお使いのシステム向け手順に従ってください。 + +Python をインストールしたら、もう一度バージョンを確認し、推奨バージョンが入っていることを確認してください。 + +:::tip Advanced option: `pyenv` +別の方法として `pyenv` を使用して Python をインストールすることもできます。 `pyenv` を使うと、システム上で複数バージョンの Python を管理できます。 `pyenv` のインストール方法は [こちら](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation) を参照してください。 +::: + +## 仮想環境のセットアップ + +仮想環境を使うと、複数の Python プロジェクトを互いに分離できます。各プロジェクトごとに依存関係をインストールしても、他のプロジェクトには影響しません。 + +### 仮想環境の作成 + +仮想環境の作成には `venv` を使用することを推奨します。プロジェクト ディレクトリへ移動(例: `cd PATH/TO/PROJECT`)し、次を実行します: + +```shell +python -m venv .venv +``` + +`python3` が Python コマンドの場合は、次を実行してください: + +```shell +python3 -m venv .venv +``` + +これにより、プロジェクト ディレクトリに `.venv` というディレクトリが作成され、その中に仮想環境が構築されます。 + +### 仮想環境のアクティブ化 + +各仮想環境は「アクティブ化」と「非アクティブ化」ができます。アクティブ化されている間、実行する Python コマンドはその仮想環境内の Python バージョンとライブラリを使用します。 + +仮想環境をアクティブ化するには、プロジェクト ディレクトリで次を実行します: + +```shell +source .venv/bin/activate +``` + +Windows を使用している場合は以下を実行してください: + + + + +```shell +.venv\Scripts\activate.bat +``` + + + + +```shell +.venv\Scripts\Activate.ps1 +``` + + + + +仮想環境がアクティブ化されているかどうかは、次を実行して確認できます: + +```shell +which python +``` + +または Windows では、 PowerShell で `Get-Command python`、 Command Prompt で `where python` を実行します。 + +仮想環境がアクティブ化されている場合、 `.venv` ディレクトリを指すパスが表示されます。 + +:::tip Virtual environments +仮想環境は非常に便利です。詳しく知りたい場合は、 [FreeCodeCamp](https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/) のチュートリアルや、より深く解説している [RealPython](https://realpython.com/python-virtual-environments-a-primer/) の記事を参照してください。 +
+ +さらに、 `conda`、 `pipenv`、 `poetry` など他にも多くの環境管理ツールがあります。すでにこれらのツールを使用している場合は、 `venv` の代わりにそれらを使っても構いません。 +::: + +## Weaviate クライアントのインストール + +これで、 Weaviate と Python でのやり取りを簡単にしてくれる [Weaviate クライアント ライブラリ](../../weaviate/client-libraries/index.mdx) をインストールできます。 + +[仮想環境をアクティブ化](#-activate-the-virtual-environment) したら、次のコマンドで Weaviate クライアントをインストールします: + +```shell +pip install weaviate-client +``` + +### インストールの確認 + +Weaviate クライアントがインストールされているか確認するには、次の Python コードを実行してください: + + + +次のような出力が表示されれば成功です: + +```text +Your Weaviate client library version is: 4.5.4. +``` + +これで、 Python と Weaviate Python クライアント ライブラリを使う準備が整いました。おめでとうございます! + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_category_.json new file mode 100644 index 000000000..5abb7a5e5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Python", + "position": 10 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/10_setup_python.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/10_setup_python.py new file mode 100644 index 000000000..157cc9be5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/10_setup_python.py @@ -0,0 +1,5 @@ +# CheckClientLibInstall +import weaviate + +print(f"Your Weaviate client library version is: {weaviate.__version__}.") +# END CheckClientLibInstall diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/cta_socials.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/cta_socials.mdx new file mode 100644 index 000000000..3b1623c60 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/cta_socials.mdx @@ -0,0 +1,3 @@ +## 最新情報のご案内 + +私たちはドキュメントを常に改善しています。新しいリソースやアップデートをお見逃しにならないよう、 [ニュースレター](https://newsletter.weaviate.io/) にご登録いただくか、ソーシャルメディア( [Twitter](https://x.com/weaviate_io)、 [LinkedIn](https://www.linkedin.com/company/weaviate-io/) )でフォローしてください。 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/intro_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/intro_next_steps.mdx new file mode 100644 index 000000000..6f9fca3a4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/_snippets/intro_next_steps.mdx @@ -0,0 +1,32 @@ +おめでとうございます! Weaviate の入門コースを修了しました。 + +このコースを終えたら、より高度な内容を学ぶためにドキュメントや Academy をご覧になることをおすすめします。 + +特に人気のあるリソースは次のとおりです。 + +### ドキュメント + +- ハウツーガイド + - [How-to: Manage collections](/weaviate/manage-collections/index.mdx) と [How-to: Manage objects](/weaviate/manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除)方法を解説しています。 + - [How-to: search](/weaviate/search/index.mdx):あらゆる検索操作のコード例を掲載しています。 + - [How-to: configure Weaviate](/weaviate/configuration/index.mdx):[PQ](/weaviate/configuration/compression/pq-compression.md) や [BQ](/weaviate/configuration/compression/bq-compression.md) の圧縮、[バックアップ](/deploy/configuration/backups.md)、[レプリケーション](/deploy/configuration/replication.md) など、Weaviate の設定方法をまとめています。 +- [Concepts guides](/weaviate/concepts/index.md):Weaviate のアーキテクチャと概念を理解するためのガイド。 +- [API reference](/weaviate/api/index.mdx):Weaviate の API についての詳細情報。 + +### Academy + +- [名前付きベクトル](../named_vectors/index.md):名前付き ベクトル を用いてデータを柔軟に表現する方法を学びます。 +- [Which search is right for me?](../standalone/which_search/index.mdx):Weaviate のさまざまな検索方法と、その使い分けを学びます。 +- [チャンク化](../standalone/chunking/index.mdx):長いドキュメントを効率的に検索するためのチャンク化手法を学びます。 + +import CTASocials from './cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## 質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/100_pq.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/100_pq.mdx new file mode 100644 index 000000000..40f2163c6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/100_pq.mdx @@ -0,0 +1,84 @@ +--- +title: 直積量子化 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_pq.py'; + + +[直積量子化](/weaviate/concepts/vector-quantization#product-quantization) (PQ) は、ベクトルを圧縮するための手法です。Weaviate では、メモリ上の [HNSW インデックス](/weaviate/concepts/indexing/vector-index.md#hierarchical-navigable-small-world-hnsw-index) のサイズを削減し、パフォーマンス向上とリソース・コスト削減に役立ちます。 + +## 直積量子化 + +直積量子化は、次の 2 つの方法でベクトルを圧縮します。 +1. ベクトルを「セグメント」に分割する +2. 各セグメントを「コードブック」に含まれるセントロイドの 1 つで表現できるよう量子化する + +下図では、各次元が浮動小数点数で表される L 次元のベクトルを示しています。このベクトルは L/x セグメントに分割され、各セグメントは N 個のセントロイドのいずれかで量子化されます。 + +import PQDiagram from './_snippets/pq_diagram.png'; + +Abstracted PQ diagram showing reduction of dimensions and quantization of groups of floats + +例えば、768 次元のベクトルは、128 セグメントに量子化された 1 バイト整数のベクトルへ圧縮できます。 + +これにより、ベクトルの長さは 6 分の 1 になり、各セグメントは浮動小数点数 (4 バイト) から 1 バイトで 256 個のセントロイドのいずれかを表す形式へ縮小されます。 + +結果として、ベクトルのサイズは 24 倍 (768 × 4 バイト → 128 × 1 バイト) 小さくなります。 + +その後、HNSW インデックスは PQ 圧縮後のベクトル上に構築されるため、インデックスのメモリサイズも削減されます。 + +### 損失性 + +PQ はロスのある圧縮手法です。元の浮動小数点値をより小さな整数集合へ量子化するため、一部情報が失われます。 + +しかし、Weaviate はインデックスから多めにベクトルを取得し、非圧縮空間で再スコアリングを行うことで、この損失を補っています。実際には、この方法で PQ の損失性を十分に緩和できることが分かっています。 + +## PQ の設定 + +以下の例は、デフォルト設定で直積量子化 (PQ) を有効にしたコレクションを作成します。 + + + +### コードの解説 + +このコードは、PQ を有効にしたコレクションをデフォルト設定で作成します。 + +ただし、圧縮は直ちには行われません。PQ はベクトルの量子化を行うため、既定では 100,000 個のベクトルが「トレーニングセット」に到達するまで待機します。 + +トレーニングセットは量子化用のセントロイドを計算するために使用され、到達後に PQ 圧縮が実行されます。 + +:::note Version and configuration requirements +この PQ 設定方法は「 AutoPQ 」と呼ばれ、Weaviate `v1.23` 以降で非同期インデックス作成を有効にしている場合に利用できます。 +
+ +より古いバージョンの Weaviate を使用している、または非同期インデックス作成を無効にしている場合は、別の設定方法が必要です。詳しくは [PQ 設定ドキュメント](/weaviate/configuration/compression/pq-compression.md#manually-configure-pq) をご覧ください。 +::: + +## PQ のカスタマイズ + +多くの PQ パラメータは変更可能です。デフォルト設定は多くのユースケースで適していますが、要件に合わせて PQ 設定を調整したい場合もあるでしょう。 + +以下の例では、トレーニングセットのサイズを小さくする、セントロイド数を変更するなど、カスタム設定を行う方法を示しています。 + + + +利用可能な設定項目については、[PQ 設定ドキュメント](/weaviate/configuration/compression/pq-compression.md#pq-parameters) を参照してください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/200_bq.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/200_bq.mdx new file mode 100644 index 000000000..65eaed6bc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/200_bq.mdx @@ -0,0 +1,67 @@ +--- +title: バイナリ量子化 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/200_bq.py'; + + +[バイナリ量子化](/weaviate/concepts/vector-quantization#binary-quantization) (BQ) は、ベクトルを圧縮するための手法です。Weaviate では、メモリ上の [HNSW インデックス](/weaviate/concepts/indexing/vector-index.md#hierarchical-navigable-small-world-hnsw-index) やディスクベースの [flat インデックス](/weaviate/concepts/indexing/vector-index.md#flat-index) のサイズを削減するために利用できます。 + +HNSW では、BQ によりメモリフットプリントを縮小できるため、パフォーマンス向上とリソース要件およびコスト削減が期待できます。flat インデックスの場合、ディスク上のインデックスサイズを小さくできるため、パフォーマンスが向上する可能性があります。 + +## バイナリ量子化とは + +バイナリ量子化は、各次元を 1 ビット(0 または 1)に縮小することでベクトルを圧縮します。 + +言い換えると、 n 個の浮動小数点数で構成される n 次元ベクトルを、 n 個のビットで構成される n 次元ベクトルへと圧縮します。 + +これにより、1 次元あたり 32 ビットから 1 ビットへと 32 倍のサイズ削減が可能になります。 + +### モデルの適合性 + +BQ は比較的シンプルなアルゴリズムですが、条件が合えば高い性能を発揮します。特に高次元ベクトルに適しており、BQ を適用しても多くの情報を保持できます。 + +BQ を使用する際は、バイナリ量子化向けに設計されている、またはパフォーマンスが確認されているベクトルを推奨します。経験的には、Cohere の V3 モデル(例: `embed-multilingual-v3.0` や `embed-english-v3.0`)や、OpenAI の `ada-002`、さらに大規模な `text-embedding-3` モデルで良好なリコールを確認しています。 + +### 損失性 + +BQ は損失のある圧縮手法であり、元の浮動小数点数を量子化します。 + +Weaviate では、インデックスからベクトルをオーバーフェッチし、非圧縮空間で再スコアリングすることでこの損失を補います。実際には、これにより BQ の損失を十分に補正できることを確認しています。 + +## BQ を設定する + +以下の例では、デフォルト設定でバイナリ量子化 (BQ) を有効にしたコレクションを作成します。 + + + +### コードの説明 + +このコードにより、デフォルト設定で BQ を有効にしたコレクションが作成されます。 + +BQ ではトレーニングセットを用意する必要がないため、圧縮は即座に開始されます。 + +## BQ をカスタマイズする + +BQ にはいくつか設定可能なパラメーターがあります。重要なものとして `rescore_limit` があり、リスコアリングフェーズを開始する前にインデックスから取得するベクトルの最小数を指定します。 + + + +## ご質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/300_strategy.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/300_strategy.mdx new file mode 100644 index 000000000..aad23fc24 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/300_strategy.mdx @@ -0,0 +1,43 @@ +--- +title: 圧縮戦略 +--- + + PQ 、 BQ 、または圧縮なしの中から選ぶ場合、どれを選択すべきでしょうか。答えは「場合によります」。 + + PQ と BQ はどちらもロスあり圧縮手法であり、その選択はお客様の状況、モデル、ユースケースによって異なります。 + +## インデックスの種類 + + PQ は現在 HNSW インデックスでのみサポートされています。一方、 BQ は HNSW と flat の両方のインデックスでサポートされています。 flat インデックスを使用している場合は BQ を使用する必要があります。 + +## モデル適合性 + + PQ は一般的により堅牢な圧縮手法です。トレーニング時にお客様のデータに合わせて適合されるため、モデルが PQ に適しているかどうかをそれほど心配する必要はありません。 + +これに対して BQ は、モデルの長さやバイナリ量子化向けに設計されているかどうかなど、モデルに対してより敏感です。 + +モデルが BQ に適しているか分からない場合は、 PQ の使用を推奨します。 + +## 調整可能性 + +ご覧のとおり、 PQ のパラメーターは調整可能ですが、 BQ はそうではありません。つまり、圧縮の恩恵を受けつつ、リコールや QPS 目標などのパフォーマンス指標に対して PQ を強めたり弱めたり調整できます。 + +## 複雑さ + +実装が最も簡単な解決策をお探しの場合は、 BQ が最適です。訓練セットがそろうのを待つ必要がなく、すぐに有効化できるシンプルな設定です。 + +## 結論 + +まとめると、どの圧縮手法を選ぶかはお客様の状況、モデル、ユースケースによって異なります。 + +しかし一般的な経験則として、迷った場合は PQ を選ぶことを推奨します。 PQ はより堅牢で調整可能であり、より幅広いモデルやユースケースに適しています。 + +リソース制約が問題でなければ、圧縮をまったく使用しないという選択肢もあります。これにより最高のパフォーマンスが得られますが、その分リソース要件は増大します。 + +ただし後から圧縮をオンにすることは、データの再インデックスが必要になるため通常は不可能です。(ただしデータセットが大きすぎない限り、 PQ だけは [後から有効化できます](../../../weaviate/configuration/compression/pq-compression.md#3-enable-pq-and-create-the-codebook)。) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/900_next_steps.mdx new file mode 100644 index 000000000..3b1082a07 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/900_next_steps.mdx @@ -0,0 +1,26 @@ +--- +title: 次のステップ +--- + +おめでとうございます! これで圧縮に関するこのコースを修了しました。役立ち、かつ有益であったことを願っています。 + +学習を続けるためのリソースは、まだたくさんあります。 + +## ドキュメント + +- [ハウツー: PQ を設定する](/weaviate/configuration/compression/pq-compression.md) +- [ハウツー: BQ を設定する](/weaviate/configuration/compression/bq-compression.md) +- [コンセプト: ベクトル インデックス](/weaviate/concepts/indexing/vector-index.md): ベクトル インデックスは Weaviate の動作および圧縮にとって不可欠です。詳しくはここをご覧ください。 +- [設定リファレンス: ベクトル インデックス](/weaviate/config-refs/indexing/vector-index.mdx): 圧縮設定を含むベクトル インデックスの設定リファレンスです。 + +import CTASocials from '../_snippets/cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/100_pq.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/100_pq.py new file mode 100644 index 000000000..baef74c62 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/100_pq.py @@ -0,0 +1,79 @@ +import weaviate +# PQBasicConfig # PQCustomConfig +from weaviate.classes.config import Configure, DataType, Property +# END PQBasicConfig # PQCustomConfig +from weaviate.collections.classes.config import PQEncoderType, PQEncoderDistribution +# END PQCustomConfig + +from weaviate.collections.classes.config import PQConfig + +client = weaviate.connect_to_local() + +# PQBasicConfig # PQCustomConfig + +# Client instantiation not shown +collection_name = "PQExampleCollection" + +# END PQBasicConfig # END PQCustomConfig + +client.collections.delete(collection_name) + +# PQBasicConfig +client.collections.create( + name=collection_name, + # END PQBasicConfig + properties=[ + Property(name="title", data_type=DataType.TEXT) + ], + vector_config=Configure.Vectors.text2vec_openai( + # PQBasicConfig + # highlight-start + quantizer=Configure.VectorIndex.Quantizer.pq() + # highlight-end + ), + + # Other configuration not shown +) +# END PQBasicConfig + +# Confirm creation +c = client.collections.use(collection_name) +coll_config = c.config.get() +assert type(coll_config.vector_config["default"].vector_index_config.quantizer) == PQConfig + + +client.collections.delete(collection_name) + +# PQCustomConfig +client.collections.create( + name=collection_name, + # END PQCustomConfig + properties=[ + Property(name="title", data_type=DataType.TEXT) + ], + vector_config=Configure.Vectors.text2vec_openai( + # PQCustomConfig + # highlight-start + quantizer=Configure.VectorIndex.Quantizer.pq( + segments=512, + centroids=256, + training_limit=50000, + encoder_distribution=PQEncoderDistribution.NORMAL, + encoder_type=PQEncoderType.TILE, + ) + # highlight-end + ), + # Other configuration not shown +) +# END PQCustomConfig + +c = client.collections.use(collection_name) +coll_config = c.config.get() +assert type(coll_config.vector_config["default"].vector_index_config.quantizer) == PQConfig +assert coll_config.vector_config["default"].vector_index_config.quantizer.segments == 512 +assert coll_config.vector_config["default"].vector_index_config.quantizer.training_limit == 50000 + +# START-ANY + +client.close() +# END-ANY diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/200_bq.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/200_bq.py new file mode 100644 index 000000000..60f9198cd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/200_bq.py @@ -0,0 +1,76 @@ +import weaviate +# BQBasicConfig # BQCustomConfig +from weaviate.classes.config import Configure, DataType, Property +# END BQBasicConfig # BQCustomConfig + +from weaviate.collections.classes.config import BQConfig + +client = weaviate.connect_to_local() + +print(client.get_meta()) +print(weaviate.__version__) + +# BQBasicConfig # BQCustomConfig + +# Client instantiation not shown +collection_name = "BQExampleCollection" + +# END BQBasicConfig # END BQCustomConfig + +client.collections.delete(collection_name) + +# BQBasicConfig +client.collections.create( + name=collection_name, + # END BQBasicConfig + properties=[ + Property(name="title", data_type=DataType.TEXT) + ], + vector_config=Configure.Vectors.text2vec_openai( + # BQBasicConfig + # highlight-start + quantizer=Configure.VectorIndex.Quantizer.bq() + # highlight-end + ), + # Other configuration not shown +) +# END BQBasicConfig + + +# Confirm creation +c = client.collections.use(collection_name) +coll_config = c.config.get() +assert type(coll_config.vector_config["default"].vector_index_config.quantizer) == BQConfig + + +client.collections.delete(collection_name) + +# BQCustomConfig +client.collections.create( + name=collection_name, + # END BQCustomConfig + properties=[ + Property(name="title", data_type=DataType.TEXT) + ], + vector_config=Configure.Vectors.text2vec_openai( + # BQCustomConfig + # Other configuration not shown + # highlight-start + quantizer=Configure.VectorIndex.Quantizer.bq( + rescore_limit=150 + ) + # highlight-end + ), +) +# END BQCustomConfig + +c = client.collections.use(collection_name) +coll_config = c.config.get() +assert type(coll_config.vector_config["default"].vector_index_config.quantizer) == BQConfig +# assert coll_config.vector_index_config.quantizer.rescore_limit == 150 # appears to be a bug + + +# START-ANY + +client.close() +# END-ANY diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/pq_diagram.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/pq_diagram.png new file mode 100644 index 000000000..297c18cc7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/_snippets/pq_diagram.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/index.md new file mode 100644 index 000000000..793ef03f7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/compression/index.md @@ -0,0 +1,27 @@ +--- +title: "250 ベクトル圧縮" +description: "Weaviate でのデータの最適な保存と取得のための圧縮手法を Python で学びます。" +sidebar_position: 250 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +:::info 前提条件 +本コースは自己完結型です。ただし、[テキスト](../starter_text_data/index.md)、[独自 ベクトル](../starter_custom_vectors/index.md)、または [マルチモーダル データ](../starter_multimodal_data/index.md) を扱う 101 レベルのいずれかのコースを先に受講されることを推奨します。 +::: + +より多くのデータを扱うにつれて、その膨大な量が作業に大きな制約を与えるようになります。特に本番環境に近づくほど、ストレージ コストやデータ処理にかかる時間が大きな負担となりがちです。 + +本コースでは Weaviate におけるデータ圧縮を紹介し、リソース要件を削減してパフォーマンスを向上させたりコストを削減したりする方法を学びます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/img/Weaviate-release-1-22-python.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/img/Weaviate-release-1-22-python.png new file mode 100644 index 000000000..eb1965151 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/img/Weaviate-release-1-22-python.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/100_overview.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/100_overview.mdx new file mode 100644 index 000000000..588a62f84 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/100_overview.mdx @@ -0,0 +1,83 @@ +--- +title: "概要" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +Weaviate におけるマルチテナンシーは、コレクションが分離されたデータグループを効率的に提供できるようにする機能です。マルチテナント コレクション内の各「テナント」は、自身のデータのみにアクセスでき、同じデータ構造と設定を共有します。 + +![マルチテナンシー](./img/multi-tenancy-dark.png#gh-dark-mode-only) +![マルチテナンシー](./img/multi-tenancy-light.png#gh-light-mode-only) + +これにより、Weaviate は最小限のオーバーヘッドで多数のテナントを効率的に処理できます。後ほど説明するように、個々のテナントを管理してパフォーマンスとリソース使用量のバランスを取ることも可能です。 + +
+ 他の文脈における「マルチテナンシー」 + +一般に「マルチテナンシー」とは、単一のソフトウェア インスタンスが複数の「テナント」を提供するソフトウェア アーキテクチャを指します。この場合、各テナントは共通アクセス権を持つユーザーグループであることが多いです。 + +これは Weaviate におけるマルチテナンシーの概念と似ており、各テナントは他のテナントから分離されたデータグループとして扱われます。 + +
+ +## マルチテナンシー使用の理由 + +典型的なユースケースとして、SaaS (software-as-a-service) アプリケーションがあります。多くの SaaS アプリケーションでは、各エンドユーザーやアカウントが持つプライベート データは他者からアクセスできない必要があります。 + +### ケーススタディの例 + +このコースでは、`MyPrivateJournal` というアプリを開発する立場になり、マルチテナンシーについて学んでいきます。 + +`MyPrivateJournal` は SaaS アプリケーションで、*Steve*、*Alice* などのユーザーが日記を作成・保存できます。各ユーザーの日記はプライベートで、他者が閲覧できてはいけません。 + +単一テナント コレクションでこれを実装すると、次のいずれかになります。 + +1. **モノリシック コレクション**: すべてのデータセットをエンドユーザー識別子プロパティ付きで 1 つのコレクションに保存 +1. **ユーザーごとのコレクション**: 各エンドユーザーのデータを個別のコレクションに保存 + +しかし、どちらにも大きな制限があります。 + +- モノリシック コレクションの場合: + - 開発者のミスで *Steve* の日記が *Alice* に漏れるなど、重大なプライバシー侵害が起こり得ます。 + - `MyPrivateJournal` が成長すると、*Steve* のクエリはコレクション全体を検索するため遅くなります。 + - *Steve* が `MyPrivateJournal` にデータ削除を依頼した場合、処理が複雑でエラーが起きやすくなります。 +- ユーザーごとのコレクションの場合: + - `MyPrivateJournal` は大量のコレクションを支えるため、より多くのハードウェアコストがかかります。 + - 設定変更 (例: 新しいプロパティの追加) を行う際、各コレクションごとに個別対応が必要です。 + +Weaviate のマルチテナンシーは、同一設定を共有しながらユーザーデータを分離することで、これらの問題を解決します。 + +### マルチテナンシーの利点 + +マルチテナント コレクションでは、各「テナント」が相互に分離されつつ、同じ設定を共有します。この構成により、多数の単一テナント コレクションを作るよりもはるかにリソース効率が高くなります。 + +1 つの Weaviate ノードは、単一テナント コレクションよりも多くのテナントをホストできます。また、設定が 1 つで済むため開発者の負担も軽減され、テナント間のデータ漏えいリスクがなく、各テナントやデータの管理が容易になります。 + +#### `MyPrivateJournal` とマルチテナンシー + +`MyPrivateJournal` はマルチテナンシーを利用し、各ユーザーの日記を個別のテナントに保存できます。これにより *Steve* と *Alice* のデータが互いに分離され、管理も安全になります。 + +さらに、`MyPrivateJournal` はアクティブでないユーザーのデータをコールド ストレージへ移動し、Weaviate ノードのホット (メモリ) およびウォーム (ディスク) リソース使用量を低減できます。 + +## テナントとコレクションの比較 + +マルチテナント コレクションには、任意の数のテナントを作成できます。 + +| 対象 | テナント | 単一テナント コレクション | +| ----- | ----- | ----- | +| オブジェクト | テナントに属する | コレクションに属する | +| ベクトルインデックス | テナントに属する | コレクションに属する | +| 転置インデックス | テナントに属する | コレクションに属する | +| 削除 | テナントを削除するとそのテナントのデータが削除される | コレクションを削除するとそのコレクションのデータが削除される | +| クエリ | 1 度に 1 つのテナントを検索できる | 1 度に 1 つのコレクションを検索できる | + +もちろん、違いもあります。次のセクションでは、`MyPrivateJournal` が Weaviate でマルチテナンシーを実装する流れに沿って、これらの違いを確認していきます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/200_setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/200_setup.mdx new file mode 100644 index 000000000..26d290a34 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/200_setup.mdx @@ -0,0 +1,307 @@ +--- +title: データベースのセットアップ +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +`MyPrivateJournal` の要件を満たす Weaviate インスタンスを構築できるか見てみましょう。 + +## プロジェクト要件 + +SaaS アプリケーションである `MyPrivateJournal` は、次の機能が必要だと判断しました。 + +- **データの分離**: 各ユーザーのデータはプライベートであること。 +- **効率的なスケーラビリティ**: + - `MyPrivateJournal` が成長しても、数万〜数十万ユーザーを扱えること。 + - アクティブユーザーに対しては高速であり、非アクティブユーザーはリソースを消費しないこと。 +- **管理の容易さ**: + - 新しいユーザーの追加が簡単かつ高速であること。 + - ユーザーの削除が容易であること。 +- **柔軟性**: + - 低トラフィックのユーザーにも高トラフィックのユーザーにも効率的であること。 +- **フォールトトレランス**: + - ノード障害が発生しても、そのユーザーが完全にダウンしないこと。 +- **開発者体験**: + - これらの機能が実装・保守しやすいこと。 + +検討の結果、マルチテナントコレクションを備えた Weaviate がこれらの課題を解決できると判断しました。ここでは `MyPrivateJournal` 向け PoC を実装してみましょう。 + +## Weaviate の設定 + +開発環境として、Docker を使ったローカル Weaviate インスタンスを利用します。これにより、開発とテスト用の Weaviate を素早く立ち上げられます。 + +こちらが `docker-compose.yml` ファイルです。 + +```yaml +--- +services: + weaviate_anon: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_API_BASED_MODULES: 'true' + # highlight-start + ASYNC_INDEXING: 'true' + ENABLE_MODULES: 'backup-filesystem,offload-s3' + AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-} + AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-} + OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true' + # highlight-end + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node1' +... +``` + +
+ マルチノード構成の場合は? + +良い質問です!ご覧のとおり、簡潔さのためにここではシングルノード構成を使用しています。 +
+ +しかし、サービスを追加することで簡単にマルチノード構成へ拡張できます。これにより、水平方向のスケーリングやレプリケーションによるフォールトトレランスが可能になります。 +
+ +例として、3 ノード構成は次のとおりです。 + +```yaml +--- +services: + weaviate-node-1: # Founding member service name + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + restart: on-failure:0 + ports: + - "8180:8080" + - 50151:50051 + environment: + AUTOSCHEMA_ENABLED: 'false' + QUERY_DEFAULTS_LIMIT: 25 + QUERY_MAXIMUM_RESULTS: 10000 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ASYNC_INDEXING: 'true' + ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem,offload-s3' + ENABLE_API_BASED_MODULES: 'true' + AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-} + AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-} + OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true' + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node1' + CLUSTER_GOSSIP_BIND_PORT: '7100' + CLUSTER_DATA_BIND_PORT: '7101' + weaviate-node-2: # Founding member service name + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + restart: on-failure:0 + ports: + - "8181:8080" + - 50152:50051 + environment: + AUTOSCHEMA_ENABLED: 'false' + QUERY_DEFAULTS_LIMIT: 25 + QUERY_MAXIMUM_RESULTS: 10000 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ASYNC_INDEXING: 'true' + ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem,offload-s3' + ENABLE_API_BASED_MODULES: 'true' + AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-} + AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-} + OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true' + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node2' + CLUSTER_GOSSIP_BIND_PORT: '7102' + CLUSTER_DATA_BIND_PORT: '7103' + CLUSTER_JOIN: 'weaviate-node-1:7100' + weaviate-node-3: # Founding member service name + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + restart: on-failure:0 + ports: + - "8182:8080" + - 50153:50051 + environment: + AUTOSCHEMA_ENABLED: 'false' + QUERY_DEFAULTS_LIMIT: 25 + QUERY_MAXIMUM_RESULTS: 10000 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ASYNC_INDEXING: 'true' + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ENABLE_API_BASED_MODULES: 'true' + AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-} + AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-} + OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true' + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node3' + CLUSTER_GOSSIP_BIND_PORT: '7104' + CLUSTER_DATA_BIND_PORT: '7105' + CLUSTER_JOIN: 'weaviate-node-1:7100' +... +``` + +
+ +### 設定のハイライト + +他の Docker 設定 ([例: Docs](/deploy/installation-guides/docker-installation.md), [Academy](../starter_text_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx)) に見覚えがあるかもしれませんが、以下の設定は新しいかもしれません。 + +- `ASYNC_INDEXING`: 非同期インデックス作成を有効にします。大量データ挿入に便利で、後ほど学ぶ `dynamic` インデックスタイプを使用できます。 +- `ENABLE_MODULES`: 今回は `offload-s3` を有効にし、後でテナントオフロードを実演します。オフロードは非アクティブユーザーのデータ管理に役立ちます。 +- `AWS_ACCESS_KEY_ID` と `AWS_SECRET_ACCESS_KEY`: Weaviate が S3 バケットへアクセスするための AWS 資格情報です。 +- `OFFLOAD_S3_BUCKET_AUTO_CREATE`: 該当バケットが存在しない場合に自動で作成します。 + +ファイルを `docker-compose.yaml` として保存し、次のコマンドで Weaviate を起動します。 + +```bash +docker compose up +``` + +import OffloadingLimitation from '/_includes/offloading-limitation.mdx'; + + + +### Weaviate インスタンスの詳細 + +インスタンスが作成されたら、`http://localhost:8080` でアクセスできます。 + +では、`MyPrivateJournal` 用のコレクションを作成しましょう。 + +## コレクションの作成 + +### マルチテナンシーの有効化 + +コレクションは作成時にマルチテナントとして指定する必要があります。そのため、コレクション設定でマルチテナンシーを有効にします。 + + + +ここでは `auto_tenant_creation` と `auto_tenant_activation` を `true` に設定しています。詳細は後ほど説明しますが、簡単に概要を示します。 + +- `auto_tenant_activation`: `true` の場合、非アクティブ (`INACTIVE` または `OFFLOADED`) なテナントがアクセスされた際に自動的にアクティブ化されます。 +- `auto_tenant_creation`: `true` の場合、存在しないテナントに対してオブジェクトが挿入された際に自動でテナントを作成します。 + +これらの機能は後ほど実際に確認します。 + +
+ auto_tenant_creation について詳しく + +:::info `v1.25` で追加 +auto tenant creation 機能は、バッチインポートでは `v1.25.0`、単一オブジェクト挿入では `v1.25.2` から利用できます。 +::: + +`auto_tenant_creation` を有効にすると、存在しないテナントに対してオブジェクトが挿入された際に Weaviate が自動でテナントを作成します。 +
+ +大量データ取り込み時に便利で、事前にテナントを作成する手間が省けます。`auto_tenant_creation` により、インポート処理を中断せずに続行できます。 +
+ +ただし、ソースデータの誤りがインポート中に検知されないリスクがあります。例えば、誤って `"TenntOn"` とスペルされたオブジェクトが `"TenantOne"` ではなく `"TenntOne"` という新しいテナントを作成してしまいます。 +
+ +サーバー側のデフォルト値は `false` です。 +
+ +
+ auto_tenant_activation について詳しく + +:::info `v1.25.2` で追加 +auto tenant activation 機能は `v1.25.2` から利用できます。 +::: + +`auto_tenant_activation` を有効にすると、非アクティブ (`INACTIVE` または `OFFLOADED`) なテナントがアクセスされた際に自動でアクティブ化されます。 +
+ +多数のテナントが存在し、そのうち常に一部のみがアクティブというシナリオに最適です。例えば、SaaS アプリでタイムゾーンや最近のアクティビティによりアクセスが少ないテナントがある場合などです。 +
+ +`auto_tenant_activation` を有効にすることで、これらのテナントを安心して非アクティブにでき、リクエスト時にメモリへロードされます。 +
+ +これにより、Weaviate インスタンスのメモリ使用量を削減できます。アクティブなテナントのみがメモリに読み込まれるためです。 +
+ +サーバー側のデフォルト値は `false` です。 + +
+### ベクトルインデックスの設定 + +他のジャーナルのユースケースから分かっていることとして、大多数のユーザーはエントリー数が少ない一方で、少数のユーザーは大量のエントリーを持つ場合があります。 + +これはバランスを取るのが難しい状況です。`hnsw` インデックスを使用すると、多くのエントリーを持つユーザーに対して高速ですが、メモリを多く消費します。`flat` インデックスを使用するとメモリ消費は抑えられますが、多くのエントリーを持つユーザーに対しては速度が遅くなる可能性があります。 + +そこで選択できるのが `dynamic` インデックスです。`dynamic` インデックスは、エントリー数がしきい値を超えると自動的に `flat` から `hnsw` へ切り替わります。これにより、メモリ使用量と速度のバランスを取ることができます。 + +以下は、`dynamic` インデックスを使用して "note" という名前のベクトルを設定する例です。 + + + +ここで(ダジャレではありませんが)注意したいのは、`dynamic` インデックス構成では `flat` と `hnsw` の両方のインデックス設定を受け付ける点です。`dynamic` インデックスがそれぞれの状態にあるときに、該当する設定が使用されます。 + +### 完全なコードスニペット + +以下はコレクションを作成する完全なコードスニペットです。設定を確認し、私たちの選択に同意できるか見てみてください。 + + PoC では、シンプルにするために 1 つのコレクション(`"JournalEntry"`)だけを作成し、`"text"`、`"date"`、`"tags"` プロパティを持たせています。 + + + +### まとめ + +このセクションでは、マルチテナンシーを有効にした Weaviate インスタンスをセットアップしました。また、マルチテナンシーと dynamic インデックス設定を持つ `MyPrivateJournal` 用のコレクションを作成しました。 + +これで、`MyPrivateJournal` チームはユーザーのオンボーディングを開始し、ジャーナルエントリーをコレクションに保存できるようになります。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/300_tenant_data.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/300_tenant_data.mdx new file mode 100644 index 000000000..2f1e8f6eb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/300_tenant_data.mdx @@ -0,0 +1,169 @@ +--- +title: テナントとデータの操作 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +`MyPrivateJournal` のチームは、現在 Weaviate インスタンスにマルチテナント コレクションを構築しました。このセクションでは、テナントとそのデータの操作方法を学びます。 + +## テナントとデータの追加 + +マルチテナント コレクションを作成したら、 `.tenant` 名前空間を通じてテナントを管理できます。 + +`MyPrivateJournal` の各エンドユーザーは、自身の日記エントリを専用のテナントに保存します。つまり、ユーザーがオンボーディングされるとテナントが作成され、オフボーディングされるとそのテナントは削除されます。 + +### テナントの作成 + +ユーザーをオンボーディングする際には、次のコードをオンボーディング ロジックに組み込めます。 + + + +テナントは一括で作成することも可能です。 + +たとえば、 `MyPrivateJournal` が `AcmeCorp` という組織から複数の新しいユーザーをオンボーディングする場合、1 回の操作で複数ユーザー用のテナントを作成できます: + + + +:::caution Tenant names are case-sensitive +テナント名は大文字と小文字を区別します。したがって、 `steve` 、 `Steve` 、 `STEVE` は別々のテナントとして扱われます。 +::: + +### データオブジェクトの追加 + +マルチテナント コレクション内のテナントを操作する手順は、シングルテナント コレクションの場合とほぼ同じです。 + +ここでは、 `MyPrivateJournal` がテナント内のデータ オブジェクトをどのように扱うかを見ていきます。 + +#### 単一オブジェクトの挿入 + +エンドユーザー(例: Steve または `steve85` )が新しい日記エントリを書き込むと、 `MyPrivateJournal` はそれを Steve のテナントに挿入できます。 + + + +#### バッチデータの挿入 + +また、 Steve が別のシステムから自身の日記エントリをインポートしたい場合、 `MyPrivateJournal` はバッチで挿入できます。 + +
+ 挿入されるデータ + +追加するオブジェクトは、ここに示すように辞書のリストとして指定できます。 `DATE` 型プロパティには、タイムゾーン付きの `datetime` オブジェクトを使用している点にご注意ください。 + + + +
+ + + +#### 追加機能: 自動テナント作成 + +`MyPrivateJournal` で自動テナント作成を有効にしている場合、テナントを明示的に作成しなくてもデータを挿入できます。この例では、指定したテナントは存在しませんが、 Weaviate が自動的に作成します。 + +これにより、 `MyPrivateJournal` はユーザーが最初の日記エントリを書くまでテナントの作成を遅らせることができます。 + + + +## テナントデータのクエリ + +Steve のテナントが作成されてデータが格納されると、 `MyPrivateJournal` は Steve が自身のデータを操作できるようにします。 + +このようなアプリケーションでは、 `MyPrivateJournal` は Steve に次の機能を提供するかもしれません: + +- 指定した日付範囲の日記エントリを取得する +- エントリを検索する + +嬉しいことに、データ操作と同様に、テナント内での取得や検索もシングルテナント コレクションの場合とほとんど同じです。 + +### 日付範囲でのエントリ取得 + +特定の日付範囲の Steve の日記エントリを取得するには、 `MyPrivateJournal` は次のようなクエリを実行できます: + + + +
+ 例: レスポンス + +このクエリは次のようなレスポンスを返します: + + +
+### エントリーの検索 + +さらに、 Steve はエントリーを検索したいことがあるかもしれません。例えば、彼が体験した食べ物に関連するエントリーを探したい場合などです。 + +`MyPrivateJournal` は Weaviate の `hybrid` 検索を活用して、 Steve が最も関連性の高いエントリーを見つけられるようにできます。 + + + +
+ レスポンス例 + + +
+ +検索構文は基本的に single-tenant コレクションの場合と同一であることがわかります。そのため、 single-tenant コレクションで利用できるすべての検索方法は multi-tenant コレクションにも適用できます。 + +### 要約 + +このセクションでは、マルチテナントコレクションにおいてテナントとそのデータを操作する方法を学びました。テナントの作成、データオブジェクトの追加、およびテナントデータのクエリ方法を確認しました。 + +次のセクションでは、 `MyPrivateJournal` がテナントを管理することで、アプリケーションをスムーズかつ効率的に動作させ続ける方法を学びます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/400_manage_tenants.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/400_manage_tenants.mdx new file mode 100644 index 000000000..20fd6f23f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/400_manage_tenants.mdx @@ -0,0 +1,199 @@ +--- +title: テナントを管理する +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +## テナントのアクティビティステータス + +`MyPrivateJournal` が成長するにつれ、チームはリソース要件とそれに伴うコストが増加していることに気付きます。 + +同時に、チームは次のような利用パターンも確認しています。 + +- 多くのユーザーは 1 日のうち短時間だけアプリを使い、その後ログオフします。 +- まれにしかアクセスしないユーザーもいます。 +- しばらくすると離脱し、長期間データにアクセスしなくなるユーザーもいます。 + +Weaviate のマルチテナンシー機能を利用すると、`MyPrivateJournal` はこれらの利用パターンをより効率的に管理できます。以下で詳しく見てみましょう。 + +### テナントのアクティビティステータスの概要 + +まず、テナントのアクティビティステータスについて少し説明します。これまではステータスを指定せずにテナントを作成してきましたが、その場合、デフォルトで `ACTIVE` になります。 + +テナントのステータスには `ACTIVE`、`INACTIVE`、`OFFLOADED` の 3 種類があります。 + +| テナント状態 | CRUD とクエリ | ベクトルインデックス | 転置インデックス | オブジェクトデータ | アクティブ化までの時間 | テナントの説明 | +|-------------|--------------|---------------------|-----------------|-------------------|------------------------|----------------| +| Active (デフォルト) | **はい** | Hot/Warm | Warm | Warm | なし | 使用可能 | +| Inactive | **いいえ** | Warm | Warm | Warm | 高速 | 使用不可 (ローカル保存) | +| Offloaded | **いいえ** | Cold | Cold | Cold | 低速 | 使用不可 (クラウド保存) | + +これらのステータスは変更可能で、コスト・可用性・パフォーマンスのバランスを取りながらテナントを柔軟に管理できます。 + +### テナントのアクティビティステータスを管理する + +ここまでで、`MyPrivateJournal` がテナントのアクティビティステータスを活用し、運用効率を向上できることがわかってきました。 + +#### テナントを非アクティブ化する + +`INACTIVE` テナントは `ACTIVE` テナントよりも少ないリソースで済むため、`MyPrivateJournal` は直ちにアクセスされる可能性が低いテナントを非アクティブ化できます。 + +例として、ユーザーがアプリからログアウトしたタイミングで、そのテナントを `INACTIVE` に設定できます。 + + + +#### 複数のテナントを非アクティブ化する + +`MyPrivateJournal` は複数のテナントをまとめて非アクティブ化することもできます。たとえば、ローカルの夜間に全テナントを非アクティブ化したり、7 日以上ログインしていないテナントを非アクティブ化したりできます。 + + + +#### テナントをオフロードする + +`MyPrivateJournal` はテナントをクラウドへオフロードすることもできます。近い将来アクセスされる可能性が低いテナントに有効です。 + +たとえば、30 日以上アクセスされていないテナントをオフロードできます。 + + + +これにより、テナントのデータがコールドストレージへ移動し、Hot および Warm リソースが解放されます。結果として、システム全体の要件とコストを削減できます。 + +
+ オフロードの設定方法 + +import OffloadingLimitation from '/_includes/offloading-limitation.mdx'; + + + +テナントをコールドストレージへオフロードできる機能は、Weaviate インスタンスのリソース使用量を管理する強力な手段です。 +
+ +Weaviate でテナントオフロードを利用するには、対応するオフロード [module](../../../weaviate/configuration/modules.md) を有効にする必要があります。デプロイ方法が Docker か Kubernetes かに応じて、以下のように `offload-s3` モジュールを有効化できます。 + + + + +```yaml +services: + weaviate: + environment: + # highlight-start + ENABLE_MODULES: 'offload-s3' # plus other modules you may need + OFFLOAD_S3_BUCKET: 'weaviate-offload' # the name of the S3 bucket + OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true' # create the bucket if it does not exist + # highlight-end +``` + + + + +```yaml +offload: + s3: + enabled: true # Set this value to true to enable the offload-s3 module + envconfig: + OFFLOAD_S3_BUCKET: weaviate-offload # the name of the S3 bucket + OFFLOAD_S3_BUCKET_AUTO_CREATE: true # create the bucket if it does not exist +``` + + + + +対象の S3 バケットが存在しない場合、`OFFLOAD_S3_BUCKET_AUTO_CREATE` 変数を `true` に設定すると、Weaviate がバケットを自動作成します。 +
+ +#### AWS パーミッション + +Weaviate には AWS 認証情報を提供する必要があります。アクセスキー方式と ARN 方式のいずれかを選択できます。 +
+ +:::tip Requirements +Weaviate インスタンスには [S3 バケットへアクセスするための必要なパーミッション](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-policy-language-overview.html) が必要です。 +- 指定した AWS アイデンティティにはバケットへの書き込み権限が必要です。 +- `OFFLOAD_S3_BUCKET_AUTO_CREATE` を `true` にする場合、バケット作成権限も必要です。 +::: + +**Option 1: With IAM and ARN roles** +
+ +バックアップモジュールはまず AWS IAM での認証を試みます。失敗した場合は `Option 2` の方法で認証を試みます。 +
+ +**Option 2: With access key and secret access key** +
+ +| 環境変数 | 説明 | +| --- | --- | +| `AWS_ACCESS_KEY_ID` | 対象アカウントの AWS アクセスキー ID。 | +| `AWS_SECRET_ACCESS_KEY` | 対象アカウントの AWS シークレットアクセスキー。 | +| `AWS_REGION` | (任意) AWS リージョン。設定しない場合、モジュールは `AWS_DEFAULT_REGION` を参照します。 | + +`offload-s3` モジュールを有効化した後は、テナントのアクティビティステータスを `OFFLOADED` に設定して S3 バケットへオフロードしたり、`ACTIVE` または `INACTIVE` に設定してローカルストレージへ戻したりできます。 + +
+#### ユーザーのアクティベーション + +そして、 `MyPrivateJournal` は必要に応じてテナントをアクティベートできます。たとえば、ユーザーがログインしたときや、非アクティベーションとは逆のパターンでユーザーのローカル時間に基づいてテナントをアクティベートすることが可能です。 + + + +#### 自動アクティベーションの活用 + +ユーザーが `INACTIVE` テナントに対してクエリを実行しようとする場合もあります。 + +これは問題のように思えるかもしれませんが、コレクションを `auto_tenant_activation` を有効にして作成していれば([前のステップで設定しました](./200_setup.mdx#-create-a-collection))、 Weaviate はクエリに合わせてテナントを自動的にアクティベートできます。 + +## ユーザーのオフボーディング + +すべての SaaS アプリケーションと同様に、 `MyPrivateJournal` でもユーザーを随時オフボーディングする必要があります。これはユーザーからの要請やアカウント削除のほか、さまざまな理由によるものです。 + +マルチテナント コレクションでは、ユーザーをオフボーディングするにはそのテナントを削除するだけで済みます。これによりテナントとそのデータがすべて削除されます。 + + + +`MyPrivateJournal` のエンジニアは、ユーザーがアカウントを削除したりデータ削除を要求したりした際に、そのユーザーのテナントを削除するオフボーディング システムを構築できます。これにより、ユーザーデータがシステムから確実に削除されます。 + +### まとめ + +このセクションでは、マルチテナント コレクションにおけるテナント管理方法について学びました。以下の操作方法をご紹介しました。 + +- テナントのアクティビティ ステータスを更新する +- テナントをコールドストレージへオフロードする +- 必要に応じてテナントをアクティベートする +- テナントをシステムから削除する + +これらの機能により、 `MyPrivateJournal` はリソース使用量をより効果的に管理し、ユーザーにより良い体験を提供できます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/900_next_steps.mdx new file mode 100644 index 000000000..cf96779a2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/900_next_steps.mdx @@ -0,0 +1,42 @@ +--- +title: まとめ / 次のステップ +--- + +おめでとうございます!マルチテナンシーに関するこのコースを修了しました。役立つ内容であったことを願っています。 + +## マルチテナントコレクション + +マルチテナントコレクションは、単一の Weaviate インスタンスで複数のテナントを管理できる強力な機能です。各テナントは独立したデータを持ちながら、同じスキーマと設定を共有します。 + +マルチテナントコレクションは複数の Weaviate コレクションを作成する場合に比べ、はるかに効率的です。これにより、アプリケーションをより簡単かつコスト効率良くスケールできます。 + +## マルチテナンシーとリソース管理 + +各テナントはコレクションに属しており同じ設定を共有しますが、テナントごとにリソースを個別に管理できます。 + +これはテナントの state を `ACTIVE`、`INACTIVE`、`OFFLOADED` のいずれかに設定する、あるいはインデックスタイプを `dynamic` に設定することで実現できます。`dynamic` を使用すると、各テナントはオブジェクト数が一定のしきい値を超えた後にのみ HNSW を使用します。 + +テナントごとのリソースを慎重に管理する戦略を構築することで、アプリケーションのパフォーマンスとコスト効率を最適化できます。 + +## さらなるリソース + +学習を続ける際は、以下のリソースをご活用ください。 + +- [スターターガイド: リソース管理](/weaviate/starter-guides/managing-resources/index.md) +- [コンセプト: マルチテナンシー](/weaviate/concepts/data.md#multi-tenancy) +- [ハウツー: コレクションの管理](../../../weaviate/manage-collections/index.mdx) +- [ハウツー: マルチテナント操作](/weaviate/manage-collections/multi-tenancy.mdx) +- [ハウツー: テナント state の管理](/weaviate/manage-collections/tenant-states.mdx) +- [Weaviate Academy: ベクトルインデックス](../vector_index/index.md) + +import CTASocials from '../_snippets/cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/_snippets/100_config.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/_snippets/100_config.py new file mode 100644 index 000000000..327f91870 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/_snippets/100_config.py @@ -0,0 +1,355 @@ +# FullBasicMT +import weaviate +import os +from weaviate.classes.config import Configure, Property, DataType + +client = weaviate.connect_to_local( + headers={ + "X-Cohere-Api-Key": os.getenv("COHERE_APIKEY"), + } +) + +mt_collection_name = "JournalEntry" + +# END FullBasicMT + +client.collections.delete(mt_collection_name) + +# ================================================================================ +# MyPrivateJournal multi-tenancy configuration +# ================================================================================ + +client.close() + +client = weaviate.connect_to_local( + headers={ + "X-Cohere-Api-Key": os.getenv("COHERE_APIKEY"), + } +) + +client.collections.delete(mt_collection_name) + +# MTConfig # MTFullCollectionCreation +from weaviate.classes.config import Configure, Property, DataType + +mt_collection = client.collections.create( + name=mt_collection_name, # e.g. "JournalEntry" + # highlight-start + multi_tenancy_config=Configure.multi_tenancy( + enabled=True, + auto_tenant_creation=True, + auto_tenant_activation=True, + ), + # highlight-end + # END MTConfig # MTFullCollectionCreation + properties=[ + Property(name="text", data_type=DataType.TEXT), + Property(name="date", data_type=DataType.DATE), + Property(name="tags", data_type=DataType.TEXT_ARRAY), + ], + # DynamicIndexConfig # MTFullCollectionCreation + vector_config=[ + Configure.Vectors.text2vec_cohere( + name="text", + source_properties=["text"], + # highlight-start + vector_index_config=Configure.VectorIndex.dynamic( + hnsw=Configure.VectorIndex.hnsw( + quantizer=Configure.VectorIndex.Quantizer.sq(training_limit=50000) + ), + flat=Configure.VectorIndex.flat( + quantizer=Configure.VectorIndex.Quantizer.bq() + ), + threshold=10000 + ) + # highlight-end + ) + ], + # END DynamicIndexConfig # END MTVectorIndexConfig # MTFullCollectionCreation + generative_config=Configure.Generative.cohere(model="command-r-plus") + # MTConfig +) +# END MTConfig # END MTFullCollectionCreation + +# ================================================================================ +# Basic tenant creation +# ================================================================================ + +# BasicTenantCreation +# highlight-start +mt_collection.tenants.create("steve85") # Create a tenant, e.g. based on a username +# highlight-end +# END BasicTenantCreation + +# MultiTenantCreation +new_usernames = ["bob1", "alice2", "etienne3"] + +# highlight-start +mt_collection.tenants.create(new_usernames) # Create multiple tenants +# highlight-end +# END MultiTenantCreation + +# ================================================================================ +# Single object insertion +# ================================================================================ + +# SingleObjectInsertion +from datetime import datetime, timezone + +# Start with the collection object and specify the tenant +tenant = mt_collection.with_tenant("steve85") + +tenant.data.insert( + properties={ + "text": "What amazing food we had at Quay! It was totally worth it.", + "date": datetime(2024, 5, 15).replace(tzinfo=timezone.utc), + "tags": ["restaurant", "experience"], + } +) +# END SingleObjectInsertion + +# ================================================================================ +# Batch data insertion +# ================================================================================ + +# BatchDataToInsert +from datetime import datetime, timezone + +journal_entries = [ + { + "text": "The Top Gun sequel was amazing!", + "date": datetime(2022, 5, 30).replace(tzinfo=timezone.utc), + "tags": ["movie", "action"], + }, + { + "text": "Ahhh the Taylor Swift Eras concert in Denver was sooo much better than I could have hoped for!", + "date": datetime(2023, 7, 14).replace(tzinfo=timezone.utc), + "tags": ["music", "swifties", "concert"], + }, + { + "text": "After watching Kate McKinnon play Weird Barbie I totally feel seen.", + "date": datetime(2023, 7, 25).replace(tzinfo=timezone.utc), + "tags": ["movie", "barbie", "happy"], + }, + { + "text": "Spring is here and I'm loving the new flowers in the garden!", + "date": datetime(2024, 4, 5).replace(tzinfo=timezone.utc), + "tags": ["garden", "home"], + }, + { + "text": "I went to a cooking class and learned how to make sushi!", + "date": datetime(2024, 5, 16).replace(tzinfo=timezone.utc), + "tags": ["cooking", "hobby"], + }, + { + "text": "The new taco place in town is amazing!", + "date": datetime(2024, 7, 20).replace(tzinfo=timezone.utc), + "tags": ["food", "restaurant"], + }, +] +# END BatchDataToInsert + +# BasicBatchInsertion +tenant = mt_collection.with_tenant("steve85") + +with tenant.batch.fixed_size(100) as batch: + for journal_entry in journal_entries: + batch.add_object(journal_entry) +# END BasicBatchInsertion + +# ================================================================================ +# Auto tenant creation +# ================================================================================ + +# AutoTenantCreationAtInsert +nonexistent_tenant = mt_collection.with_tenant("newsteve15") + +nonexistent_tenant.data.insert({ + "date": datetime(2024, 7, 7).replace(tzinfo=timezone.utc), + "tags": ["events", "grand prix"], + "text": "Going to Silverstone was a dream come true!", +}) +# END AutoTenantCreationAtInsert + +# ================================================================================ +# Filtering by date range +# ================================================================================ + +# DateRangeQuery +from weaviate.classes.query import Filter +from datetime import datetime, timezone + +tenant = mt_collection.with_tenant("steve85") + +start_date = datetime(2023, 7, 1).replace(tzinfo=timezone.utc) +end_date = datetime(2023, 7, 31).replace(tzinfo=timezone.utc) + +response = tenant.query.fetch_objects( + filters=( + Filter.by_property("date").greater_or_equal(start_date) & + Filter.by_property("date").less_or_equal(end_date) + ), + limit=10 +) +# END DateRangeQuery + +for obj in response.objects: + print(obj.properties) + +""" +# ExampleResponseDateRange +{ + "text": "Ahhh the Taylor Swift Eras concert in Denver was sooo much better than I could have hoped for!", + "date": datetime.datetime(2023, 7, 14, 0, 0, tzinfo=datetime.timezone.utc), + "tags": ["music", "swifties", "concert"], +} +{ + "text": "After watching Kate McKinnon play Weird Barbie I totally feel seen.", + "date": datetime.datetime(2023, 7, 25, 0, 0, tzinfo=datetime.timezone.utc), + "tags": ["movie", "barbie", "happy"], +} +# END ExampleResponseDateRange +""" + +# ================================================================================ +# User query +# ================================================================================ + +# UserQuery +tenant = mt_collection.with_tenant("steve85") + +response = tenant.query.hybrid( + query="food experience", + limit=2 +) +# END UserQuery + +for obj in response.objects: + print(obj.properties) + +""" +# ExampleResponseUserQuery +{ + "date": datetime.datetime(2024, 5, 15, 0, 0, tzinfo=datetime.timezone.utc), + "tags": ["restaurant", "experience"], + "text": "What amazing food we had at Quay! It was totally worth it.", +} +{ + "date": datetime.datetime(2024, 5, 16, 0, 0, tzinfo=datetime.timezone.utc), + "tags": ["cooking", "hobby"], + "text": "I went to a cooking class and learned how to make sushi!", +} +# END ExampleResponseUserQuery +""" + +# ================================================================================ +# Deactivate a tenant +# ================================================================================ + +mt_collection.tenants.create(["travis1989"]) + +# UpdateOneTenantStatus +from weaviate.classes.tenants import Tenant, TenantActivityStatus + +mt_collection = client.collections.use(mt_collection_name) + +mt_collection.tenants.update( + Tenant(name="travis1989", activity_status=TenantActivityStatus.INACTIVE) +) +# END UpdateOneTenantStatus + + +# ================================================================================ +# Deactivate multiple tenants +# ================================================================================ + +inactive_users = [f"user{100+i}" for i in range(10)] + +# UpdateMultipleTenantStatuses +from weaviate.classes.tenants import Tenant, TenantActivityStatus + +mt_collection = client.collections.use(mt_collection_name) + +tenants_to_deactivate = [ + Tenant(name=user, activity_status=TenantActivityStatus.INACTIVE) + for user in inactive_users +] + +mt_collection.tenants.update(tenants_to_deactivate) +# END UpdateMultipleTenantStatuses + +tenant_names_to_offload = [] # List of tenants to offload + +# OffloadMultipleTenants +from weaviate.classes.tenants import Tenant, TenantActivityStatus + +mt_collection = client.collections.use(mt_collection_name) + +tenants_to_offload = [ + Tenant(name=user, activity_status=TenantActivityStatus.OFFLOADED) + for user in tenant_names_to_offload +] + +mt_collection.tenants.update(tenants_to_offload) +# END OffloadMultipleTenants + +tenant_names_to_activate = [] # List of tenants to offload + +# ActivateMultipleTenants +from weaviate.classes.tenants import Tenant, TenantActivityStatus + +mt_collection = client.collections.use(mt_collection_name) + +tenants_to_activate = [ + Tenant(name=user, activity_status=TenantActivityStatus.ACTIVE) + for user in tenant_names_to_activate +] + +mt_collection.tenants.update(tenants_to_activate) +# END ActivateMultipleTenants + +# ================================================================================ +# Remove tenants +# ================================================================================ + +# RemoveTenants +from weaviate.classes.tenants import Tenant + +mt_collection = client.collections.use(mt_collection_name) + +# Caution - this will remove all of the associated data for the tenants +mt_collection.tenants.remove([ + "depardieu10", + "travis1989", +]) +# END RemoveTenants + +# ================================================================================ +# Misc methods +# ================================================================================ + +# +mt_collection = client.collections.use(mt_collection_name) + +all_tenants = mt_collection.tenants.get() +for k, v in all_tenants.items(): + print(k, v) + +tenants = mt_collection.tenants.get_by_names(["bob1", "alice1"]) +for k, v in tenants.items(): + print(k, v) + +tenant = mt_collection.tenants.get_by_name("bob1") +print(tenant) + +print(mt_collection.tenants.exists("etienne1")) + + + + + + + + + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/img/multi-tenancy-dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/img/multi-tenancy-dark.png new file mode 100644 index 000000000..88449c466 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/img/multi-tenancy-dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/img/multi-tenancy-light.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/img/multi-tenancy-light.png new file mode 100644 index 000000000..e2b5036dc Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/img/multi-tenancy-light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/index.md new file mode 100644 index 000000000..7525f0949 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/multitenancy/index.md @@ -0,0 +1,29 @@ +--- +title: "280 マルチテナンシー (MT)" +description: "Python アプリケーションにおいて、分離されたデータ環境のために Weaviate でマルチテナンシーを実装します。" +sidebar_position: 280 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +:::info 前提条件 +このコースは自己完結型です。ただし、[テキスト](../starter_text_data/index.md)、[独自の ベクトル](../starter_custom_vectors/index.md)、または[マルチモーダル データ](../starter_multimodal_data/index.md)を扱う 101 レベルのコースのいずれかを先に受講することをおすすめします。 +::: + +マルチテナンシーを使用すると、多数の軽量な「テナント」を含む Weaviate コレクションを作成できます。 + +テナントは、分離された同一のデータ構造を保持するよう設計されています。これは、各エンドユーザーのデータをテナント単位で管理するソフトウェア・アズ・ア・サービス (SaaS) タイプのアプリケーションなどのユースケースに適しています。テナントは個別に管理でき、メモリやディスク使用量を削減するためにコールドストレージへオフロードすることも可能です。 + +このコースでは、マルチテナンシーの概要を紹介し、Weaviate でマルチテナント コレクションを有効化・設定する方法、そしてテナントおよびテナント データを操作する方法を学びます。 + +## 学習目的 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/101_nv_preparation/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/101_nv_preparation/index.mdx new file mode 100644 index 000000000..7624e26c6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/101_nv_preparation/index.mdx @@ -0,0 +1,163 @@ +--- +title: 準備 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/101_connect.py'; + +:::info 前提条件 +このコースは単独でも完結しています。しかし、[テキスト](../../starter_text_data/index.md)、[独自ベクトル](../../starter_custom_vectors/index.md)、または[マルチモーダル データ](../../starter_multimodal_data/index.md) を扱う 101 レベルのいずれかのコースを先に受講することをおすすめします。 +::: + +このページでは、必要なリソースとセットアップ手順について簡単に説明します。具体的には、Weaviate Python クライアント ライブラリと、マルチモーダル ベクトライザーを搭載した Weaviate インスタンスを準備します。 + +## Weaviate Python クライアント ライブラリ + +最新の(`v4` 例: `4.5.0`)Weaviate Python クライアント ライブラリを次のコマンドでインストールします: + +```bash +pip install -U weaviate-client +``` + +## Weaviate をセットアップ + +マシンに Docker をインストールします。公式の [Docker インストール ガイド](https://docs.docker.com/get-docker/) に従うことをおすすめします。 + +新しいディレクトリを作成し、ターミナルでそのディレクトリに移動します。次に、`docker-compose.yml` というファイルを作成し、以下の内容を追加します: + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + volumes: + - weaviate_data:/var/lib/weaviate + restart: on-failure:0 + environment: + CLIP_INFERENCE_API: 'http://multi2vec-clip:8080' + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'multi2vec-clip' + ENABLE_API_BASED_MODULES: 'true' + CLUSTER_HOSTNAME: 'node1' + multi2vec-clip: + image: cr.weaviate.io/semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1 + environment: + ENABLE_CUDA: '0' +volumes: + weaviate_data: +... + +``` + +### Weaviate インスタンスを作成 + +次のコマンドを実行して Weaviate を起動します: + +```bash +docker compose up +``` + +### Weaviate インスタンスの詳細 + +インスタンスが作成されると、`http://localhost:8080` でアクセスできます。 + +## Weaviate を操作する + +### Weaviate インスタンスへ接続 + +Weaviate インスタンスへ接続するには、`connect_to_local` 関数を使用します。ここでは、Weaviate が利用する推論 API(例: OpenAI、Cohere、Google、AWS など)の API キーも設定します。 + + + +### Weaviate のステータスを確認 + +`is_live` 関数を使って、Weaviate インスタンスが起動しているかどうかを確認できます。 + + + +### サーバーのメタ情報を取得 + +`meta` 関数を使用して、Weaviate インスタンスのメタ情報を取得できます。 + + + +このコマンドを実行すると、サーバーのメタ情報がコンソールに表示されます。出力は次のようになります: + +
+ get_meta 出力 + +CLIP モデルに関する追加情報が含まれるため、出力は少し長くなります。 + + +
+ +### 接続を閉じる + +Weaviate クライアントの使用が終わったら、接続を閉じてください。これによりリソースが解放され、接続が適切に終了します。 + +ベストプラクティスとして、`try`-`finally` ブロックを使用することを推奨します。簡潔さのため、以降のコード スニペットでは `try`-`finally` ブロックを省略します。 + + + +## ソース データ + +今回は、[TMDB](https://www.themoviedb.org/) から取得した映画データセットを使用します。データセットはこの [GitHub リポジトリ](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json) にあり、1990 年から 2024 年までに公開された約 700 本の映画に関する書誌情報が含まれています。 + +マルチモーダル プロジェクトとして、同じリポジトリにある[各映画のポスター](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024_posters.zip) も使用します。 + +
+ サンプル テキスト データを見る + +| | backdrop_path | genre_ids | id | original_language | original_title | overview | popularity | poster_path | release_date | title | video | vote_average | vote_count | +|---:|:---------------------------------|:----------------|-----:|:--------------------|:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------:|:---------------------------------|:---------------|:----------------------------|:--------|---------------:|-------------:| +| 0 | /3Nn5BOM1EVw1IYrv6MsbOS6N1Ol.jpg | [14, 18, 10749] | 162 | en | Edward Scissorhands | A small suburban town receives a visit from a castaway unfinished science experiment named Edward. | 45.694 | /1RFIbuW9Z3eN9Oxw2KaQG5DfLmD.jpg | 1990-12-07 | Edward Scissorhands | False | 7.7 | 12305 | +| 1 | /sw7mordbZxgITU877yTpZCud90M.jpg | [18, 80] | 769 | en | GoodFellas | The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway. | 57.228 | /aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg | 1990-09-12 | GoodFellas | False | 8.5 | 12106 | +| 2 | /6uLhSLXzB1ooJ3522ydrBZ2Hh0W.jpg | [35, 10751] | 771 | en | Home Alone | Eight-year-old Kevin McCallister makes the most of the situation after his family unwittingly leaves him behind when they go on Christmas vacation. But when a pair of bungling burglars set their sights on Kevin's house, the plucky kid stands ready to defend his territory. By planting booby traps galore, adorably mischievous Kevin stands his ground as his frantic mother attempts to race home before Christmas Day. | 3.538 | /onTSipZ8R3bliBdKfPtsDuHTdlL.jpg | 1990-11-16 | Home Alone | False | 7.4 | 10599 | +| 3 | /vKp3NvqBkcjHkCHSGi6EbcP7g4J.jpg | [12, 35, 878] | 196 | en | Back to the Future Part III | The final installment of the Back to the Future trilogy finds Marty digging the trusty DeLorean out of a mineshaft and looking for Doc in the Wild West of 1885. But when their time machine breaks down, the travelers are stranded in a land of spurs. More problems arise when Doc falls for pretty schoolteacher Clara Clayton, and Marty tangles with Buford Tannen. | 28.896 | /crzoVQnMzIrRfHtQw0tLBirNfVg.jpg | 1990-05-25 | Back to the Future Part III | False | 7.5 | 9918 | +| 4 | /3tuWpnCTe14zZZPt6sI1W9ByOXx.jpg | [35, 10749] | 114 | en | Pretty Woman | When a millionaire wheeler-dealer enters a business contract with a Hollywood hooker Vivian Ward, he loses his heart in the bargain. | 97.953 | /hVHUfT801LQATGd26VPzhorIYza.jpg | 1990-03-23 | Pretty Woman | False | 7.5 | 7671 | + +
+## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/20_create_collection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/20_create_collection.mdx new file mode 100644 index 000000000..effd18b42 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/20_create_collection.mdx @@ -0,0 +1,64 @@ +--- +title: コレクションの作成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +名前付き ベクトル を使用するには、コレクションに名前付き ベクトル 定義を設定する必要があります。 + +## コード + +次の例では、複数の名前付き ベクトル 定義を含む映画データ用のコレクションを作成します。 + + + +## コード解説 + +ここでの主な違いは、`NamedVectors` クラスを使用してベクトライザー設定を定義している点です。コードを詳しく見ていきましょう。 + +:::tip Revision +このコードは [multimodal](../../starter_multimodal_data/102_mm_collections/20_create_collection.mdx) の例を基にしています。詳細についてはその例を参照してください。 +::: + +### 名前付き ベクトル 設定 + +この定義により、各オブジェクトは `title`、`overview`、`poster_title` の 3 つの ベクトル で表現されます。 + + + +#### `title` + +この ベクトル 表現は `title` プロパティ(`source_properties`)から生成されます。`text2vec-openai` モジュールを使用してベクトル化します。 + +これを利用して、タイトルの類似性で映画を検索できます。 + +#### `overview` + +この ベクトル 表現は `overview` プロパティに基づいています。そのため、ストーリーや主要なアイデアの類似性で映画を検索できます。 + +#### `poster_title` + +この ベクトル 表現は `title` と `poster` のプロパティを組み合わせて生成されます。`multi2vec-clip` モジュールを使用してベクトル化します。 + +ベクトル の重みの大部分(90%)が `poster` プロパティに、残り(10%)が `title` プロパティに割り当てられている点に注意してください。つまり、この ベクトル 表現はタイトルよりポスターの影響を強く受けます。 + +マルチモーダル ベクトライザー を使用しているため、任意の画像やテキストで、タイトルやポスターとの類似性を基に映画を検索できます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/30_import_data.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/30_import_data.mdx new file mode 100644 index 000000000..4a1b5a120 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/30_import_data.mdx @@ -0,0 +1,52 @@ +--- +title: データのインポート +description: "Named Vectors コレクションへのデータのインポート" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +## コード + +この例では、映画データをコレクションにインポートします。 + +驚くべきことに、[マルチモーダルコース](../../starter_multimodal_data/102_mm_collections/20_create_collection.mdx)で単一ベクトル構成に使用したのとまったく同じコードをここでも利用できます。これは、名前付きベクトルの設定がコレクション定義内で行われており、残りを Weaviate が処理してくれるためです。 + + + +コードの流れ: +- 元のテキストと画像データを読み込む +- コレクションを取得する +- バッチャー (`batch`) オブジェクトを使ってコンテキストマネージャーに入る +- データをループ処理し、 + - テキストに対応する画像を見つける + - 画像を base64 に変換する + - オブジェクトをバッチャーに追加する +- インポートエラーを出力する + +コードの詳細な解説はここでは繰り返しません。同じ内容はマルチモーダルコースで説明していますので、復習したい場合は[こちら](../../starter_multimodal_data/102_mm_collections/20_create_collection.mdx)をご覧ください。 + +## ベクトルの生成元 + +バッチャーがキューを Weaviate に送信すると、オブジェクトがコレクション(今回は映画コレクション)へ追加されます。 + +ここで思い出してほしいのは、各オブジェクトには `title`、`overview`、`poster_title` の 3 つの名前付きベクトルがあるという点です。これらのベクトルは、コレクション定義で設定したベクトライザーによって生成されます。 + +- `title` ベクトルは `text2vec-openai` ベクトライザーで生成されます +- `overview` ベクトルは `text2vec-openai` ベクトライザーで生成されます +- `poster_title` ベクトルは `multi2vec-clip` ベクトライザーで生成されます + +次のセクションでは、これらの名前付きベクトルが検索時にどのような柔軟性を提供するかを探っていきます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/index.mdx new file mode 100644 index 000000000..51f24eee7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/102_nv_collections/index.mdx @@ -0,0 +1,24 @@ +--- +title: データベースにデータを投入する +description: Weaviate で最適化された検索のために、名前付き ベクトル コレクションを整理します。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/10_searches.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/10_searches.mdx new file mode 100644 index 000000000..d23850c4a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/10_searches.mdx @@ -0,0 +1,180 @@ +--- +title: 検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_searches.py'; + +named vectors を持つコレクションには複数の ベクトル 埋め込みを含めることができるため、あらゆる ベクトル 検索または類似度検索では「target」 ベクトル を指定する必要があります。 + +これは `near_text` と `near_vector` 検索だけでなく、`near_image` などのマルチモーダル検索にも適用されます。ここではいくつかの例を見てみましょう。 + +## テキスト検索 + +### コード + +ここでは "MovieNVDemo" 内から、フレーズ `"A joyful holiday film"` と意味的に近いエントリーを検索します。ただし、同じクエリでも `target_vector` パラメーターを変えた複数バージョンを示しています。 + + + + + + + + + + + + + +### コードの説明 + +ここで使用している各 named vector は、映画データの異なるプロパティに基づいています。 + +最初の検索は映画の **タイトル** の意味をクエリと比較し、2 番目の検索は映画の **全文サマリー**(overview)を比較し、3 番目は **ポスター(およびタイトル)** を比較します。 + +Weaviate では、各 named vector に異なる ベクトライザー を設定することもできます。ご存じのとおり `poster_title` ベクトルは CLIP モデルによって作成され、`title` と `overview` プロパティは OpenAI モデルによって作成されています。 + +その結果、適切なプロパティに対して適切なモデルを使用することで、各 named vector をさらに特化させることができます。 + +### 結果の説明 + +検索はそれぞれ異なるプロパティを基にしているため、結果も異なります。 + +#### `title` vs `overview` + +`overview` ターゲット ベクトルでの検索結果には、「Home Alone」や「Home Alone 2: Lost in New York」など、他の検索には含まれていないタイトルが表示されています。 + +これは、これらの映画のストーリーがホリデーをテーマにしている一方で、タイトル自体は明らかに楽しい休日やホリデーを示唆していないためです。 + +#### `poster` + +`poster_title` ターゲット ベクトルでの検索結果には興味深いことにスティーヴン・キング原作のホラー映画「Misery」が含まれています。これは映画のポスターが雪景色であり、CLIP ベクトライザーが画像の要素を認識するよう訓練されているためと考えられます。この恐ろしい映画でも、ポスターだけを見れば検索結果として「間違い」とは言い切れません。本や映画を知っている人なら同意するでしょうが。 + + + + +```text +How the Grinch Stole Christmas 2000 8871 +Distance to query: 0.162 + +The Nightmare Before Christmas 1993 9479 +Distance to query: 0.177 + +The Pursuit of Happyness 2006 1402 +Distance to query: 0.182 + +Jingle All the Way 1996 9279 +Distance to query: 0.184 + +Mrs. Doubtfire 1993 788 +Distance to query: 0.189 +``` + + + + +```text +How the Grinch Stole Christmas 2000 8871 +Distance to query: 0.148 + +Home Alone 1990 771 +Distance to query: 0.164 + +Onward 2020 508439 +Distance to query: 0.172 + +Home Alone 2: Lost in New York 1992 772 +Distance to query: 0.175 + +Little Miss Sunshine 2006 773 +Distance to query: 0.176 +``` + + + + +上位 5 件のポスター: +Life Is Beautiful +Groundhog Day +Jingle All the Way +Training Day +Misery + +```text +Life Is Beautiful 1997 637 +Distance to query: 0.621 + +Groundhog Day 1993 137 +Distance to query: 0.623 + +Jingle All the Way 1996 9279 +Distance to query: 0.625 + +Training Day 2001 2034 +Distance to query: 0.627 + +Misery 1990 1700 +Distance to query: 0.632 +``` + + + + +## ハイブリッド検索 + +### コード + +次の例では "MovieNVDemo" 内から "history" という語のハイブリッド検索スコアが最も高いエントリーを探し、上位 5 件のタイトルと公開年を表示します。 + + + +### コードの説明 + +named vectors でのハイブリッド検索は、他の named vector を使った ベクトル 検索と同じ仕組みで動作します。ハイブリッド検索の ベクトル 検索部分で使用する named vector を指定するために、`target_vector` パラメーターを必ず渡してください。 + +## キーワード検索 + +named vectors はオブジェクトの ベクトル 表現に影響を与えますが、キーワード検索には影響しません。named vector コレクションでも、他のコレクションと同じ構文でキーワード検索を実行できます。 + +## 検索における名前付き ベクトル + +named vectors を使用すると、ニーズに合わせて柔軟な検索オプションを設定できます。 + +各オブジェクトには、任意のプロパティと ベクトライザー の組み合わせ、あるいは独自モデルで作成した複数のカスタム ベクトル など、必要なだけ多くの named vectors を持たせることができます。 + +この柔軟性により、特定のユースケースに最適化された ベクトル 表現を持つデータベースを構築し、任意のプロパティの組み合わせに基づいて類似アイテムを検索できます。 +## RAG について + + RAG (検索拡張生成)クエリで名前付き ベクトル を使用する場合も、他の名前付き ベクトル を使った ベクトル 検索と同じ方法で動作します。 RAG クエリの ベクトル 検索コンポーネントで使用する名前付き ベクトル を指定するには、`target_vector` パラメーターを必ず指定してください。 + +これにより、生成結果の品質を向上させられる可能性があります。いくつかの例を [次のセクション](./20_use_cases.mdx) で見ていきましょう。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/20_use_cases.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/20_use_cases.mdx new file mode 100644 index 000000000..54e34b915 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/20_use_cases.mdx @@ -0,0 +1,131 @@ +--- +title: ユースケース +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/104_usecase.py'; + + RAG ( Retrieval augmented generation )は、 ベクトル 検索と自然言語生成の強みを組み合わせた強力な機能です。 名前付き ベクトル を RAG クエリで使用すると、ワークフローと結果をさらに向上させることができます。 + +このセクションでは、同じコレクションを使用しながら、 名前付き ベクトル によって異なるユーザーが自身のニーズに合わせて検索と生成を行ういくつかの例を見ていきます。 + +## デザインエージェンシー:ポスターデザインの評価 + +新作映画のポスターデザインを委託されたデザインエージェンシー( *Aesthetico* )を想像してください。 + +Aesthetico のデザイナーは [この映画ポスター](https://upload.wikimedia.org/wikipedia/commons/7/78/1927_Boris_Bilinski_%281900-1948%29_Plakat_f%C3%BCr_den_Film_Metropolis%2C_Staatliche_Museen_zu_Berlin.jpg) を作成しました。彼らは、自分たちのポスターが既存の他の映画ポスターとどのように比較されるのか、またそれらのポスターがどのジャンルの映画に使われているのかを知りたいと考えています。 + +Metropolis poster + +幸運なことに、`MovieNVDemo` コレクションにはポスターデザインに基づく `poster_title` 名前付き ベクトル が用意されています。そのため Aesthetico のデザイナーは `poster_title` 名前付き ベクトル に対して検索を行い、自分たちのポスターに似た映画を探し出せます。そのうえで RAG を実行し、見つかった映画の概要を要約できます。 + +### コード + +次のクエリは、入力画像に似た映画を見つけ、その結果に対して RAG を使って洞察を提供します。 + + + +### 出力 + +以下は RAG クエリの例示的な出力です。 + +> これらの映画はアクション、 サイエンスフィクション、 スリラー、 ドラマに分類できます。観客は、サスペンス、ミステリー、そして幻想的な生物やシナリオが盛り込まれたアクション満載の作品を好む層が中心でしょう。これらの映画は、スーパーヒーロー映画のファン、 サイエンスフィクション 愛好家、緊張感あふれるストーリーラインを楽しむ視聴者など、幅広い層に訴求する可能性があります。 + +Aesthetico のデザイナーはこの情報を活用し、自身のポスターデザインに似た映画のタイプを理解してデザインの方向性をさらに洗練できます。 + +
+ 検索結果 + +Predator 2
+Inception
+Mission: Impossible
+The Dark Knight
+Lost in Translation
+Independence Day
+Godzilla vs. Kong
+Fargo
+The Amazing Spider-Man
+Godzilla
+ +
+ +## 映画脚本家:アイデアの評価 + +別のプロジェクトでは、*ScriptManiacs* の脚本家チームが サイエンスフィクション 映画の脚本に取り組んでいます。彼らはいくつかの映画タイトル案を検討しており、それぞれのタイトルにどのようなイメージやテーマが結び付くかを知りたいと考えています。 + +同じコレクションを使って、彼らの目的も達成できます。実際には、同一のコレクションに対して、`target_vector` パラメーターを変えながら複数回クエリを実行できます。 + +ScriptManiacs の脚本家は次のような検索が可能です。 +- `title` 名前付き ベクトル で検索し、*似たタイトル* の映画を見つける +- `overview` 名前付き ベクトル で検索し、*プロットが似ている* 映画を見つける + +では、タイトル案「Chrono Tides: The Anomaly Rift」を例に見てみましょう。 + +### コード + +次の例では、「Chrono Tides: The Anomaly Rift」との類似度に基づいて "MovieNVDemo" のエントリを検索し、さらに大規模言語モデルに共通点を抽出させています。 + +`for tgt_vector` ループに注目してください。これにより、同じクエリを異なる 名前付き ベクトル に対して実行できます。 + + + +### 出力 + +2つのクエリはまったく異なる出力を示しました。タイトル「Chrono Tides: The Anomaly Rift」に最も近いタイトルを検索すると、結果はアクション/アドベンチャー映画に偏りました。一方、そのタイトルと最も類似した概要を持つ映画を検索すると、 サイエンスフィクション とアドベンチャー映画が含まれました。 + +このようにして ScriptManiacs の脚本家は、タイトル案に関連する多様なテーマやジャンルを理解し、執筆に活かすことができます。 + +たとえば、「Chrono Tides: The Anomaly Rift」をアクション/アドベンチャー寄りの サイエンスフィクション として制作するのであれば、このタイトルは適していると言えるでしょう。一方、よりドラマチックまたはロマンチックなテーマを求めるのであれば、タイトルを再考する必要があるかもしれません。 + +概要検索の結果には複数の サイエンスフィクション とアドベンチャー映画が含まれており、脚本家たちが サイエンスフィクション 作品の命名として正しい方向に進んでいることを示しています。 + +#### 類似タイトル + +RAG クエリによると、「Chrono Tides: The Anomaly Rift」と類似タイトルを持つ映画には次の共通点があります。 + +> これらの映画は **アクション/アドベンチャー作品** で、ファンタジー、アドベンチャー、ロマンスを好む幅広い観客を対象としています。『Pirates of the Caribbean』や『Lara Croft』シリーズは海賊の冒険や財宝探索を、『The Croods』は家族向けアニメーションを、『The Twilight Saga』は超自然的ロマンスを、『Meg 2: The Trench』は水中スリラーとアクションを提供しています。総じて、これらの映画は高い緊張感、幻想的要素、ドラマチックなストーリーラインを楽しむ観客に訴求します。 + +
+ 検索結果 + +Pirates of the Caribbean: On Stranger Tides
+Lara Croft: Tomb Raider
+The Croods: A New Age
+The Twilight Saga: Breaking Dawn - Part 1
+Meg 2: The Trench
+ +
+ +#### 類似概要 + +「Chrono Tides: The Anomaly Rift」と最も類似した概要を持つ映画には次の共通点があります。 + +> これらの映画は ** サイエンスフィクション およびアドベンチャー作品** に分類できます。宇宙探査、古代文明、恐竜、自然災害、神話的冒険をテーマとしており、アクションとビジュアルの豊かな映画を好む観客に向けられています。ファンタジー要素とサスペンスを兼ね備えた作品を楽しむ層に最適です。 + +
+ 検索結果 + +Stargate
+Interstellar
+Jurassic Park III
+2012
+Moana
+ +
+## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/index.mdx new file mode 100644 index 000000000..a38c08034 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/103_nv_queries/index.mdx @@ -0,0 +1,24 @@ +--- +title: クエリの実行 +description: Weaviate で名前付き ベクトルをシームレスにクエリして整理します。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/900_next_steps.mdx new file mode 100644 index 000000000..b13bf0f8a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/900_next_steps.mdx @@ -0,0 +1,25 @@ +--- +title: 次のステップ +--- + +おめでとうございます! 名前付きベクトルに関するこのコースを完了しました。学習に役立ち、参考になったなら幸いです。 + +名前付きベクトルの学習をさらに深めるためのリソースはまだたくさんあります。 + +## ドキュメント + +- [Collection definition: named vectors](/weaviate/config-refs/collections#named-vectors): コレクションで名前付きベクトルを定義する方法のリファレンスです。 +- [How-to: Manage collections](/weaviate/manage-collections/index.mdx) と [How-to: Manage objects](/weaviate/manage-objects/index.mdx) のガイドでは、名前付きベクトルを含むコレクションやオブジェクトに対して作成・読み取り・更新・削除(i.e. create, read, update, delete)を行う方法を紹介しています。 +- [How-to: search](/weaviate/search/index.mdx): 名前付きベクトルを含むすべての検索操作のコード例を掲載しています。 + +import CTASocials from '../_snippets/cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/101_connect.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/101_connect.py new file mode 100644 index 000000000..c2d1018de --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/101_connect.py @@ -0,0 +1,531 @@ +# DockerInstantiation +import weaviate + +client = weaviate.connect_to_local() +# END DockerInstantiation + +client.close() + +# DockerAPIKeyInstantiation +import weaviate +import os + +headers = { + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") +} # Replace with your own API keys + +client = weaviate.connect_to_local(headers=headers) +# END DockerAPIKeyInstantiation + +# PollLiveness +assert client.is_live() # This will raise an exception if the client is not live +# END PollLiveness + + +# GetMeta +import json + +metainfo = client.get_meta() +print(json.dumps(metainfo, indent=2)) # Print the meta information in a readable format +# END GetMeta + + +""" +# OutputGetMeta +{ + "hostname": "http://[::]:8080", + "modules": { + "generative-openai": { + "documentationHref": "https://platform.openai.com/docs/api-reference/completions", + "name": "Generative Search - OpenAI" + }, + "multi2vec-clip": { + "clip_model": { + "_commit_hash": null, + "_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_clip-ViT-B-32/0_CLIPModel", + "add_cross_attention": false, + "architectures": [ + "CLIPModel" + ], + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "length_penalty": 1, + "logit_scale_init_value": 2.6592, + "max_length": 20, + "min_length": 0, + "model_type": "clip", + "no_repeat_ngram_size": 0, + "num_beam_groups": 1, + "num_beams": 1, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "text_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": 0, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": 2, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 512, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 2048, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "max_position_embeddings": 77, + "min_length": 0, + "model_type": "clip_text_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 8, + "num_beam_groups": 1, + "num_beams": 1, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": 1, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false, + "vocab_size": 49408 + }, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": "torch.float32", + "torchscript": false, + "transformers_version": null, + "typical_p": 1, + "use_bfloat16": false, + "vision_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 768, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "image_size": 224, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 3072, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "min_length": 0, + "model_type": "clip_vision_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 12, + "num_beam_groups": 1, + "num_beams": 1, + "num_channels": 3, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "patch_size": 32, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false + } + }, + "text_model": { + "_commit_hash": null, + "_name_or_path": "./models/text/0_CLIPModel", + "add_cross_attention": false, + "architectures": [ + "CLIPModel" + ], + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "length_penalty": 1, + "logit_scale_init_value": 2.6592, + "max_length": 20, + "min_length": 0, + "model_type": "clip", + "no_repeat_ngram_size": 0, + "num_beam_groups": 1, + "num_beams": 1, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "text_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": 0, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": 2, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 512, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 2048, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "max_position_embeddings": 77, + "min_length": 0, + "model_type": "clip_text_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 8, + "num_beam_groups": 1, + "num_beams": 1, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": 1, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false, + "vocab_size": 49408 + }, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": "torch.float32", + "torchscript": false, + "transformers_version": null, + "typical_p": 1, + "use_bfloat16": false, + "vision_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 768, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "image_size": 224, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 3072, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "min_length": 0, + "model_type": "clip_vision_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 12, + "num_beam_groups": 1, + "num_beams": 1, + "num_channels": 3, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "patch_size": 32, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false + } + } + }, + "text2vec-openai": { + "documentationHref": "https://platform.openai.com/docs/guides/embeddings/what-are-embeddings", + "name": "OpenAI Module" + }, + }, + "version": "1.23.9" +} +# END OutputGetMeta +""" + + +client.close() + + +# TryFinallyCloseDemo +import weaviate +import os + +# END TryFinallyCloseDemo + +client = weaviate.connect_to_local() + +# TryFinallyCloseDemo +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_local() + +try: + # Work with the client here - e.g.: + assert client.is_live() + pass + +finally: # This will always be executed, even if an exception is raised + client.close() # Close the connection & release resources +# END TryFinallyCloseDemo diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/102_collection.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/102_collection.py new file mode 100644 index 000000000..63eddb9bd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/102_collection.py @@ -0,0 +1,155 @@ +# CreateMovieCollection +import weaviate + +# CreateMovieCollection # SubmoduleImport +import weaviate.classes.config as wc + +# CreateMovieCollection # END SubmoduleImport + +# END CreateMovieCollection +client = weaviate.connect_to_local(port=8280, grpc_port=50251) + +# CreateMovieCollection +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_local(headers=headers) + +# END CreateMovieCollection + +# Actual instantiation + +client.collections.delete("MovieNVDemo") + +# CreateMovieCollection +client.collections.create( + name="MovieNVDemo", # The name of the collection ('NV' for named vectors) + properties=[ + wc.Property(name="title", data_type=wc.DataType.TEXT), + wc.Property(name="overview", data_type=wc.DataType.TEXT), + wc.Property(name="vote_average", data_type=wc.DataType.NUMBER), + wc.Property(name="genre_ids", data_type=wc.DataType.INT_ARRAY), + wc.Property(name="release_date", data_type=wc.DataType.DATE), + wc.Property(name="tmdb_id", data_type=wc.DataType.INT), + wc.Property(name="poster", data_type=wc.DataType.BLOB), + ], + # Define & configure the vectorizer module + vector_config=[ + # NamedVectorConfig # CreateMovieCollection + # Vectorize the movie title + wc.Configure.Vectors.text2vec_openai( + name="title", source_properties=["title"] + ), + # Vectorize the movie overview (summary) + wc.Configure.Vectors.text2vec_openai( + name="overview", source_properties=["overview"] + ), + # Vectorize the movie poster & title + wc.Configure.Vectors.multi2vec_clip( + name="poster_title", + image_fields=[ + wc.Multi2VecField(name="poster", weight=0.9) + ], # 90% of the vector is from the poster + text_fields=[ + wc.Multi2VecField(name="title", weight=0.1) + ], # 10% of the vector is from the title + ), + # END NamedVectorConfig # CreateMovieCollection + ], + # Define the generative module + generative_config=wc.Configure.Generative.openai(), +) + +client.close() +# END CreateMovieCollection + + +# BatchImportData +import weaviate +import pandas as pd +import requests +from datetime import datetime, timezone +import json +from weaviate.util import generate_uuid5 +from tqdm import tqdm +import os +import zipfile +from pathlib import Path +import base64 + +# END BatchImportData +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} +client = weaviate.connect_to_local(port=8280, grpc_port=50251, headers=headers) + +# BatchImportData +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_local() + +# END BatchImportData + +# BatchImportData +data_url = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json" +resp = requests.get(data_url) +df = pd.DataFrame(resp.json()) + +# Create a directory for the images +img_dir = Path("scratch/imgs") +img_dir.mkdir(parents=True, exist_ok=True) + +# Download images +posters_url = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024_posters.zip" +posters_path = img_dir / "movies_data_1990_2024_posters.zip" +posters_path.write_bytes(requests.get(posters_url).content) + +# Unzip the images +with zipfile.ZipFile(posters_path, "r") as zip_ref: + zip_ref.extractall(img_dir) + +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# END BatchImportData + +# df = df[:50] # Limit to 50 for testing purposes + +# BatchImportData +# Enter context manager +with movies.batch.fixed_size(50) as batch: + # Loop through the data + for i, movie in tqdm(df.iterrows()): + # Convert data types + # Convert a JSON date to `datetime` and add time zone information + release_date = datetime.strptime(movie["release_date"], "%Y-%m-%d").replace( + tzinfo=timezone.utc + ) + # Convert a JSON array to a list of integers + genre_ids = json.loads(movie["genre_ids"]) + # Convert image to base64 + img_path = img_dir / f"{movie['id']}_poster.jpg" + with open(img_path, "rb") as file: + poster_b64 = base64.b64encode(file.read()).decode("utf-8") + + # Build the object payload + movie_obj = { + "title": movie["title"], + "overview": movie["overview"], + "vote_average": movie["vote_average"], + "genre_ids": genre_ids, + "release_date": release_date, + "tmdb_id": movie["id"], + "poster": poster_b64, + } + + # Add object to batch queue + batch.add_object( + properties=movie_obj, + uuid=generate_uuid5(movie["id"]), + ) + # Batcher automatically sends batches + +# Check for failed objects +if len(movies.batch.failed_objects) > 0: + print(f"Failed to import {len(movies.batch.failed_objects)} objects") + for failed in movies.batch.failed_objects: + print(f"e.g. Failed to import object with error: {failed.message}") + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/103_searches.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/103_searches.py new file mode 100644 index 000000000..8c959955f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/103_searches.py @@ -0,0 +1,204 @@ +# START-ANY +import weaviate +import weaviate.classes.query as wq +import os + +# END-ANY + +# FilteredSemanticSearch +from datetime import datetime + +# END FilteredSemanticSearch + +# START-ANY + +# END-ANY + +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} +client = weaviate.connect_to_local( + port=8280, + grpc_port=50251, + headers=headers +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_local(headers=headers) + +# END-ANY + + +# NVTitleSearch +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# Perform query +response = movies.query.near_text( + query="A joyful holiday film", + # highlight-start + target_vector="title", # The target vector to search against + # highlight-end + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + return_properties=["title", "release_date", "tmdb_id", "poster"] +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year, o.properties["tmdb_id"] + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END NVTitleSearch + + +print("\n\n") + +client.connect() + + +# NVOverviewSearch +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# Perform query +response = movies.query.near_text( + query="A joyful holiday film", + # highlight-start + target_vector="overview", # The target vector to search against + # highlight-end + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + return_properties=["title", "release_date", "tmdb_id", "poster"] +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year, o.properties["tmdb_id"] + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END NVOverviewSearch + + +print("\n\n") + +client.connect() + + +# NVPosterSearch +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# Perform query +response = movies.query.near_text( + query="A joyful holiday film", + # highlight-start + target_vector="poster_title", # The target vector to search against + # highlight-end + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + return_properties=["title", "release_date", "tmdb_id", "poster"] +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year, o.properties["tmdb_id"] + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END NVPosterSearch + + +print("\n\n") + +client.connect() + + +# MetadataMultimodalSearch + +def url_to_base64(url): + import requests + import base64 + + image_response = requests.get(url) + content = image_response.content + return base64.b64encode(content).decode("utf-8") + + +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# Perform query +src_img_path = "https://github.com/weaviate-tutorials/edu-datasets/blob/main/img/International_Space_Station_after_undocking_of_STS-132.jpg?raw=true" +query_b64 = url_to_base64(src_img_path) + +response = movies.query.near_image( + near_image=query_b64, + limit=5, + target_vector="poster_title", # The target vector to search against + return_metadata=wq.MetadataQuery(distance=True), + return_properties=["title", "release_date", "tmdb_id", "poster"] # To include the poster property in the response (`blob` properties are not returned by default) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year, o.properties["tmdb_id"] + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END MetadataMultimodalSearch + + +print("\n\n") + +client.connect() + + +# MetadataHybridSearch +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# Perform query +response = movies.query.hybrid( + query="history", + # highlight-start + target_vector="overview", # The target vector to search against + # highlight-end + limit=5, + return_metadata=wq.MetadataQuery(score=True) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Hybrid score: {o.metadata.score:.3f}\n" + ) # Print the hybrid search score of the object from the query + +client.close() +# END MetadataHybridSearch + + +print("\n\n") + +client.connect() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/104_usecase.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/104_usecase.py new file mode 100644 index 000000000..99605709d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/_snippets/104_usecase.py @@ -0,0 +1,91 @@ +# START-ANY +import os +import weaviate +import os + +# END-ANY + +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} +client = weaviate.connect_to_local( + port=8280, + grpc_port=50251, + headers=headers +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_local(headers=headers) + +# END-ANY + +# PosterSearchGeneration + +def url_to_base64(url): + import requests + import base64 + + image_response = requests.get(url) + content = image_response.content + return base64.b64encode(content).decode("utf-8") + + +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# Perform query +src_img_path = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/img/1927_Boris_Bilinski_(1900-1948)_Plakat_f%C3%BCr_den_Film_Metropolis%2C_Staatliche_Museen_zu_Berlin.jpg" +query_b64 = url_to_base64(src_img_path) + +# response = movies.generate.near_text( +# query="Science fiction film set in space", +response = movies.generate.near_image( + near_image=query_b64, + limit=10, + # highlight-start + target_vector="poster_title", # The target vector to search against + grouped_task="What types of movies are these, and what kinds of audience might this set of movies be aimed at overall?", + grouped_properties=["title", "overview"] # Optional parameter; for reducing prompt length + # highlight-end +) + +# Inspect the response +for o in response.objects: + print(o.properties["title"]) # Print the title +print(response.generative.text) # Print the generated text (the commonalities between them) + +client.close() +# END PosterSearchGeneration + + +print("\n\n") + +client.connect() + + +# TitleSerachLoop +# Get the collection +movies = client.collections.use("MovieNVDemo") + +# Perform query +# highlight-start +# Loop through the target vectors +for tgt_vector in ["title", "overview"]: +# highlight-end + response = movies.generate.near_text( + query="Chrono Tides: The Anomaly Rift", + limit=5, + # highlight-start + target_vector=tgt_vector, # The target vector to search against + grouped_task="What types of movies are these, and what kinds of audience might this set of movies be aimed at overall?", + grouped_properties=["title", "overview"] # Optional parameter; for reducing prompt length + # highlight-end + ) + + # Inspect the response + for o in response.objects: + print(o.properties["title"]) # Print the title + print(response.generative.text) # Print the generated text (the commonalities between them) + +client.close() +# END TitleSerachLoop diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/index.md new file mode 100644 index 000000000..37c1aaefb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/named_vectors/index.md @@ -0,0 +1,27 @@ +--- +title: "220 名前付き ベクトル" +description: "Python でのクエリ関連性を高めるために Weaviate で名前付き ベクトル を使用する方法を理解します." +sidebar_position: 220 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +同じデータを複数の方法で表現したいことがあります。たとえば、記事を本文、タイトル、あるいはその両方で表現したい場合などです。 + +名前付き ベクトル を使うと、これが可能になります。名前付き ベクトル では、1 つのオブジェクトに対して複数の ベクトル 埋め込みを保存し、それぞれの ベクトル 空間を用いて検索できます。これにより、データの表現と検索方法に大きな柔軟性が生まれます。 + +本コースでは、マルチモーダリティの観点から名前付き ベクトル の使い方を学びます。タイトルや概要といったテキスト属性、ポスターなどの画像属性を ベクトル 化して、映画を表現・検索する方法を紹介します。 + +マルチモーダル データを使う予定がなくても問題ありません。ここで学ぶ概念は、どのようなデータや ベクトライザー にも応用できます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/10_vectorization_in_weaviate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/10_vectorization_in_weaviate.mdx new file mode 100644 index 000000000..3e74b6a2f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/10_vectorization_in_weaviate.mdx @@ -0,0 +1,8 @@ +--- +title: Weaviate におけるベクトル化 +--- + +- Weaviate がベクトルを取得する方法 +- Weaviate モジュール + - モジュールとモデル +- ローカル と API ベース のベクトル化 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/20_requirements.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/20_requirements.mdx new file mode 100644 index 000000000..55a65e3c2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/20_requirements.mdx @@ -0,0 +1,8 @@ +--- +title: ベクトライザーの要件 +--- + +- ベクトライザーの機能 +- ベクトライザーのコスト +- ベクトライザーの利用可能性 +- ベクトライザーのロケーション ( data residency ) \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/30_performance.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/30_performance.mdx new file mode 100644 index 000000000..31a5b5efb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/30_performance.mdx @@ -0,0 +1,10 @@ +--- +title: ベクトライザーのパフォーマンス +--- + +- 推論速度 +- 検索品質 + - ベンチマーク +- リソース要求 + - 推論時 + - Weaviate 上 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/40_compression.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/40_compression.mdx new file mode 100644 index 000000000..19cbd8d66 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/40_compression.mdx @@ -0,0 +1,8 @@ +--- +title: ベクトル(インデックス)圧縮 +--- + +- ベクトル圧縮とは +- Weaviate におけるベクトル圧縮 + - ベクトル圧縮の影響 +- 圧縮時のベクトライザーのパフォーマンス \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/50_use_in_weaviate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/50_use_in_weaviate.mdx new file mode 100644 index 000000000..60cd21161 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/50_use_in_weaviate.mdx @@ -0,0 +1,7 @@ +--- +title: Weaviate におけるベクトライザーの選択 +--- + +- ベクトライザー設定をどこで確認できるか +- ベクトライザーを設定する方法 +- ベクトライザーを変更する方法 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/index.mdx new file mode 100644 index 000000000..c07a14e36 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_202_vectorizer_selection/index.mdx @@ -0,0 +1,47 @@ +--- +title: 202 ベクトライザーの選択 +sidebar_position: 101 +--- + +## ユニット概要 + + + +:::warning TODO +Intro video here +::: + + + +Weaviate はさまざまな ベクトライザー モデルと統合しており、それぞれがデータの ベクトル 表現(エンベディング)を生成するように設計されています。 + +これらの ベクトライザー は、機能、ユースケース、リソース要件、コストなどの面で異なります。ご自身のニーズに最適な ベクトライザー を選択することが重要です。 + +このユニットでは、Weaviate で利用できる ベクトライザー の種類を学び、アプリケーションに最適な ベクトライザー を選択する方法を習得します。 + + +### 前提条件 + +- ベクトル 表現の基礎的な理解 +- Weaviate の ベクトル 検索機能への習熟 +- Python プログラミングの中級レベルのスキル + + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_203_indexing/_60_indexing_options.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_203_indexing/_60_indexing_options.mdx new file mode 100644 index 000000000..96d61b753 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_203_indexing/_60_indexing_options.mdx @@ -0,0 +1,32 @@ +--- +title: インデックスオプション +--- + +### トークン化オプション + +転置インデックスは、テキストをどのようにトークンへ分割するかを決定するトークン化方式を用いて構築されます。主な方式は次のとおりです。 + +| Tokenization Method | 説明 | 例となる入力 | インデックス化されるトークン | +|---------------------|------|-------------|------------------------------| +| `word` (default) | 英数字を保持して小文字化し、空白で分割します。 | `Conference (Chicago, IL)` | `conference`, `chicago`, `il` | +| `whitespace` | テキストを空白文字で分割します。 | `Conference (Chicago, IL)` | `Conference`, `(Chicago,`, `IL)` | +| `lowercase` | テキストを小文字化し、空白で分割します。 | `Conference (Chicago, IL)` | `conference`, `(chicago,`, `il)` | +| `field` | 空白文字をトリムした後、フィールド全体をインデックス化します。 | `Conference (Chicago, IL)` | `Conference (Chicago, IL)` | + +そのため、用語「conference」と一致する (すなわち `Equal` ) フィルターは、`word` トークン化を使用している場合にはオブジェクト ID を返しますが、`whitespace` トークン化を使用している場合には (大文字小文字が一致しないため) 返しません。 + +## レビュー + +### レビュー演習 + +:::caution TODO +Add review exercises +::: + +### 重要ポイント + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_203_indexing/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_203_indexing/index.mdx new file mode 100644 index 000000000..ce255cc7a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_203_indexing/index.mdx @@ -0,0 +1,47 @@ +--- +title: 202 ベクトル、キーワード、またはハイブリッド検索? +sidebar_position: 101 +--- + +## ユニット概要 + + + +:::warning TODO +ここにイントロ動画 +::: + + + +ようこそ! + +これは、 Weaviate と共にベクトルの世界を旅する最初のステップです。 +このユニットでは、 Weaviate の基礎の概要を学びます。 + +まず、 Weaviate とは何か、そして何ができるのかを理解します。 +次に、ベクトルデータベースとベクトル検索とは何かを学び、その後、実際に Weaviate を実行してベクトル検索を行います。 + +このユニットを終える頃には、コースの残りの内容をスムーズに進め、また自身のプロジェクトで Weaviate を活用するための確かな基礎知識が身に付きます。 + +### 前提条件 + +- なし + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_others/_inside_weaviate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_others/_inside_weaviate.mdx new file mode 100644 index 000000000..d526bf5b1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_others/_inside_weaviate.mdx @@ -0,0 +1,317 @@ +--- +title: Weaviate の内部を覗く +sidebar_position: 50 +--- + +## 概要 + +:::warning TODO +Intro video here +::: + +これまでに、セマンティック検索と ベクトル 検索の概念について紹介し、さらに Weaviate を実際に操作していただきました。 + +ここでは Weaviate の内部動作をより深く理解するため、以下のトピックをハイレベルで解説します。 + +- Weaviate が ベクトル 検索をどのように行うか +- Weaviate におけるデータの保存方法 +- Weaviate が使用する ベクトル の由来 + +これらの情報は、Weaviate の強力な検索機能の仕組みを理解し、開発プロジェクトで最大限に活用するための助けとなります。 + + +#### ML モデルとベクトル化 + +機械学習モデルは、テキスト・画像・音声クリップなどのデータを ベクトル へ変換します。この種のモデルはしばしば「ベクトライザー」とも呼ばれ、類似度の測定方法は使用する機械学習モデルによって異なります。 + +そのため、目的に合った適切なモデルを選択する、少なくとも不適切なモデルを選ばないことが極めて重要です。コース全体で多様なモデルを取り上げ、経験則から詳細な議論まで、モデル選択について学習します。 + +Weaviate 自体はデータをベクトル化しませんが、非常に多くのベクトル化モデルやサービスと互換性があります。本コースでは、目的や要件に合った方法でデータをベクトル化するための Weaviate の設定方法も扱います。 + +### 高速なデータ検索 + +![](../../tmp_images/orgainized_filing_cabinets_with_many_folders_1.jpg) + +データを迅速かつ効率的に取得するため、Weaviate はオブジェクトインデックスに加えて ベクトル インデックスを使用します。 ベクトル インデックスは高速な情報検索を実現しつつ、高いリコール性能も維持します。ただし、データセットの規模が大きくなるにつれて、メモリ要件と検索時間のバランスを取る必要があります。 + +Weaviate はインデックス作成に「近似最近傍(ANN)」アルゴリズムを採用しており、準線形以下の計算量でスケールします。つまり、検索時間の増加速度はデータセットサイズの増加速度よりも遅く、Weaviate は高いスケーラビリティを実現します。 + +コースを通じて、Weaviate のインデックスや主要な ベクトル インデックスタイプである HNSW インデックスについて学びます。 + +### 本番環境への移行 + +![](../../tmp_images/a_machine_with_a_conveyer_belt_producing_boxes_of_documents.jpg) + +ベクトル データベースはしばしば水平・垂直の両方にスケールする必要があります。その規模は数十億のデータオブジェクトへ拡大することもあり、数十億の ベクトル を多くの同時ユーザーが検索できるよう、インデックスと検索が求められます。 + +これは ベクトル 検索のデータサイエンス的課題とは異なる追加のチャレンジを伴うことを理解しています。そのため、本コースでは Weaviate を本番環境で運用する際の主要事項を専用ユニットで解説します。 + +認証・認可、バックアップ、モニタリング、レプリケーションなど、Weaviate の本番運用に関わるあらゆる内容を取り上げます。 + + + + + +## データ構造 + +:::warning TODO +Intro video here +::: + +### オブジェクト + +![](../../tmp_images/a_beautiful_document_page_with_a_long_number_on_top_and_lots_of_text_underneath_1.jpg) + +Weaviate では、各オブジェクトがドキュメントストア内の JSON ドキュメントとして保存され、キーには一意の [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) が使用されます。オブジェクトの構造例は以下のとおりです。 + +:::note TODO +Replace object with one from actual edu database +::: + +```json +{ + "id": "unique-uuid", // e.g. "779c8970-0594-301c-bff5-d12907414002" + "class": "Name of the class the object belongs to", // e.g. "Question" + "properties": { + "property_name_1": "property_value_1", // e.g. "answer": "Jupiter" + "property_name_2": "property_value_1", // e.g. "question": "This is the largest planet in the solar system." + ... + }, + "vector": "Vector representation of the object if available" // e.g. [-0.16147631, -0.065765485, ... ,-0.06546908] +} +``` + +Weaviate では、リレーショナルデータベースの外部キーに似たクロスリファレンスを使用して、オブジェクト同士をリンクできます。データ全体の構造は `schema` によって定義されます。 + +### スキーマ + +![](../../tmp_images/a_complex_architectural_blueprint_laid_out_on_the_table_0.jpg) + +Weaviate における `schema` は、データ構造を定義する設計図です。次にスキーマ構造の例を示します。 + +
+ Example schema + TODO: Add actual example schema +
+ +スキーマは各クラスについて、その名前や説明などのメタデータ、各クラスのプロパティの名前や説明を指定します。さらに、クラス間のクロスリファレンスや、オブジェクトインデックスと ベクトル インデックスを含むインデックス設定も定義します。 + +また、スキーマはベクトル化プロセスに関する情報、使用するベクトル化モデル、含める/除外するプロパティ、プロパティ見出しを含めるかどうかなどを保持します。 + +:::info Auto-schema +スキーマ定義に必要で不足している情報は、Weaviate がデフォルト値とインポートデータに基づき自動推論します。 +::: + +#### データ型 + +各 `class` 定義には 1 つ以上のプロパティが含まれ、それぞれにデータ型を指定します。現在、Weaviate がサポートするデータ型は以下のとおりです。 + +import DataTypes from '/_includes/datatypes.mdx'; + +
+ Available data types in Weaviate + +
+ +ほとんどのデータ型では、`string` または `string[]` のように単一値またはリスト値を指定できます。 + +スキーマ定義とデータ型については、別のユニットで詳しく取り上げます。 + + + +### データインデックス + +![](../../tmp_images/robot_arm_picking_up_a_box_from_many_many_orgainized_boxes_with_labels_0.jpg) + +効率的な検索を実現するため、Weaviate は複数のインデックスを用いてデータを保存・取得します。 + +#### オブジェクトインデックス + +オブジェクトインデックスは、特定のプロパティに基づくフィルタリングを可能にします。 バージョン 1.18 以降、Weaviate は既存の 転置インデックス に加え、Roaring Bitmap ベースのインデックスをオブジェクトインデックスに追加しました。これにより、大規模データセットや結果セットにおいても取得速度が大幅に向上します。 +#### ベクトル インデックス + +Weaviate 内のオブジェクトには ベクトル を関連付けることができ、それらは ベクトル インデックスに収集・保存されます。 ベクトル インデックスは ベクトル 類似度に基づく検索を可能にし、 ANN ( Approximate Nearest Neighbor )アルゴリズムを用いて構築されます。 + +従来の k -nearest neighbor ( kNN )類似検索は、大規模なデータセットでは遅く非効率になる可能性があります。これに対し、 ANN ベースのインデックスを用いることで Weaviate は高い再現率を維持しつつ高速に ベクトル 検索を実行できます。現在 Weaviate では HNSW ベースの ANN インデックスを採用しています。 + + + +## ベクトル 検索プロセスの詳細 + +:::warning TODO +Intro video here +::: + +### 検索サブプロセスの順序 + +![](../../tmp_images/manufacturing_line_with_multiple_factory_robots_for_different_tasks_0.jpg) + +Weaviate では、 ベクトル 検索を代数フィルターと組み合わせてより精度の高い結果を得ることができます。たとえば、特定の ベクトル に類似したクイズ問題を "World History" カテゴリの中だけで検索するといったことが可能です。 + +このような検索を実現するために、Weaviate のさまざまなコンポーネントが連携します。 + +ベクトル 検索クエリが Weaviate に送られると、まずオブジェクト インデックスを使用してオブジェクト ID の「許可リスト( allow list )」を作成します。この許可リストは ベクトル 検索と組み合わせて使用され、結果セットは ベクトル 検索結果と許可リストの積集合となります。 + +こうして得られたオブジェクト ID の集合を用いてオブジェクト ストアから必要なプロパティを取得し、最終的なレスポンスとしてユーザーに返します。 + +:::info 事前フィルタリング +この事前フィルタリングは ベクトル 検索の前段で実行されるため、フィルターが厳しい場合でも Weaviate が期待どおりの結果を返す可能性を最大化できます。 + +フィルタリングが ベクトル 検索よりも前に行われるため、この方式を事前フィルタリングと呼びます。これにより、フィルターが厳しくても要求された件数の結果を返せる可能性が高まります。 +::: + + + +### ベクトル の生成元 + +![](../../tmp_images/a_machine_with_a_conveyer_belt_producing_many_long_numbers_0.jpg) + +Weaviate は、オブジェクトに ベクトル 表現を関連付けるための複数の方法を提供しています。一般的には、インポート時に Weaviate の ベクトライザー モジュールを利用して ベクトル 表現を取得するか、ユーザーが独自に生成した ベクトル を提供するかのいずれかです。 + +#### ベクトライザー モジュールを使用する + +インポート時に ベクトル を取得したい場合は、Weaviate の ベクトライザー モジュールを使用できます。これらのモジュールは大きく 2 つに分類されます。外部推論 API を呼び出すもの( `text2vec-openai` 、 `text2vec-cohere` 、 `text2vec-huggingface` )と、ローカルでマイクロサービスとして動作しベクトル化を行うもの(例: `text2vec-transformers` )です。 + +Weaviate の ベクトライザー モジュールは柔軟かつ拡張可能です。テキストや画像を ベクトル 化するモジュールに加え、テキストと画像の両方を同一 ベクトル 空間にベクトル化できるモジュール( `multi2vec-clip` )や、別の ベクトル をもとに新たな ベクトル を生成するモジュール( `ref2vec-centroid` )などが含まれています。 + +必要に応じてカスタム モジュールを作成し、Weaviate の機能を拡張することもできます。 + +#### ベクトル をアップロードする + +別の方法として、 ベクトル を手動でアップロードすることもできます。ドキュメントでは「 Bring Your Own Vector 」オプションと呼ばれることもあり、Weaviate の外部で ベクトル を生成したい場合や、すでに ベクトル 化済みのデータをお持ちの場合に適した方法です。 + +:::note ベクトル をアップロードしてベクトライザーも使用する +独自の ベクトル をアップロードすると同時に、Weaviate に ベクトライザー を指定することも可能です。たとえば、大規模なデータセットをインポートする際に、Weaviate が提供する ベクトライザー と同じものを使って事前にデータを ベクトル 化している場合などに有用です。これにより、データセットの更新分やクエリについては Weaviate 側で ベクトル 化を行えます。 +::: + +これらのオプションについては、別のユニットで詳しく解説します。 + + + +## まとめ + +:::warning TODO +Video here +::: + +### 練習問題 + +あなた自身の言葉で、 XXX を説明できますか? + +:::warning TODO +Input box for user to put answer in and get back a similarity score & our definition? +?? +::: + +### 重要ポイント + +:::info +Add summary +::: + +import Quiz from '/src/components/Academy/quiz.js' +const vectorizationAndML = [ + { + questionText: 'What does Weaviate use to obtain a vector corresponding to a data object?', + answerOptions: [ + { answerText: 'Weaviate is capable of creating a vector from data objects.', isCorrect: false, feedback: 'Weaviate is not itself a vectorizer.'}, + { answerText: 'Weaviate uses modules to obtain vectors from machine learning models.', isCorrect: true, feedback: 'You will learn about vectorizer models and corresponding Weaviate modules later on.'}, + { answerText: 'Weaviate requires a vector to be uploaded at import time.', isCorrect: false, feedback: 'While you can upload a vector, this is not required.'}, + ], + }, +]; +const weaviateIndexing = [ + { + questionText: 'What types of indexes does Weaviate use?', + answerOptions: [ + { answerText: 'Weaviate does not rely on indexing as it relies on a kNN vector search.', isCorrect: false, feedback: 'Weaviate does not use a kNN search as it is computationally very expensive.'}, + { answerText: 'Weaviate uses a vector index.', isCorrect: false, feedback: 'This is only partially true.'}, + { answerText: 'Weaviate uses an inverted index.', isCorrect: false, feedback: 'This is only partially true.'}, + { answerText: 'Weaviate uses a vector index and an inverted index.', isCorrect: true, feedback: 'Both indexes are used for different, and complementary reasons.'}, + ], + }, +]; +const dataStorageComponents = [ + { + questionText: 'What are the key components of data storage and retrieval system in Weaviate?', + answerOptions: [ + { answerText: 'The object store, object index, and vector index.', isCorrect: true, feedback: 'Great job!'}, + { answerText: 'The object index and vector index.', isCorrect: false, feedback: 'That is partially correct, but missing a component.'}, + { answerText: 'The object store, vector store, and vector index.', isCorrect: false, feedback: 'There is no separate "vector store" with the "vector index".'}, + ], + }, +]; +const objectIndex = [ + { + questionText: 'How does Weaviate use the object index when a vector search query with a filter is sent?', + answerOptions: [ + { + answerText: 'It uses the object index to compare the query vector to objects.', + isCorrect: false, + feedback: 'Weaviate uses the vector index for this purpose.', + }, + { + answerText: 'It uses the object index to create an "allow list" of object IDs.', + isCorrect: true, + feedback: 'The allow list is then combined with results from the vector search', + }, + { + answerText: 'It uses the object index to build an ANN-based index.', + isCorrect: false, + feedback: 'The ANN-based (i.e. vector) index is built already, and it is not based on the object index.', + }, + ] + } +]; +const autoSchema = [ + { + questionText: 'What happens if required information is unspecified in the user-defined schema?', + answerOptions: [ + { + answerText: 'Weaviate will throw an error at import.', + isCorrect: false, + feedback: 'That is not true. Try again.', + }, + { + answerText: 'Data will not be imported due to a lack of schema definition.', + isCorrect: false, + feedback: 'That is not true. Try again.', + }, + { + answerText: 'Weaviate will implicitly use its default values.', + isCorrect: false, + feedback: 'Weaviate does have default values for it to use in this situation, but it will not be implicit. Please try again..', + }, + { + answerText: 'Weaviate will infer required information using the auto-schema function.', + isCorrect: true, + feedback: 'The inference will be based on the defaults as well as the data being imported.', + }, + ] + } +]; +const vectorizeObject = [{ + questionText: 'Which of the following is NOT a way to associate vector representations with objects in Weaviate?', + answerOptions: [ + { + answerText: 'Upload vectors to Weaviate', + isCorrect: false, + feedback: 'You can upload vectors to Weaviate.', + }, + { + answerText: 'Use an inference API such as OpenAI, Cohere or Hugging Face.', + isCorrect: false, + feedback: 'You can use Weaviate modules to use these inference APIs.', + }, + { + answerText: 'Rely on Weaviate Database to generate vectors.', + isCorrect: true, + feedback: 'Although it can use modules to do so, Weaviate itself cannot generate vectors.', + }, + { + answerText: 'Use a local vectorizer microservice module.', + isCorrect: false, + feedback: 'Weaviate modules such as text2vec-transformers are examples of local vectorizer microservices that can generate vectors.', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_others/_vectorizer_intro.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_others/_vectorizer_intro.md new file mode 100644 index 000000000..ef663f322 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/_others/_vectorizer_intro.md @@ -0,0 +1,38 @@ +--- +title: ベクトライザーの概要 +sidebar_position: 40 +--- + +## 背景(モジュールの目的) + +このユニットでは、適切なベクトライザーを選択するためのツールを提供します。 + +ベクトル検索の基本 [INSERT LINK HERE] では、ベクトルデータベースが各オブジェクトを関連するベクトルとともに保存できることを学びました。しかし、ベクトライザーモデルの選択は、データサイエンティストを含む誰にとっても難しい作業になり得ます。その理由は以下のとおりです。 + +### モデルの多さ + +問題の一つは、利用可能なモデルが非常に多いことです。 + +参考までに、Hugging Face Hub には 60,000 以上のモデルが登録されています(2023 年 1 月時点)。 + +![placeholder image for confusion](https://images.unsplash.com/photo-1499334758287-dc8133b315e9?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=80) + +### 性能のばらつき + +もう一つの問題は、「万能」なモデルが存在しないことです。 + +各モデルはテキスト・画像・音声など特定のアセットをベクトル化できますが、同じアセットタイプ内でも得意とするタスクが異なるのが一般的です。 + +### 進歩の速度 + +さらに、新しいモデルが毎日のように開発・公開されています。言語モデルの世界では、1 年前や 1 か月前に最先端だったものが、すでに「旧聞」扱いされることも珍しくありません。 + +これらが重なることで、意思決定が難しくなります。 + +## 心配無用 + +朗報として、アプリケーションをうまく機能させるために「完璧なモデル」を選ぶ必要はありません。 + +ベクトライザーモデルは進化を遂げており、多くのモデルがさまざまなタスクで優れた性能を発揮します。 + +次のセクションでは、一般的に使用されるベクトライザーモデルの種類について学びます。 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/10_introduction.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/10_introduction.mdx new file mode 100644 index 000000000..2491aa8e6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/10_introduction.mdx @@ -0,0 +1,133 @@ +--- +title: チャンク化の簡潔な紹介 +description: Weaviate の Python SDK におけるチャンク化の基本を理解します。 +--- + + + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +## チャンク化とは + +チャンク化とは、テキストをより小さな断片 ― すなわち「チャンク」 ― に分割する前処理ステップです。 + +ベクトル データベースは、オブジェクトを意味を捉えたベクトルと共に格納することをご存じでしょう。しかし、各ベクトルが *どれだけ* のテキストの意味を捉えるのでしょうか? それを定義するのがチャンク化です。各チャンクこそがベクトル化され、データベースに保存される情報単位となります。 + +例えば、ソース テキストが複数冊の書籍で構成されている場合を考えてみましょう。チャンク化手法によっては、書籍を章・段落・文、さらには単語レベルまで分割することも可能です。 + +単純な概念ですが、ベクトル データベースの性能や言語モデルの出力に大きな影響を及ぼします。 + +## データをチャンク化する理由 + +### 情報検索のため + +先ほどの例 ― 書籍セットからベクトル データベースを構築する ― に戻りましょう。 + +極端なケースとして、各書籍を 1 つのベクトルとして登録する方法があります。これは図書館の蔵書目録のようなデータベースを構築することになります。 + +この方法はクエリに最も近い書籍を見つけるには有用ですが、ベクトルが書籍全体を対象としているため、書籍内の特定情報を探すといったより細粒度のタスクには適していません。 + +逆に、各文を 1 つのベクトルとして登録する方法もあります。これは文レベルのシソーラスのようなデータベースを構築するイメージです。筆者が伝えたい特定の概念や情報を見つけるには適していますが、本や章といったより広い情報を探すには不向きかもしれません。 + +どちらを選ぶか、あるいはその中間の方法を選ぶかはユースケース次第です。指針や考慮点については後ほど詳しく説明します。 + +ここでの重要ポイントは、チャンク化がデータベースに保存される情報単位、すなわち検索・取得される情報単位を定義するということです。 + +後述するように、これは検索だけでなく下流の検索拡張生成 (RAG) ユースケースにも影響します。 + +### モデル要件への適合 + +チャンク化のもう一つの理由は、使用する言語モデルの要件を満たすためです。 + +これらのモデルには入力テキスト長に関する有限の「ウィンドウ」があり、ソース テキストがその長さを超えることがよくあります。例えば『ロード・オブ・ザ・リング』は 500,000 語を超えます! + +一般的なモデルの「コンテキスト ウィンドウ」は数千トークン(単語、語の一部、句読点など)程度です。そのため、モデルに入力するテキストはこのサイズ以下のチャンクに分割する必要があります。 + +### 最適な検索拡張生成 (RAG) のため + +チャンク化は検索拡張生成 (RAG) を最適化するためにも重要です。(RAG について復習が必要な場合は、[こちらのモジュール](../../zero_to_mvp/104_queries_2/30_generative.mdx) をご覧ください。) + +要するに、RAG ではデータベースから取得したデータをプロンプトと一緒に大規模言語モデル (LLM) に渡すことで、モデルを現実の情報に基づかせることができます。これにより、古い情報や欠落した情報による事実誤りを防ぐことができます。 + +それでは、なぜチャンク化が RAG に影響するのでしょうか? LLM には入力サイズの上限 ― コンテキスト ウィンドウ ― があるため、チャンク サイズはコンテキスト ウィンドウに含められるチャンク数を決定します。これはつまり、LLM が参照できる情報源の数と、各オブジェクトに含まれる情報量を決めることになります。 + +チャンク サイズが小さすぎる場合、大きすぎる場合に何が起きるかを考えてみましょう。 + +#### 小さすぎるチャンク + +短いチャンクを使うと、多くのチャンクから情報を LLM に渡すことができます。しかし、各結果に含まれる文脈情報が不足する可能性があります。 + +次の文をチャンクとして LLM に渡す場合を想像してみてください: +`In the dense areas, most of the concentration is via medium- and high-rise buildings.` +この文からその地域の性質について多くを語っていますが、さらなる文脈がないと LLM にとっては有用ではありません。この文はどこについて語っているのでしょうか? なぜ密度について話しているのでしょうか? 人間にも分かりづらいですし、LLM も同様に推測せざるを得ません。 + +対照的に、以下のように渡したらどうでしょうか: +`Wikipedia: London: Architecture: In the dense areas, most of the concentration is via medium- and high-rise buildings. London's skyscrapers, such as 30 St Mary Axe (dubbed "The Gherkin"), Tower 42, the Broadgate Tower and One Canada Square, are mostly in the two financial districts, the City of London and Canary Wharf.` + +ソース、記事タイトル、セクションタイトル、追加の文など、より多くの文脈情報が含まれているため、私たちにも LLM にとってもはるかに明確です。 + +#### 大きすぎるチャンク + +一方で、チャンクが大きすぎると、LLM のコンテキスト ウィンドウに収まるチャンク数が少なくなったり、コストが増加したりします。また、不要な情報が増える可能性もあります。 + +極端な例として、一続きのテキストしか LLM に渡せないとしたらどうでしょうか。それは、書籍の 1 つのセクションだけを使ってエッセイを書けと言われるようなものです。 + +どちらの極端も理想的ではなく、バランスを見つけることが重要です。 + +## チャンクサイズの選定 + +ご覧のように、適切なチャンク サイズを選ぶには複数の要因が絡み合います。 + +残念ながら、誰にとっても万能なチャンク サイズやチャンク化手法は存在しません。ポイントは、*あなた* に合った ― 小さすぎず大きすぎず、かつ手法も適切な ― サイズを見つけることです。 + +次のユニットでは、一般的なチャンク化手法からレビューを始め、これらのアイデアを掘り下げていきます。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/20_how_1.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/20_how_1.mdx new file mode 100644 index 000000000..2c9457bb7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/20_how_1.mdx @@ -0,0 +1,198 @@ +--- +title: チャンク化手法 - 1 +description: Weaviate でチャンク化手法を実装するステップ 1 を解説します。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import CodeFixedSizeChunking from '!!raw-loader!./_snippets/20_chunking_methods.1.fixed.size.py'; +import CodeVariableSizeChunking from '!!raw-loader!./_snippets/20_chunking_methods.2.variable.size.py'; +import CodeMixedStrategyChunking from '!!raw-loader!./_snippets/20_chunking_methods.3.mixed.strategy.py'; + + + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +## 概要 + +チャンク化とは何か、そしてそれがなぜ重要なのかを学んだので、ここからは実践的なチャンク化手法を見ていきます。まずは **固定サイズ** のチャンク化手法と、その実装例を紹介します。 + +## 固定サイズのチャンク化 + +名前が示すとおり、固定サイズのチャンク化とは、テキストを一定のサイズ(またはサイズを基準に)で分割する方法です。たとえば、記事を 100 語ごとのチャンクに分割したり、200 文字ごとに分割したりします。 + +そのシンプルさと効果の高さから、最も一般的なチャンク化手法と言えるでしょう。 + +### 実装 + +固定サイズのチャンク化は、テキストを一定数の単位ごとに分割して実装します。ここでの単位は語、文字、あるいは *トークン* である場合もあり、チャンクあたりの単位数は(上限として)固定され、必要に応じて重複(オーバーラップ)を設けます。 + +:::tip トークンとは? +ここでの「トークン」とは、モデルが数値に置き換えて処理するテキストの単位です。最新のトランスフォーマーモデルでは、トークンは数文字から成る「サブワード」であることが一般的です。 +::: + +固定サイズのチャンク化を行う擬似コードの一例を示します。 + +```python +# Given a text of length L +# Split the text into chunks of size N units (e.g. tokens, characters, words) +# Optionally, add an overlap of M units at the beginning or end of each chunk (from the previous or next chunk) +# This should typically result in a list of chunks of length L // N + 1 +``` + +Python で実装すると、次のようになります。 + + + + + + + +さらに、オーバーラップ(ここでは各チャンクの先頭側)を含めるように変更した例です。 + + + + + + + +これは固定サイズのチャンク化を実装する唯一の方法ではありませんが、比較的シンプルな実装例の一つです。 + +:::note 演習 +あなたなら固定サイズのチャンク化をどのように実装しますか? 擬似コード(あるいはコード)を書いてみてください。 +::: + +### 例 + +具体的な固定サイズチャンク化の例を 3 つ見てみましょう。チャンクサイズはそれぞれ 5 語、25 語、100 語です。 + +題材として [Pro Git book](https://git-scm.com/book/en/v2) から抜粋し、特に [What is Git?](https://github.com/progit/progit2/blob/main/book/01-introduction/sections/what-is-git.asc) 章のテキストを使用します。 + +先ほどのチャンク化関数を使った例は次のとおりです。 + + + + + + + +これにより次のような出力が得られます。各サイズの最初の数チャンクを見て、何に気づくでしょうか? + +:::note 演習 +検索用途に最も適切なチャンクサイズはどれだと思いますか? その理由とトレードオフを考えてみてください。 +::: + + + + + + + + + + + + + +これらの具体例を見ると、先に説明した考え方が理解しやすくなるはずです。 + +まず、小さなチャンクは非常に細かく、検索に有用な情報を含むには不十分に見えます。一方、大きなチャンクは典型的な段落と同程度の長さになり、より多くの情報を保持できるようになります。 + +さらにチャンクが長くなると、そのベクトル埋め込みはより一般的なものになり、やがて情報検索には使いにくくなるポイントに達します。 + +:::note 文字やサブワードのトークン分割は? +この程度のサイズであれば、語を分割する文字ベースやサブワードトークンベースのチャンク化は通常必要ありません。語を途中で分割しても意味がないためです。 +::: + +:::tip どこから始める? +固定サイズチャンクで検索を行う場合、他に指標がなければ 100〜200 語程度、オーバーラップを 20% 程度から試してみてください。 +::: + +## 補足 + +:::info Pro Git by Scott Chacon and Ben Straub - 書籍ライセンス + +*この書籍は Creative Commons Attribution-Non Commercial-Share Alike 3.0 ライセンス の下で利用できます。* + +::: + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/25_how_2.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/25_how_2.mdx new file mode 100644 index 000000000..52b86bd86 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/25_how_2.mdx @@ -0,0 +1,200 @@ +--- +title: チャンク化テクニック - 2 +description: Weaviate で大量データをチャンク化する高度な手法をマスターします。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import CodeFixedSizeChunking from '!!raw-loader!./_snippets/20_chunking_methods.1.fixed.size.py'; +import CodeVariableSizeChunking from '!!raw-loader!./_snippets/20_chunking_methods.2.variable.size.py'; +import CodeMixedStrategyChunking from '!!raw-loader!./_snippets/20_chunking_methods.3.mixed.strategy.py'; + + + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +## 概要 + +前回に続き、ここでは **可変サイズ** チャンク化テクニックを取り上げ、いくつかの実装例をご紹介します。 + +## 可変サイズ チャンク化 + +次に可変サイズ チャンク化を見ていきましょう。固定サイズ チャンク化とは異なり、ここでのチャンクサイズは *入力パラメーター* ではなく *結果* として決まります。 + +可変サイズ チャンク化では、テキストを分割するためのマーカーを利用します。マーカーは文や段落といった構文上のもの、あるいは Markdown ヘッダーのような構造上のものなど、さまざまです。 + +### 実装 + +可変サイズ チャンク化の擬似コード実装は次のようになります。 + +```python +# Given a text of length L +# Identify a marker (e.g. full-stop, paragraph marker (two newlines), or a Markdown header +# Split the text into chunks at each marker +``` + +これを Python で実装すると、以下のようになります。 + + + + + + + +あるいは、Markdown ヘッダーのような特別なマーカーを使ってテキストを分割することもできます。 + +(*Pro Git* 書籍は [Asciidoc](https://asciidoc.org/) で書かれているため、ここでは Asciidoc ヘッダーを使用します。すべて新しい行の先頭に `==` が付いています。) + + + + + + + +それでは、具体的な例に当てはめてみましょう。 + +### 例 + +先ほどと同じテキストにこれらのスプリッターを適用します。 + + + + + + + +出力は次のとおりです。何か気づく点はありますか? + + + + + + + + + + +おそらく真っ先に目に付くのは、非常に単純なマーカー ベースのチャンク化では見出しが 1 つのチャンクとして抽出されてしまう点です。これは望ましくない場合があります。 + +実際には、例えばこのような非常に短いチャンクは次のチャンクに結合するなどの混合戦略を採用することが多いでしょう。見出しやタイトルと思われるテキストを隣接する本文とまとめるイメージです。 + +それでは、そのような戦略を見てみましょう。 + +## 混合戦略 + +固定サイズ チャンク化と可変サイズ チャンク化を組み合わせて、両方の長所を活かすことができます。たとえば、段落マーカーで可変サイズ チャンク化を行ったうえで、固定サイズのフィルターを適用する方法です。 + +具体的には、サイズが小さすぎるチャンクは次のチャンクと結合し、サイズが大きすぎるチャンクは中央や内部の別のマーカーで分割する、などの処理を行います。 + +### 例 + +実装例は次のようになります。 + +```python +# Given a text of length L +# Identify a marker (e.g. full-stop, paragraph marker (two newlines), or a Markdown header +# Split the text into chunks at each marker +# If any of the chunks are too small, merge them with the next chunk +# If any of the chunks are too large, split them - e.g. at the middle or using another marker within the chunk +``` + +これを Python で実装すると、以下のようになります。 + + + + + + + +このコードにより生成されたチャンクは次のとおりです。 + + + +この戦略では、チャンクが小さくなりすぎることを防ぎつつ、見出しという構文上の境界も尊重できます。 + +単一のテキストに対するチャンク化戦略を確認したところで、次は複数のテキストに対してどのように機能するかを見てみましょう。また、異なるチャンク化戦略を用いた場合の検索結果がどのようになるかも確認します。 + + +### 復習演習 + +:::note 演習 +試してみてください ... +::: + +### 主要ポイント + +:::info +概要を追加 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/30_example_chunking.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/30_example_chunking.mdx new file mode 100644 index 000000000..42e5a1741 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/30_example_chunking.mdx @@ -0,0 +1,196 @@ +--- +title: 例 パート 1 - チャンク化 +description: Weaviate におけるチャンク化の実例を確認します。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import CodePracticalExample from '!!raw-loader!./_snippets/30_example.py'; + + + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +## 概要 + +前のセクションでは、[チャンク化について](./10_introduction.mdx) と、その方法として [固定長チャンク](./20_how_1.mdx) および [可変長チャンク](./25_how_2.mdx) を学びました。 + +本セクションと次のセクションでは、チャンク化が実際にどのように機能するかを包括的に示します。異なるチャンク化手法を用いて書籍の複数セクションを取り込み、検索性能を比較します。 + +## 実データのチャンク化 + +すでに [Pro Git book](https://git-scm.com/book/en/v2) * の一部を使ったチャンク化の例をご覧いただきました。本セクションでは、本書の複数章、合計 14 セクションを使用します。 + +### ソースデータ + +ここでは `requests` ライブラリを使って Pro Git book からソースデータを取得します。各セクションを個別のオブジェクトとして保存し、章タイトルやファイル名などのメタデータとテキストを含めます。 + +:::tip このデータは何でも構いません +ここでの詳細は重要ではありません。ソースはデータベース、PDF、あるいは動画など何でもかまいません。重要なのは、さまざまなチャンク化戦略を試すためのテキスト集合を取得することです。 +::: + + + + + + + +この処理により 14 個のテキストオブジェクトが得られます(各セクションにつき 1 つ)。それぞれに章タイトル、ファイル名、そしてセクションのテキストが含まれます。 + +
+ サンプルセクションを確認する + +``` +{ + "body": "=== About Version Control\n\n(((version control)))\nWhat is \"`version control`\", and why should you care?\nVersion control is a system that records changes to a file or set of files over time so that you can recall specific versions later.\nFor the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.\n\nIf you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use.\nIt allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.\nUsing a VCS also generally means that if you screw things up or lose files, you can easily recover.\nIn addition, you get all this for very little overhead.\n\n==== Local Version Control Systems\n\n(((version control,local)))\nMany people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever).\nThis approach is very common because it is so simple, but it is also incredibly error prone.\nIt is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to.\n\nTo deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.\n\n.Local version control diagram\nimage::images/local.png[Local version control diagram]\n\nOne of the most popular VCS tools was a system called RCS, which is still distributed with many computers today.\nhttps://www.gnu.org/software/rcs/[RCS^] works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches.\n\n==== Centralized Version Control Systems\n\n(((version control,centralized)))\nThe next major issue that people encounter is that they need to collaborate with developers on other systems.\nTo deal with this problem, Centralized Version Control Systems (CVCSs) were developed.\nThese systems (such as CVS, Subversion, and Perforce) have a single server that contains all the versioned files, and a number of clients that check out files from that central place.(((CVS)))(((Subversion)))(((Perforce)))\nFor many years, this has been the standard for version control.\n\n.Centralized version control diagram\nimage::images/centralized.png[Centralized version control diagram]\n\nThis setup offers many advantages, especially over local VCSs.\nFor example, everyone knows to a certain degree what everyone else on the project is doing.\nAdministrators have fine-grained control over who can do what, and it's far easier to administer a CVCS than it is to deal with local databases on every client.\n\nHowever, this setup also has some serious downsides.\nThe most obvious is the single point of failure that the centralized server represents.\nIf that server goes down for an hour, then during that hour nobody can collaborate at all or save versioned changes to anything they're working on.\nIf the hard disk the central database is on becomes corrupted, and proper backups haven't been kept, you lose absolutely everything -- the entire history of the project except whatever single snapshots people happen to have on their local machines.\nLocal VCSs suffer from this same problem -- whenever you have the entire history of the project in a single place, you risk losing everything.\n\n==== Distributed Version Control Systems\n\n(((version control,distributed)))\nThis is where Distributed Version Control Systems (DVCSs) step in.\nIn a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don't just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history.\nThus, if any server dies, and these systems were collaborating via that server, any of the client repositories can be copied back up to the server to restore it.\nEvery clone is really a full backup of all the data.\n\n.Distributed version control diagram\nimage::images/distributed.png[Distributed version control diagram]\n\nFurthermore, many of these systems deal pretty well with having several remote repositories they can work with, so you can collaborate with different groups of people in different ways simultaneously within the same project.\nThis allows you to set up several types of workflows that aren't possible in centralized systems, such as hierarchical models.\n", + "chapter_title": "01-introduction", + "filename": "about-version-control.asc" +} +``` + +
+ +### チャンク化 + +次のチャンク化手法を各セクションに適用します。 + +- 固定長チャンク(重複 20 %) + - 1 チャンクあたり 25 単語 + - 1 チャンクあたり 100 単語 +- 段落マーカーを使った可変長チャンク +- 段落マーカーを使用し、最小チャンク長を 25 単語にした混合戦略チャンク + +さらに、ファイル名・章名・チャンク番号などのメタデータもチャンクに追加します。 + +実装例を以下に示します。 + +
+ ヘルパー関数 + + + + + + + +
+ + + + + + + +これで、4 つのチャンク化手法に応じた 4 つのチャンクセットが得られました。ご覧ください。 + + + + + + + + + + + + + + + + +### インポート + +これで、チャンクを Weaviate にインポートできるようになりました。比較を容易にするために、すべてのチャンクセットを同じコレクションに追加し、フィルタリングしやすいよう各チャンクに `chunking_method` プロパティを付与します。 + + + + + + + +### インスペクション + +先へ進む前に、チャンクが正しくインポートされたか確認しましょう。オブジェクトの総数と、各チャンク手法ごとのオブジェクト数を取得します。 + + + + + + + +これにより、次のような出力が得られるはずです: + + + +これらの数は作成したチャンク数と一致しているため、インポートが成功したと確信できます。 + +次のセクションでは、これらのチャンクに対して検索を試してみます。 + +## メモ + +:::info Pro Git by Scott Chacon and Ben Straub - Book License + +*Creative Commons Attribution-Non Commercial-Share Alike 3.0 ライセンス の下で提供されています。 + +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/40_example_search.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/40_example_search.mdx new file mode 100644 index 000000000..e2cafddf4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/40_example_search.mdx @@ -0,0 +1,321 @@ +--- +title: 例 パート 2 - 検索 +description: Weaviate でチャンク化されたデータを効率的に検索する方法を学びます。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import CodePracticalExample from '!!raw-loader!./_snippets/30_example.py'; + + + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +## 概要 + +[前のセクション](./30_example_chunking.mdx) では、異なるチャンク化手法を用いて本の複数章を Weaviate にインポートしました。使用した方法は次のとおりです。 + +- 固定長チャンク (20% のオーバーラップ) + - チャンク 1 件あたり 25 語 + - チャンク 1 件あたり 100 語 +- 段落マーカーを利用した可変長チャンク +- 段落マーカーと最小長 25 語を組み合わせた混合戦略チャンク + +今回は Weaviate を使って本を検索し、チャンク化手法の影響を評価します。 + +データは Git についての本の最初の 2 章から取得したものなので、さまざまな Git 関連の概念を検索し、各チャンク化戦略のパフォーマンスを確認します。 + + +## 検索 / リコール + +まず、さまざまな検索語を用いて Weaviate インスタンスから情報を取得します。意味検索 (`nearText`) を使い、最も関連性の高いチャンクを取得することを目指します。 + +### 検索構文 + +次のように検索を実行し、データセットをフィルタリングして各チャンク化戦略を順番に処理します。各検索語について、上位数件の結果を取得します。 + + + + + + + +使用する検索語: +- `"history of git"` +- `"how to add the url of a remote repository"` + +### 結果と考察 + +得られた結果は次のとおりです。 + +#### Example 1 + +:::info `"history of git"` の検索結果 +::: + + + + + + + + + + + + + + + + +このクエリは `history of git` という包括的な内容です。その結果、長めのチャンクのほうが良いパフォーマンスを示しています。 + +25 語チャンクはクエリと意味的には近いものの、トピックの理解を深めるのに十分な文脈情報を含んでいません。 + +一方、取得された段落チャンク、特に最小長 25 語のチャンクは Git の歴史について体系的な情報を含んでおり、読者の学習に適しています。 + +#### Example 2 + +:::info `"how to add the url of a remote repository"` の検索結果 +::: + + + + + + + + + + + + + + + + +このクエリはユーザーがリモートリポジトリの URL を追加する方法を知りたい場合のような、より具体的なものです。 + +先ほどとは対照的に、25 語チャンクのほうが有用でした。質問が非常に具体的だったため Weaviate は最も適切な一節、すなわちリモートリポジトリを追加する方法 (`git remote add `) を含むチャンクを特定できました。 + +ほかの結果にも同じ情報が含まれてはいますが、結果をどのように利用・表示するかを考慮する価値があります。結果が長くなるほど、ユーザーが必要な情報を見つけるのに要する認知的負荷は大きくなるかもしれません。 +## 検索拡張生成 (RAG) + +次に、チャンク化が RAG に与える影響を見てみましょう。 + +[チャンクサイズと RAG の関係については前に説明しました](./10_introduction.mdx#-for-optimal-retrieval-augmented-generation-rag)。短いチャンクを使うと、より多くのソースオブジェクトから情報を取り込めますが、各オブジェクトに含まれる文脈情報は少なくなります。反対に、長いチャンクを使うと各チャンクにより多くの文脈情報が含まれますが、取得できるソースオブジェクトは少なくなります。 + +これがどのように現れるか、いくつか RAG の例で試してみましょう。 + +### クエリ構文 + +以下にクエリ構文を示します。基本的には先ほどと同じですが、2 つの点で異なります。 + +1. チャンクサイズが小さい場合は、より多くのチャンクを取得するようにしています。 +2. 単なる検索ではなく RAG を行うようにクエリを変更しています。クエリでは、対象 LLM に結果を箇条書きで要約するよう依頼しています。 + + + + + + + +### 結果と考察 + +#### 例 1 + +:::info 「`history of git`」の検索結果。 +::: + + + + + + + + + + + + + + + + +ここでの結果はセマンティック検索と同様でした。長いチャンクのほうが情報量が多く、git の歴史のような幅広いトピックには有用です。 + +#### 例 2 + +:::info 「`available git remote commands`」の検索結果。 +::: + + + + + + + + + + + + + + + + +`available git remote commands` に対する生成検索の結果は、先ほどよりもさらに示唆的です。 + +ここでは、最も短いチャンクが書籍から最も多くの `git remote` コマンドを取得できました。これは、コーパス(書籍)内のさまざまな場所から多くのチャンクを取り出せたためです。 + +一方、長いチャンクを使った場合は、取得したチャンクが少なくなったため、`git remote` コマンドは 1 つしか取り出せませんでした。 + +#### 考察 + +ここでは短いチャンクと長いチャンクのトレードオフが見て取れます。 + +短いチャンクを使うと、より多くのオブジェクトから多くの情報を取得できますが、各オブジェクトの文脈情報は少なくなります。長いチャンクを使うと、取得できるオブジェクトは少なくなりますが、各オブジェクトに含まれる文脈情報は多くなります。 + +たとえ非常に大きなコンテキストウィンドウを持つ LLM を使う場合でも、この点は忘れないでください。入力テキストが長いほど API 料金や推論時間が増えるため、長いチャンクにはコストが伴います。 + +しばしば、これは RAG のチャンク化戦略を決める際に検討すべき *唯一の* トレードオフです。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/50_considerations.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/50_considerations.mdx new file mode 100644 index 000000000..251781b6b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/50_considerations.mdx @@ -0,0 +1,153 @@ +--- +title: 考慮事項と提案 +description: 大規模データセットを効果的にチャンク化する際の主な考慮事項を学びます。 +--- + + + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +## 概要 + +このユニットでは、チャンク化について多くを学習してきました。 + +チャンク化とは何かを確認し、さまざまなチャンク化手法を学び、その影響を理解できるように実装例も掘り下げました。 + +このセクションでは、これまでの詳細なミクロ視点から一歩引き、学んだ内容を文脈に当てはめながらマクロ視点で考えていきます。具体的には、データをチャンク化する際に検討すべきポイントと、それが Weaviate 実装にどのように影響するかを見ていきます。 + +## 考慮事項 + +ご覧いただいたとおり、データをチャンク化する方法は多数あります。では、どれが最適なのでしょうか。 + +答えはいつものように「ケース・バイ・ケース」です。ただし、チャンク化手法を選ぶ際に考慮すべき事項を以下に示します。 + +#### 検索結果あたりのテキスト量 + +検索結果の各「ヒット」にどれだけのテキストを含めるべきでしょうか。1 文なのか 1 段落なのか、それとも別の単位なのか。 + +自然な考え方としては、取得したい検索結果と同じサイズでデータをチャンク化することです。 + +#### 入力クエリの長さ + +一般的な入力クエリがどのようなものかを検討してください。短い検索文字列でしょうか。それとも文書から抽出したような長いテキストでしょうか。 + +クエリの ベクトル はチャンクの ベクトル と比較されることを念頭に置いてください。したがって、短いクエリには短いチャンク、長いクエリには長いチャンクが役立つ場合があります。 + +短いチャンクを使用していて追加のコンテキストが必要な場合は、検索語を含むチャンクとその前後のチャンクをまとめて返すようにアプリを設計すると良いでしょう。 + +#### データベースサイズ + +チャンクが大きいほどチャンク数は減り、データベース自体は小さくなります。大規模データセットを扱う場合は重要な観点です。 + +#### モデルの制約 + +チャンクサイズがモデルの最大許容サイズ(コンテキストウィンドウ)以内に収まるようにする必要があります。これは埋め込みの生成にも RAG にも当てはまります。 + +#### RAG ワークフロー + +前述のとおり、短いチャンクは多様なソースから多数のチャンクを取り込むのに適しますが、コンテキストが不足する可能性があります。長いチャンクはより多くのコンテキストを提供できますが、取り込めるチャンク数が限られるかもしれません。 + +### 経験則 + +とはいえ、出発点としての経験則があると便利です。まずは 100〜150 語程度のチャンクサイズから始めることをお勧めします。 + +その後、上記の考慮事項やアプリのパフォーマンス観察結果に基づき、チャンクサイズを調整してください。 + +## データモデリング + +定義上、ソースデータをチャンク化すると 1 つのソースから複数のオブジェクトが生成されます。 + +したがって、チャンクとソースデータ間、さらにはチャンク同士の関係をどのようにモデル化するかを検討する必要があります。これにより、ソースに関するメタデータや周辺チャンクなど、必要な情報を効率的に取得できるようになります。 + +### コレクション定義の例 + +参考書ライブラリのデータを保存するよう設計された Weaviate データベースを考えてみましょう。 + +各書籍を 1 つの ベクトル として保存すると依然としてサイズが大き過ぎるかもしれません。そのため、書籍を段落単位にチャンク化したうえで `Book` コレクションと `Paragraph` コレクションを作成し、`Paragraph` コレクションにクロスリファレンスプロパティ `fromBook` を持たせる方法が考えられます。これにより、書籍のメタデータは `Book` コレクションから、周辺の段落は `Paragraph` コレクションから取得できます。 + +たとえば、次のように `Book` コレクションを構築できます。 + +```json +{ + "class": "Book", + "properties": [ + ... // other class properties + // highlight-start + { + "name": "title", + "dataType": ["text"], + }, + { + "name": "text", + "dataType": ["text"], + }, + // highlight-end + ], + "vectorIndexConfig": { + "skip": true + } + ... // other class attributes +} +``` + +そして `Book` コレクションを参照する `Paragraph` コレクションを次のように追加します。 + +```json +{ + "class": "Paragraph", + "properties": [ + ... // other class properties + // highlight-start + { + "name": "body", + "dataType": ["Text"] + }, + { + "name": "chunk_number", + "dataType": ["int"] + }, + { + "name": "fromBook", + "dataType": ["Book"] + }, + // highlight-end + ], + ... // other class attributes (e.g. vectorizer) +} +``` + +この構成では、`Book` コレクションはベクトル化されておらず、`Paragraph` コレクションのみがベクトル化されている点に注意してください。これにより、`Book` コレクションはメタデータの保存・取得に、`Paragraph` コレクションは検索にそれぞれ活用できます。 + +これはデータをモデル化する方法の一例に過ぎません。ユースケースに最適な構成を見つけるために、さまざまな設定を試してみてください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/90_wrap_up.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/90_wrap_up.mdx new file mode 100644 index 000000000..14b8650a6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/90_wrap_up.mdx @@ -0,0 +1,33 @@ +--- +title: まとめ +description: チャンク化のまとめと概要 +--- + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +## ユニットレビュー + +このユニットでは、チャンク化とは、長いテキストをより小さいテキスト片、すなわち「チャンク」に分割する手法であることを学習しました。 + +チャンク化が ベクトル データベースを用いた情報検索にどのように影響するのか、そして検索拡張生成のパフォーマンスにどのように影響するのかを取り上げました。 + +続いて、固定サイズのチャンク化、可変サイズのチャンク化、ハイブリッドチャンク化など、さまざまなチャンク化手法を扱いました。また、チャンク化戦略を決定する際の主な検討事項と、いくつかの推奨される出発点についても議論しました。 + +このユニットの締めくくりとして、データをチャンク化する際に考慮すべきポイントについて議論しました。それには、検索結果あたりのテキストの長さ、入力クエリの長さ、データベースの規模、言語モデルの要件、 RAG ワークフローなどが含まれます。 + +これでチャンク化の全体像を十分に理解し、実際のニーズに基づいて堅実なチャンク化戦略を実装できるようになったことを願っています。 + +### 学習目標 + +- 大枠でチャンク化が何であるかを説明できる +- ベクトル検索および生成検索におけるチャンク化の影響を説明できる +- さまざまなチャンク化手法を実装し、他の手法を検討すべき場所を把握できる +- 自身のニーズに基づいてチャンク化戦略を評価できる + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.1.fixed.size.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.1.fixed.size.py new file mode 100644 index 000000000..f58a67c08 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.1.fixed.size.py @@ -0,0 +1,84 @@ +# START Fixed size chunker with overlap # START Vanilla fixed size chunker # START Get fixed-size chunks examples +from typing import List + +# END Fixed size chunker with overlap # END Vanilla fixed size chunker # END Get fixed-size chunks examples + +# ======================================== +# ========== FIXED-SIZE CHUNKING ========= +# ======================================== + +# START Vanilla fixed size chunker +# Split the text into units (words, in this case) +def word_splitter(source_text: str) -> List[str]: + import re + source_text = re.sub("\s+", " ", source_text) # Replace multiple whitespces + return re.split("\s", source_text) # Split by single whitespace + +def get_chunks_fixed_size(text: str, chunk_size: int) -> List[str]: + text_words = word_splitter(text) + chunks = [] + for i in range(0, len(text_words), chunk_size): + chunk_words = text_words[i: i + chunk_size] + chunk = " ".join(chunk_words) + chunks.append(chunk) + return chunks +# END Vanilla fixed size chunker + +# START Fixed size chunker with overlap +# Split the text into units (words, in this case) +def word_splitter(source_text: str) -> List[str]: + import re + source_text = re.sub("\s+", " ", source_text) # Replace multiple whitespces + return re.split("\s", source_text) # Split by single whitespace + +def get_chunks_fixed_size_with_overlap(text: str, chunk_size: int, overlap_fraction: float) -> List[str]: + text_words = word_splitter(text) + overlap_int = int(chunk_size * overlap_fraction) + chunks = [] + for i in range(0, len(text_words), chunk_size): + chunk_words = text_words[max(i - overlap_int, 0): i + chunk_size] + chunk = " ".join(chunk_words) + chunks.append(chunk) + return chunks +# END Fixed size chunker with overlap + +# START Get fixed-size chunks examples +# Get source data +import requests + +url = "https://raw.githubusercontent.com/progit/progit2/main/book/01-introduction/sections/what-is-git.asc" +source_text = requests.get(url).text + +# Chunk text by number of words +for chosen_size in [5, 25, 100]: + chunks = get_chunks_fixed_size_with_overlap(source_text, chosen_size, overlap_fraction=0.2) + # Print outputs to screen + print(f"\nSize {chosen_size} - {len(chunks)} chunks returned.") + for i in range(3): + print(f"Chunk {i+1}: {chunks[i]}") +# END Get fixed-size chunks examples + + +""" +# START Chunking by 5 words - outputs +Size 5 - 281 chunks returned. +Chunk 1: [[what_is_git_section]] === What is Git? +Chunk 2: Git? So, what is Git in +Chunk 3: in a nutshell? This is an +# END Chunking by 5 words - outputs + +# START Chunking by 25 words - outputs +Size 25 - 57 chunks returned. +Chunk 1: [[what_is_git_section]] === What is Git? So, what is Git in a nutshell? This is an important section to absorb, because if you understand what Git +Chunk 2: if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you. As you learn Git, try to +Chunk 3: you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid +# END Chunking by 25 words - outputs + +# START Chunking by 100 words - outputs +Size 100 - 15 chunks returned. +Chunk 1: [[what_is_git_section]] === What is Git? So, what is Git in a nutshell? This is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you. As you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid subtle confusion when using the tool. Even though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in +Chunk 2: tool. Even though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in a very different way, and understanding these differences will help you avoid becoming confused while using it.(((Subversion)))(((Perforce))) ==== Snapshots, Not Differences The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data. Conceptually, most other systems store information as a list of file-based changes. These other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as _delta-based_ version control). .Storing data as changes to a base version +Chunk 3: each file over time (this is commonly described as _delta-based_ version control). .Storing data as changes to a base version of each file image::images/deltas.png[Storing data as changes to a base version of each file] Git doesn't think of or store its data this way. Instead, Git thinks of its data more like a series of snapshots of a miniature filesystem. With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already +# END Chunking by 100 words - outputs +""" + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.2.variable.size.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.2.variable.size.py new file mode 100644 index 000000000..778d730a7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.2.variable.size.py @@ -0,0 +1,66 @@ +# START Paragraph variable size chunker # START Asciidoc section variable size chunker +from typing import List + +# END Paragraph variable size chunker # END Asciidoc section variable size chunker + + +# ======================================== +# ======= VARIABLE-SIZE CHUNKING ========= +# ======================================== + +# START Paragraph variable size chunker +# Split the text into paragraphs +def get_chunks_by_paragraph(source_text: str) -> List[str]: + return source_text.split("\n\n") +# END Paragraph variable size chunker + +# START Asciidoc section variable size chunker +# Split the text by Asciidoc section markers +def get_chunks_by_asciidoc_sections(source_text: str) -> List[str]: + return source_text.split("\n==") +# END Asciidoc section variable size chunker + +# START Header variable size chunker +# Get source data +import requests + +url = "https://raw.githubusercontent.com/progit/progit2/main/book/01-introduction/sections/what-is-git.asc" +source_text = requests.get(url).text + +# Split the text into paragraphs +chunks = source_text.split("\n====") +# END Header variable size chunker + +# START Get variable-size chunks examples +# Get source data +import requests + +url = "https://raw.githubusercontent.com/progit/progit2/main/book/01-introduction/sections/what-is-git.asc" +source_text = requests.get(url).text + +# Chunk text by particular marker +for marker in ["\n\n", "\n=="]: + chunks = source_text.split(marker) + # Print outputs to screen + print(f"\nUsing the marker: {repr(marker)} - {len(chunks)} chunks returned.") + for i in range(3): + print(f"Chunk {i+1}: {repr(chunks[i])}") +# END Get variable-size chunks examples + + +""" +# START Chunking by paragraph - outputs +Using the marker: '\n\n' - 31 chunks returned. +Chunk 1: '[[what_is_git_section]]\n=== What is Git?' +Chunk 2: "So, what is Git in a nutshell?\nThis is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you.\nAs you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid subtle confusion when using the tool.\nEven though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in a very different way, and understanding these differences will help you avoid becoming confused while using it.(((Subversion)))(((Perforce)))" +Chunk 3: '==== Snapshots, Not Differences' +# END Chunking by paragraph - outputs + +# START Chunking by header - outputs +Using the marker: '\n==' - 7 chunks returned. +Chunk 1: '[[what_is_git_section]]' +Chunk 2: "= What is Git?\n\nSo, what is Git in a nutshell?\nThis is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you.\nAs you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid subtle confusion when using the tool.\nEven though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in a very different way, and understanding these differences will help you avoid becoming confused while using it.(((Subversion)))(((Perforce)))\n" +Chunk 3: "== Snapshots, Not Differences\n\nThe major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data.\nConceptually, most other systems store information as a list of file-based changes.\nThese other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as _delta-based_ version control).\n\n.Storing data as changes to a base version of each file\nimage::images/deltas.png[Storing data as changes to a base version of each file]\n\nGit doesn't think of or store its data this way.\nInstead, Git thinks of its data more like a series of snapshots of a miniature filesystem.\nWith Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.\nTo be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already stored.\nGit thinks about its data more like a *stream of snapshots*.\n\n.Storing data as snapshots of the project over time\nimage::images/snapshots.png[Git stores data as snapshots of the project over time]\n\nThis is an important distinction between Git and nearly all other VCSs.\nIt makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation.\nThis makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS.\nWe'll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in <>.\n" +# END Chunking by header - outputs +""" + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.3.mixed.strategy.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.3.mixed.strategy.py new file mode 100644 index 000000000..b7959d04e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/20_chunking_methods.3.mixed.strategy.py @@ -0,0 +1,50 @@ +# START Asciidoc and size based chunking +from typing import List + +# END Asciidoc and size based chunking + + +# ======================================== +# ======= MIXED-STRATEGY CHUNKING ========= +# ======================================== + +# START Asciidoc and size based chunking +# Get source data +import requests + +url = "https://raw.githubusercontent.com/progit/progit2/main/book/01-introduction/sections/what-is-git.asc" +source_text = requests.get(url).text + +# Split the text by Asciidoc marker +chunks = source_text.split("\n==") + +# Chunking +new_chunks = list() +chunk_buffer = "" +min_length = 25 + +for chunk in chunks: + new_buffer = chunk_buffer + chunk # Create new buffer + new_buffer_words = new_buffer.split(" ") # Split into words + if len(new_buffer_words) < min_length: # Check whether buffer length too small + chunk_buffer = new_buffer # Carry over to the next chunk + else: + new_chunks.append(new_buffer) # Add to chunks + chunk_buffer = "" + +if len(chunk_buffer) > 0: + new_chunks.append(chunk_buffer) # Add last chunk, if necessary + +# Print outputs to screen +for i in range(3): + print(f"Chunk {i+1}: {repr(new_chunks[i])}") +# END Asciidoc and size based chunking + + +""" +# START Mixed-strategy chunking output +Chunk 1: "[[what_is_git_section]]= What is Git?\n\nSo, what is Git in a nutshell?\nThis is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you.\nAs you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid subtle confusion when using the tool.\nEven though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in a very different way, and understanding these differences will help you avoid becoming confused while using it.(((Subversion)))(((Perforce)))\n" +Chunk 2: "== Snapshots, Not Differences\n\nThe major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data.\nConceptually, most other systems store information as a list of file-based changes.\nThese other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as _delta-based_ version control).\n\n.Storing data as changes to a base version of each file\nimage::images/deltas.png[Storing data as changes to a base version of each file]\n\nGit doesn't think of or store its data this way.\nInstead, Git thinks of its data more like a series of snapshots of a miniature filesystem.\nWith Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot.\nTo be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already stored.\nGit thinks about its data more like a *stream of snapshots*.\n\n.Storing data as snapshots of the project over time\nimage::images/snapshots.png[Git stores data as snapshots of the project over time]\n\nThis is an important distinction between Git and nearly all other VCSs.\nIt makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation.\nThis makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS.\nWe'll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in <>.\n" +Chunk 3: "== Nearly Every Operation Is Local\n\nMost operations in Git need only local files and resources to operate -- generally no information is needed from another computer on your network.\nIf you're used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers.\nBecause you have the entire history of the project right there on your local disk, most operations seem almost instantaneous.\n\nFor example, to browse the history of the project, Git doesn't need to go out to the server to get the history and display it for you -- it simply reads it directly from your local database.\nThis means you see the project history almost instantly.\nIf you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally.\n\nThis also means that there is very little you can't do if you're offline or off VPN.\nIf you get on an airplane or a train and want to do a little work, you can commit happily (to your _local_ copy, remember?) until you get to a network connection to upload.\nIf you go home and can't get your VPN client working properly, you can still work.\nIn many other systems, doing so is either impossible or painful.\nIn Perforce, for example, you can't do much when you aren't connected to the server; in Subversion and CVS, you can edit files, but you can't commit changes to your database (because your database is offline).\nThis may not seem like a huge deal, but you may be surprised what a big difference it can make.\n" +# END Mixed-strategy chunking output +""" \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/30_example.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/30_example.py new file mode 100644 index 000000000..075d18b75 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/30_example.py @@ -0,0 +1,571 @@ +# ============================ +# ======= CHUNK DATA ========= +# ============================ + +# START Get text objects from Pro Git book +def get_book_text_objects(): + import requests + + # Source location + text_objs = list() + api_base_url = 'https://api.github.com/repos/progit/progit2/contents/book' # Book base URL + chapter_urls = ['/01-introduction/sections', '/02-git-basics/sections'] # List of section URLs + + # Loop through book chapters + for chapter_url in chapter_urls: + response = requests.get(api_base_url + chapter_url) # Get the JSON data for the section files in the chapter + + # Loop through inner files (sections) + for file_info in response.json(): + if file_info['type'] == 'file': # Only process files (not directories) + file_response = requests.get(file_info['download_url']) + + # Build objects including metadata + chapter_title = file_info['download_url'].split('/')[-3] + filename = file_info['download_url'].split('/')[-1] + text_obj = { + "body": file_response.text, + "chapter_title": chapter_title, + "filename": filename + } + text_objs.append(text_obj) + return text_objs +# END Get text objects from Pro Git book + + +# START Get chunks - helper functions +from typing import List + +def word_splitter(source_text: str) -> List[str]: + import re + source_text = re.sub("\s+", " ", source_text) # Replace multiple whitespces + return re.split("\s", source_text) # Split by single whitespace + +def get_chunks_fixed_size_with_overlap(text: str, chunk_size: int, overlap_fraction: float) -> List[str]: + text_words = word_splitter(text) + overlap_int = int(chunk_size * overlap_fraction) + chunks = [] + for i in range(0, len(text_words), chunk_size): + chunk = " ".join(text_words[max(i - overlap_int, 0): i + chunk_size]) + chunks.append(chunk) + return chunks + +def get_chunks_by_paragraph(source_text: str) -> List[str]: + return source_text.split("\n\n") + +def get_chunks_by_paragraph_and_min_length(source_text: str) -> List[str]: + chunks = source_text.split("\n==") + + # Chunking + new_chunks = list() + chunk_buffer = "" + min_length = 25 + + for chunk in chunks: + new_buffer = chunk_buffer + chunk # Create new buffer + new_buffer_words = new_buffer.split(" ") # Split into words + if len(new_buffer_words) < min_length: # Check whether buffer length too small + chunk_buffer = new_buffer # Carry over to the next chunk + else: + new_chunks.append(new_buffer) # Add to chunks + chunk_buffer = "" + + if len(chunk_buffer) > 0: + new_chunks.append(chunk_buffer) # Add last chunk, if necessary + return new_chunks + +def build_chunk_objs(book_text_obj, chunks): + chunk_objs = list() + for i, c in enumerate(chunks): + chunk_obj = { + "chapter_title": book_text_obj["chapter_title"], + "filename": book_text_obj["filename"], + "chunk": c, + "chunk_index": i + } + chunk_objs.append(chunk_obj) + return chunk_objs +# END Get chunks - helper functions + +# START Get chunks - main body +book_text_objs = get_book_text_objects() + +# Get multiple sets of chunks - according to chunking strategy +chunk_obj_sets = dict() +for book_text_obj in book_text_objs: + text = book_text_obj["body"] # Get the object's text body + + # Loop through chunking strategies: + for strategy_name, chunks in [ + ["fixed_size_25", get_chunks_fixed_size_with_overlap(text, 25, 0.2)], + ["fixed_size_100", get_chunks_fixed_size_with_overlap(text, 100, 0.2)], + ["para_chunks", get_chunks_by_paragraph(text)], + ["para_chunks_min_25", get_chunks_by_paragraph_and_min_length(text)] + ]: + chunk_objs = build_chunk_objs(book_text_obj, chunks) + + if strategy_name not in chunk_obj_sets.keys(): + chunk_obj_sets[strategy_name] = list() + + chunk_obj_sets[strategy_name] += chunk_objs +# END Get chunks - main body + +""" +# START fixed_size_25 chunks +fixed_size_25 +655 chunks in total +Chunk 0: '=== About Version Control\n\n(((version control)))\nWhat is "`version control`", and why should you care?\nVersion control is a system that records changes to a file or set' +Chunk 1: 'to a file or set of files over time so that you can recall specific versions later.\nFor the examples in this book, you will use software source code as the' +Chunk 2: 'software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.\n\nIf you are a graphic or' +# END fixed_size_25 chunks +# START fixed_size_100 chunks +fixed_size_100 +170 chunks in total +Chunk 0: '=== About Version Control\n\n(((version control)))\nWhat is "`version control`", and why should you care?\nVersion control is a system that records changes to a file or set of files over time so that you can recall specific versions later.\nFor the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.\n\nIf you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS)' +Chunk 1: "keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use.\nIt allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.\nUsing a VCS also generally means that if you screw things up or lose files, you can easily recover.\nIn addition, you get all this for very little overhead.\n\n==== Local Version Control Systems\n\n(((version control,local)))\nMany people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're" +Chunk 2: "Systems\n\n(((version control,local)))\nMany people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever).\nThis approach is very common because it is so simple, but it is also incredibly error prone.\nIt is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to.\n\nTo deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.\n\n.Local version control diagram\nimage::images/local.png[Local version control diagram]\n\nOne of the most popular VCS tools was a system called RCS, which is still distributed with many computers today.\nhttps://www.gnu.org/software/rcs/[RCS^] works by keeping patch sets (that is, the differences between" +# END fixed_size_100 chunks +# START para_chunks chunks +para_chunks +549 chunks in total +Chunk 0: '=== About Version Control' +Chunk 1: '(((version control)))\nWhat is "`version control`", and why should you care?\nVersion control is a system that records changes to a file or set of files over time so that you can recall specific versions later.\nFor the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.' +Chunk 2: 'If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use.\nIt allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.\nUsing a VCS also generally means that if you screw things up or lose files, you can easily recover.\nIn addition, you get all this for very little overhead.' +# END para_chunks chunks +# START para_chunks_min_25 chunks +para_chunks_min_25 +93 chunks in total +Chunk 0: '=== About Version Control\n\n(((version control)))\nWhat is "`version control`", and why should you care?\nVersion control is a system that records changes to a file or set of files over time so that you can recall specific versions later.\nFor the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.\n\nIf you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use.\nIt allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.\nUsing a VCS also generally means that if you screw things up or lose files, you can easily recover.\nIn addition, you get all this for very little overhead.\n' +Chunk 1: "== Local Version Control Systems\n\n(((version control,local)))\nMany people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever).\nThis approach is very common because it is so simple, but it is also incredibly error prone.\nIt is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to.\n\nTo deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.\n\n.Local version control diagram\nimage::images/local.png[Local version control diagram]\n\nOne of the most popular VCS tools was a system called RCS, which is still distributed with many computers today.\nhttps://www.gnu.org/software/rcs/[RCS^] works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches.\n" +Chunk 2: "== Centralized Version Control Systems\n\n(((version control,centralized)))\nThe next major issue that people encounter is that they need to collaborate with developers on other systems.\nTo deal with this problem, Centralized Version Control Systems (CVCSs) were developed.\nThese systems (such as CVS, Subversion, and Perforce) have a single server that contains all the versioned files, and a number of clients that check out files from that central place.(((CVS)))(((Subversion)))(((Perforce)))\nFor many years, this has been the standard for version control.\n\n.Centralized version control diagram\nimage::images/centralized.png[Centralized version control diagram]\n\nThis setup offers many advantages, especially over local VCSs.\nFor example, everyone knows to a certain degree what everyone else on the project is doing.\nAdministrators have fine-grained control over who can do what, and it's far easier to administer a CVCS than it is to deal with local databases on every client.\n\nHowever, this setup also has some serious downsides.\nThe most obvious is the single point of failure that the centralized server represents.\nIf that server goes down for an hour, then during that hour nobody can collaborate at all or save versioned changes to anything they're working on.\nIf the hard disk the central database is on becomes corrupted, and proper backups haven't been kept, you lose absolutely everything -- the entire history of the project except whatever single snapshots people happen to have on their local machines.\nLocal VCSs suffer from this same problem -- whenever you have the entire history of the project in a single place, you risk losing everything.\n" +# END para_chunks_min_25 chunks +""" + +# ===================================== +# ======= IMPORT CHUNKED DATA ========= +# ===================================== + + +# START import chunks +import weaviate +import os +from weaviate.util import generate_uuid5 + +client = weaviate.Client( + "http://localhost:8080", + additional_headers={ + "X-OpenAI-Api-Key": os.environ["OPENAI_APIKEY"], + } +) + +chunk_collection_definition = { + "class": "Chunk", + "vectorizer": "text2vec-openai", + "moduleConfig": { + "generative-openai": {} + }, + "properties": [ + { + "name": "chunk", + "dataType": ["text"], + }, + { + "name": "chapter_title", + "dataType": ["text"], + }, + { + "name": "filename", + "dataType": ["text"], + }, + { + "name": "chunking_strategy", + "dataType": ["text"], + "tokenization": "field", + } + ] +} +client.schema.create_class(chunk_collection_definition) + +with client.batch as batch: + for chunking_strategy, chunk_objects in chunk_obj_sets.items(): + for chunk_obj in chunk_objects: + chunk_obj["chunking_strategy"] = chunking_strategy + batch.add_data_object( + data_object=chunk_obj, + class_name="Chunk", + uuid=generate_uuid5(chunk_obj) + ) +# END import chunks + +# START inspection +print("Total count:") +print(client.query.aggregate("Chunk").with_meta_count().do()) # Get a total count +for chunking_strategy in chunk_obj_sets.keys(): + where_filter = { + "path": ["chunking_strategy"], + "operator": "Equal", + "valueText": chunking_strategy + } + print(f"Object count for {chunking_strategy}") + strategy_count = ( + client.query.aggregate("Chunk") + .with_where(where_filter) + .with_meta_count().do() + ) + print(strategy_count) # Get a count for each strategy +# END inspection + +""" +# START Inspection output +Total count: +{'data': {'Aggregate': {'Chunk': [{'meta': {'count': 1487}}]}}} +Object count for fixed_size_25 +{'data': {'Aggregate': {'Chunk': [{'meta': {'count': 672}}]}}} +Object count for fixed_size_100 +{'data': {'Aggregate': {'Chunk': [{'meta': {'count': 173}}]}}} +Object count for para_chunks +{'data': {'Aggregate': {'Chunk': [{'meta': {'count': 549}}]}}} +Object count for para_chunks_min_25 +{'data': {'Aggregate': {'Chunk': [{'meta': {'count': 93}}]}}} +# END Inspection output +""" + + +# =============================== +# ======= VECTOR SEARCH ========= +# =============================== + +def parse_result(response_object): + return response_object["data"]["Get"]["Chunk"] + +# START vector_search +search_string = "history of git" # Or "available git remote commands" + +for chunking_strategy in chunk_obj_sets.keys(): + where_filter = { + "path": ["chunking_strategy"], + "operator": "Equal", + "valueText": chunking_strategy + } + # END vector_search + print(f'\n{"="*20}') + print(f"Retrieved objects for {chunking_strategy}") + # START vector_search + response = ( + client.query.get("Chunk", ["chunk"]) + .with_near_text({"concepts": [search_string]}) + .with_where(where_filter) + .with_limit(2) + .do() + ) + # END vector_search + for i, chunk_obj in enumerate(parse_result(response)): + print(f'{"="*5} Object {i} {"="*5}') + print(chunk_obj["chunk"]) +# END vector_search + + + +""" +# START fixed_size_25 vector_search_history +==================== +Retrieved objects for fixed_size_25 +===== Object 0 ===== +=== A Short History of Git As with many great things in life, Git began with a bit of creative destruction and fiery controversy. The +===== Object 1 ===== +kernel efficiently (speed and data size) Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities. It's amazingly fast, +# END fixed_size_25 vector_search_history + +# START fixed_size_100 vector_search_history +==================== +Retrieved objects for fixed_size_100 +===== Object 0 ===== +=== A Short History of Git As with many great things in life, Git began with a bit of creative destruction and fiery controversy. The Linux kernel is an open source software project of fairly large scope.(((Linux))) During the early years of the Linux kernel maintenance (1991–2002), changes to the software were passed around as patches and archived files. In 2002, the Linux kernel project began using a proprietary DVCS called BitKeeper.(((BitKeeper))) In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool's free-of-charge status was revoked. +===== Object 1 ===== +2005, Git has evolved and matured to be easy to use and yet retain these initial qualities. It's amazingly fast, it's very efficient with large projects, and it has an incredible branching system for non-linear development (see <>). +# END fixed_size_100 vector_search_history + +# START para_chunks vector_search_history +==================== +Retrieved objects for para_chunks +===== Object 0 ===== +Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities. +It's amazingly fast, it's very efficient with large projects, and it has an incredible branching system for non-linear development (see <>). + +===== Object 1 ===== +As with many great things in life, Git began with a bit of creative destruction and fiery controversy. +# END para_chunks vector_search_history + +# START para_chunks_min_25 vector_search_history +==================== +Retrieved objects for para_chunks_min_25 +===== Object 0 ===== +=== A Short History of Git + +As with many great things in life, Git began with a bit of creative destruction and fiery controversy. + +The Linux kernel is an open source software project of fairly large scope.(((Linux))) +During the early years of the Linux kernel maintenance (1991–2002), changes to the software were passed around as patches and archived files. +In 2002, the Linux kernel project began using a proprietary DVCS called BitKeeper.(((BitKeeper))) + +In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool's free-of-charge status was revoked. +This prompted the Linux development community (and in particular Linus Torvalds, the creator of Linux) to develop their own tool based on some of the lessons they learned while using BitKeeper.(((Linus Torvalds))) +Some of the goals of the new system were as follows: + +* Speed +* Simple design +* Strong support for non-linear development (thousands of parallel branches) +* Fully distributed +* Able to handle large projects like the Linux kernel efficiently (speed and data size) + +Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities. +It's amazingly fast, it's very efficient with large projects, and it has an incredible branching system for non-linear development (see <>). + +===== Object 1 ===== +== Nearly Every Operation Is Local + +Most operations in Git need only local files and resources to operate -- generally no information is needed from another computer on your network. +If you're used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers. +Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous. + +For example, to browse the history of the project, Git doesn't need to go out to the server to get the history and display it for you -- it simply reads it directly from your local database. +This means you see the project history almost instantly. +If you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally. + +This also means that there is very little you can't do if you're offline or off VPN. +If you get on an airplane or a train and want to do a little work, you can commit happily (to your _local_ copy, remember?) until you get to a network connection to upload. +If you go home and can't get your VPN client working properly, you can still work. +In many other systems, doing so is either impossible or painful. +In Perforce, for example, you can't do much when you aren't connected to the server; in Subversion and CVS, you can edit files, but you can't commit changes to your database (because your database is offline). +This may not seem like a huge deal, but you may be surprised what a big difference it can make. +# END para_chunks_min_25 vector_search_history +""" + +""" +# START fixed_size_25 vector_search_remote_repo +==================== +Retrieved objects for fixed_size_25 +===== Object 0 ===== +remote))) To add a new remote Git repository as a shortname you can reference easily, run `git remote add `: [source,console] ---- $ git remote origin $ git remote +===== Object 1 ===== +to and from them when you need to share work. Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote +# END fixed_size_25 vector_search_remote_repo + +# START fixed_size_100 vector_search_remote_repo +==================== +Retrieved objects for fixed_size_100 +===== Object 0 ===== +adds the `origin` remote for you. Here's how to add a new remote explicitly.(((git commands, remote))) To add a new remote Git repository as a shortname you can reference easily, run `git remote add `: [source,console] ---- $ git remote origin $ git remote add pb https://github.com/paulboone/ticgit $ git remote -v origin https://github.com/schacon/ticgit (fetch) origin https://github.com/schacon/ticgit (push) pb https://github.com/paulboone/ticgit (fetch) pb https://github.com/paulboone/ticgit (push) ---- Now you can use the string `pb` on the command line in lieu of the whole URL. For example, if you want to fetch all the information that Paul has but that you don't yet have in your repository, you can run `git fetch pb`: [source,console] ---- $ git fetch pb remote: Counting objects: 43, +===== Object 1 ===== +Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more. In this section, we'll cover some of these remote-management skills. [NOTE] .Remote repositories can be on your local machine. ==== It is entirely possible that you can be working with a "`remote`" repository that is, in fact, on the same host you are. The word "`remote`" does not necessarily imply that the repository is somewhere else on the network or Internet, only that it is elsewhere. Working with such a remote repository would still involve all the standard pushing, pulling and fetching operations as with any other remote. ==== +# END fixed_size_100 vector_search_remote_repo + +# START para_chunks vector_search_remote_repo +==================== +Retrieved objects for para_chunks +===== Object 0 ===== +We've mentioned and given some demonstrations of how the `git clone` command implicitly adds the `origin` remote for you. +Here's how to add a new remote explicitly.(((git commands, remote))) +To add a new remote Git repository as a shortname you can reference easily, run `git remote add `: +===== Object 1 ===== +To be able to collaborate on any Git project, you need to know how to manage your remote repositories. +Remote repositories are versions of your project that are hosted on the Internet or network somewhere. +You can have several of them, each of which generally is either read-only or read/write for you. +Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work. +Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more. +In this section, we'll cover some of these remote-management skills. +# END para_chunks vector_search_remote_repo + +# START para_chunks_min_25 vector_search_remote_repo +==================== +Retrieved objects for para_chunks_min_25 +===== Object 0 ===== +== Adding Remote Repositories + +We've mentioned and given some demonstrations of how the `git clone` command implicitly adds the `origin` remote for you. +Here's how to add a new remote explicitly.(((git commands, remote))) +To add a new remote Git repository as a shortname you can reference easily, run `git remote add `: + +[source,console] +---- +$ git remote +origin +$ git remote add pb https://github.com/paulboone/ticgit +$ git remote -v +origin https://github.com/schacon/ticgit (fetch) +origin https://github.com/schacon/ticgit (push) +pb https://github.com/paulboone/ticgit (fetch) +pb https://github.com/paulboone/ticgit (push) +---- + +Now you can use the string `pb` on the command line in lieu of the whole URL. +For example, if you want to fetch all the information that Paul has but that you don't yet have in your repository, you can run `git fetch pb`: + +[source,console] +---- +$ git fetch pb +remote: Counting objects: 43, done. +remote: Compressing objects: 100% (36/36), done. +remote: Total 43 (delta 10), reused 31 (delta 5) +Unpacking objects: 100% (43/43), done. +From https://github.com/paulboone/ticgit + * [new branch] master -> pb/master + * [new branch] ticgit -> pb/ticgit +---- + +Paul's `master` branch is now accessible locally as `pb/master` -- you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it. +We'll go over what branches are and how to use them in much more detail in <>. + +[[_fetching_and_pulling]] +===== Object 1 ===== +[[_remote_repos]]= Working with Remotes + +To be able to collaborate on any Git project, you need to know how to manage your remote repositories. +Remote repositories are versions of your project that are hosted on the Internet or network somewhere. +You can have several of them, each of which generally is either read-only or read/write for you. +Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work. +Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more. +In this section, we'll cover some of these remote-management skills. + +[NOTE] +.Remote repositories can be on your local machine. +# END para_chunks_min_25 vector_search_remote_repo +""" + + +# =================================== +# ======= Retreval augmented generation ========= +# =================================== + +# START generative_search +# Set number of chunks to retrieve to compensate for different chunk sizes +n_chunks_by_strat = dict() +# Grab more of shorter chunks +n_chunks_by_strat['fixed_size_25'] = 8 +n_chunks_by_strat['para_chunks'] = 8 +# Grab fewer of longer chunks +n_chunks_by_strat['fixed_size_100'] = 2 +n_chunks_by_strat['para_chunks_min_25'] = 2 + +# Perform Retreval augmented generation +# highlight-start +search_string = "history of git" # Or "available git remote commands" +# highlight-end + +for chunking_strategy in chunk_obj_sets.keys(): + where_filter = { + "path": ["chunking_strategy"], + "operator": "Equal", + "valueText": chunking_strategy + } + # END generative_search + print(f'\n{"="*20}') + print(f"Generated text for {chunking_strategy}") + # START generative_search + response = ( + client.query.get("Chunk", ["chunk"]) + .with_near_text({"concepts": [search_string]}) + # highlight-start + .with_generate( + grouped_task=f"Using this information, please explain {search_string} in a few short points" + ) + # highlight-end + .with_where(where_filter) + # highlight-start + .with_limit(n_chunks_by_strat[chunking_strategy]) # Variable number of chunks retrieved + # highlight-end + .do() + ) + # END generative_search + print(response["data"]["Get"]["Chunk"][0]["_additional"]["generate"]["groupedResult"]) +# END generative_search + + +""" +==================== +# START fixed_size_25 generative_search_git_history +Generated text for fixed_size_25 +- Git was created in 2005 as a result of creative destruction and controversy. +- It was designed to handle the Linux kernel efficiently in terms of speed and data size. +- Over time, Git has evolved to be easy to use while retaining its initial qualities. +- Git reconsiders many aspects of version control, making it more like a mini filesystem with powerful tools. +- Git stores the entire history of a project locally, allowing for fast and instantaneous operations. +# END fixed_size_25 generative_search_git_history + +==================== +# START fixed_size_100 generative_search_git_history +Generated text for fixed_size_100 +- In the early years of the Linux kernel maintenance (1991-2002), changes to the software were passed around as patches and archived files. +- In 2002, the Linux kernel project started using a proprietary DVCS called BitKeeper. +- In 2005, the relationship between the Linux kernel community and the company behind BitKeeper broke down, leading to the revocation of the tool's free-of-charge status. +- Since then, Git has evolved and matured, becoming easy to use while retaining its initial qualities. It is known for its speed, efficiency with large projects, and its powerful branching system for non-linear development. +# END fixed_size_100 generative_search_git_history + +==================== +# START para_chunks generative_search_git_history +Generated text for para_chunks +- Git was created in 2005 and has since evolved and matured to be easy to use and efficient with large projects. +- Git has an incredibly fast performance and a powerful branching system for non-linear development. +- Git began with controversy and creative destruction. +- Git is fundamentally different from other version control systems (VCS) in the way it thinks about and stores data. +- Git operates mostly on local files and resources, making operations fast and efficient. +- Git has integrity and ensures the integrity of its data. +- Git is more like a mini filesystem with powerful tools built on top of it, rather than just a VCS. +# END para_chunks generative_search_git_history +==================== + +# START para_chunks_min_25 generative_search_git_history +Generated text for para_chunks_min_25 +- Git was created in 2005 by the Linux development community, led by Linus Torvalds, after the breakdown of their relationship with the proprietary DVCS called BitKeeper. +- The goals of Git were to be fast, have a simple design, support non-linear development with thousands of parallel branches, be fully distributed, and handle large projects efficiently. +- Git has evolved and matured since its creation, becoming easy to use while retaining its initial qualities. +- One of the key advantages of Git is that nearly every operation is local, meaning that most operations can be performed without needing information from another computer on the network. +- This local nature of Git allows for fast and instantaneous operations, such as browsing the project history or comparing file versions. +- Being able to work offline or off VPN is also a significant advantage of Git, as it allows users to continue working and committing changes to their local copy until they have a network connection to upload. +# END para_chunks_min_25 generative_search_git_history +""" + + + +""" +==================== +# START fixed_size_25 generative_search_git_remote +Generated text for fixed_size_25 +- `git fetch `: This command retrieves data from the remote repository specified by ``. +- `git remote show `: Running this command with a specific shortname, such as `origin`, displays information about the remote repository, including its branches and configuration. +- `git remote`: This command lists all the remote servers that have been configured for the repository. +- `git remote -v`: Similar to `git remote`, this command lists all the remote servers along with their URLs for fetching and pushing. +- `git clone`: This command is used to create a local copy of a remote repository. By default, it sets up the local `master` branch to track the remote repository's `master` branch. +- `git remote add `: This command adds a new remote repository with the specified `` and ``. This allows you to easily fetch and push changes to and from the remote repository. +- `git remote remove `: This command removes the remote repository with the specified `` from the local repository. +# END fixed_size_25 generative_search_git_remote + +==================== +# START fixed_size_100 generative_search_git_remote +Generated text for fixed_size_100 +- The `git remote` command is used to see which remote servers are configured for the repository. It lists the shortnames of each remote handle that has been specified. +- The `git remote -v` command can be used to display more detailed information about the remote repositories, including the URLs for fetching and pushing. +- The `git clone` command automatically adds the `origin` remote when cloning a repository. +- To add a new remote explicitly, the `git remote add ` command can be used. This allows for pulling and pushing to the specified remote repository. +# END fixed_size_100 generative_search_git_remote + +==================== +# START para_chunks generative_search_git_remote +Generated text for para_chunks +- The `git remote` command lists the shortnames of each remote handle that you have configured. +- The `git remote show ` command provides more information about a particular remote. +- The `git remote -v` command shows the URLs associated with each remote. +- The `git remote add ` command adds a new remote Git repository with a specified shortname and URL. +- The `git remote` command can be used to show all the remotes associated with a repository. +# END para_chunks generative_search_git_remote +==================== + +# START para_chunks_min_25 generative_search_git_remote +Generated text for para_chunks_min_25 +- The `git remote` command is used to see which remote servers you have configured. It lists the shortnames of each remote handle you've specified. +- The `git remote -v` command shows the URLs that Git has stored for the shortname to be used when reading and writing to that remote. +- The `git remote show ` command provides more information about a particular remote, including the URL for the remote repository, tracking branch information, and details about branches that can be automatically merged or pushed to. +# END para_chunks_min_25 generative_search_git_remote +""" + +# TODO - needs tests diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/what-is-git.asc b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/what-is-git.asc new file mode 100644 index 000000000..8953b9d48 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/_snippets/what-is-git.asc @@ -0,0 +1,109 @@ +[[what_is_git_section]] +=== What is Git? + +So, what is Git in a nutshell? +This is an important section to absorb, because if you understand what Git is and the fundamentals of how it works, then using Git effectively will probably be much easier for you. +As you learn Git, try to clear your mind of the things you may know about other VCSs, such as CVS, Subversion or Perforce -- doing so will help you avoid subtle confusion when using the tool. +Even though Git's user interface is fairly similar to these other VCSs, Git stores and thinks about information in a very different way, and understanding these differences will help you avoid becoming confused while using it.(((Subversion)))(((Perforce))) + +==== Snapshots, Not Differences + +The major difference between Git and any other VCS (Subversion and friends included) is the way Git thinks about its data. +Conceptually, most other systems store information as a list of file-based changes. +These other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the information they store as a set of files and the changes made to each file over time (this is commonly described as _delta-based_ version control). + +.Storing data as changes to a base version of each file +image::images/deltas.png[Storing data as changes to a base version of each file] + +Git doesn't think of or store its data this way. +Instead, Git thinks of its data more like a series of snapshots of a miniature filesystem. +With Git, every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. +To be efficient, if files have not changed, Git doesn't store the file again, just a link to the previous identical file it has already stored. +Git thinks about its data more like a *stream of snapshots*. + +.Storing data as snapshots of the project over time +image::images/snapshots.png[Git stores data as snapshots of the project over time] + +This is an important distinction between Git and nearly all other VCSs. +It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation. +This makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS. +We'll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in <>. + +==== Nearly Every Operation Is Local + +Most operations in Git need only local files and resources to operate -- generally no information is needed from another computer on your network. +If you're used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers. +Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous. + +For example, to browse the history of the project, Git doesn't need to go out to the server to get the history and display it for you -- it simply reads it directly from your local database. +This means you see the project history almost instantly. +If you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally. + +This also means that there is very little you can't do if you're offline or off VPN. +If you get on an airplane or a train and want to do a little work, you can commit happily (to your _local_ copy, remember?) until you get to a network connection to upload. +If you go home and can't get your VPN client working properly, you can still work. +In many other systems, doing so is either impossible or painful. +In Perforce, for example, you can't do much when you aren't connected to the server; in Subversion and CVS, you can edit files, but you can't commit changes to your database (because your database is offline). +This may not seem like a huge deal, but you may be surprised what a big difference it can make. + +==== Git Has Integrity + +Everything in Git is checksummed before it is stored and is then referred to by that checksum. +This means it's impossible to change the contents of any file or directory without Git knowing about it. +This functionality is built into Git at the lowest levels and is integral to its philosophy. +You can't lose information in transit or get file corruption without Git being able to detect it. + +The mechanism that Git uses for this checksumming is called a SHA-1 hash.(((SHA-1))) +This is a 40-character string composed of hexadecimal characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git. +A SHA-1 hash looks something like this: + +[source] +---- +24b9da6552252987aa493b52f8696cd6d3b00373 +---- + +You will see these hash values all over the place in Git because it uses them so much. +In fact, Git stores everything in its database not by file name but by the hash value of its contents. + +==== Git Generally Only Adds Data + +When you do actions in Git, nearly all of them only _add_ data to the Git database. +It is hard to get the system to do anything that is not undoable or to make it erase data in any way. +As with any VCS, you can lose or mess up changes you haven't committed yet, but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository. + +This makes using Git a joy because we know we can experiment without the danger of severely screwing things up. +For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see <>. + +==== The Three States + +Pay attention now -- here is the main thing to remember about Git if you want the rest of your learning process to go smoothly. +Git has three main states that your files can reside in: _modified_, _staged_, and _committed_: + +* Modified means that you have changed the file but have not committed it to your database yet. +* Staged means that you have marked a modified file in its current version to go into your next commit snapshot. +* Committed means that the data is safely stored in your local database. + +This leads us to the three main sections of a Git project: the working tree, the staging area, and the Git directory. + +.Working tree, staging area, and Git directory +image::images/areas.png["Working tree, staging area, and Git directory"] + +The working tree is a single checkout of one version of the project. +These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. + +The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. +Its technical name in Git parlance is the "`index`", but the phrase "`staging area`" works just as well. + +The Git directory is where Git stores the metadata and object database for your project. +This is the most important part of Git, and it is what is copied when you _clone_ a repository from another computer. + +The basic Git workflow goes something like this: + +1. You modify files in your working tree. +2. You selectively stage just those changes you want to be part of your next commit, which adds _only_ those changes to the staging area. +3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. + +If a particular version of a file is in the Git directory, it's considered _committed_. +If it has been modified and was added to the staging area, it is _staged_. +And if it was changed since it was checked out but has not been staged, it is _modified_. +In <>, you'll learn more about these states and how you can either take advantage of them or skip the staged part entirely. diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/index.mdx new file mode 100644 index 000000000..e74c75846 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/chunking/index.mdx @@ -0,0 +1,58 @@ +--- +title: 長文のチャンク化 +description: "Python で Weaviate スタンドアロンを用いたデータのチャンク化によるストレージとパフォーマンスの最適化を探求します。" +sidebar_position: 101 # Like a subject number (e.g. CS101) +--- + +## ユニット概要 + +import PreviewUnit from '../../../_snippets/preview.mdx' + + + +import ReactPlayer from 'react-player/lazy' + + +
+ + + + + +チャンク化は、ベクトル データベースと大型言語モデルの世界において重要な概念です。これまでのユニットでは比較的短いテキストを扱ってきましたが、実際のテキスト データはもっと長い場合が多いです。 + +記事や書き起こし、さらには書籍の長さを考えてみてください。数語どころか、数千語、数万語、場合によってはそれ以上になることもあります。たとえば *The Lord of the Rings* は 500,000 語以上にもなります。 + +チャンク化とは、このようなテキストをより小さなテキスト片、すなわち「チャンク」に分割してからベクトル データベースに保存したり、言語モデルへ渡したりすることです。 + +一見すると、文や段落をどこで分割するか程度の些細な判断に思えるかもしれません。しかし、チャンク化の方法によってベクトル データベースの検索性能・挙動や、言語モデルの出力が大きく変わる可能性があります。本ユニットでは、ユーザーの視点からこの一見シンプルでありながら繊細なトピックを扱います。 + +まず、チャンク化とは何か、なぜ使用するのかを説明します。その後、さまざまなチャンク化手法を紹介し、チャンク化戦略を決める際の重要な検討事項と、推奨される出発点について議論します。 + +このユニットを終える頃には、チャンク化の基本を十分に理解し、実際のニーズに基づいて堅実なチャンク化戦略を実装できるようになります。 + +### 前提条件 + +- (**Required**) `weaviate-client` がインストールされた Python (3) 環境 +- (**Required**) [101A Weaviate Academy Preparation](../../zero_to_mvp/setup.mdx) を完了していること +- (*Recommended*) [Hello, Weaviate](../../zero_to_mvp/101_hello_weaviate/index.mdx) を完了していること +- (*Recommended*) [Queries 1](../../zero_to_mvp/102_queries_1/index.mdx) を完了していること +- (*Recommended*) [Schema and Imports](../../zero_to_mvp/103_schema_and_imports/index.mdx) を完了していること + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/index.md new file mode 100644 index 000000000..507f51a05 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/index.md @@ -0,0 +1,17 @@ +--- +title: 短いユニット +description: "ローカルまたは小規模アプリケーション向けに、スタンドアロンモードで Weaviate をセットアップします。" +sidebar_position: 900 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## 概要 + +このセクションには、他のトピックとは独立して読み進められる短いスタンドアロンユニットが含まれています。 + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/05_review.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/05_review.mdx new file mode 100644 index 000000000..95a143849 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/05_review.mdx @@ -0,0 +1,119 @@ +--- +title: 検索タイプのレビュー +description: データ クエリを洗練するための Weaviate における検索戦略のレビュー。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/05_review.py'; + +## 概要 + +Weaviate は主に 3 つの検索タイプ、つまり ** ベクトル **、** キーワード **、そして ** ハイブリッド ** 検索を提供します。ここでは、それぞれの概要と動作を簡単に振り返ります。 + +### コード例 + +これらのコード例は、[`v4` Weaviate Python client](/weaviate/client-libraries/python/index.mdx) を用いて実行できます。以下のコードで事前構成済みのデモ インスタンスへ接続し、続く例を試してみてください。 + + + + + + + + + +## ベクトル検索 + +ベクトル検索では、クエリ ベクトル に最も類似した ベクトル を持つオブジェクトを見つけます。 + +各 ベクトル は基になるオブジェクトを数値で表現しているため、ベクトル類似度は「意味的な類似度」と捉えられます。そのため、ベクトル検索は「セマンティック検索」とも呼ばれます。 + +Weaviate では、次のいずれかの方法で類似 ベクトル を持つオブジェクトを検索できます。 + +ソース メディア(例: テキストや画像)を指定: + + + + + + + + + +ベクトル を直接指定: + + + + + + + + + +既存の Weaviate オブジェクトを指定: + + + + + + + + + +## キーワード検索 + +キーワード検索では、クエリのキーワード(トークン)と最も関連性の高いキーワードを持つオブジェクトを見つけます。関連性は BM25F アルゴリズムにより決定されます。 + +直感的には、BM25F アルゴリズムは、特定のキーワードがデータセット全体でどれだけ一般的かと比較しながら、各オブジェクトのフィールドごとにそのキーワードが出現する頻度を考慮して「関連性」を算出します。 + + + + + + + + + +## ハイブリッド検索 + +ハイブリッド検索は、ベクトル検索とキーワード検索の結果を組み合わせます。両方の検索を実行した後、「fusion」アルゴリズムで 2 つの検索結果を結合します。 + + + + + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/10_strengths.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/10_strengths.mdx new file mode 100644 index 000000000..d4325c82a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/10_strengths.mdx @@ -0,0 +1,202 @@ +--- +title: 各検索タイプの強み +description: 特定のユースケース向けに Weaviate の各検索手法の強みを確認します。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/10_strengths.py'; + + +## 概要 + +これらの異なる検索タイプは、それぞれ特性が異なるため強みも異なります。 + +ここでは各検索タイプの相対的な強みを見ていきます。 + +## ベクトル検索の強み + +### 頑健性 + +ベクトルは、対象オブジェクトの意味を数値で表現したものです。そのため、意味を変えない変更に対してベクトル検索は頑健です。 + +具体的な例として、「 cat 」のベクトルは、綴りが大きく異なる「 kitten 」「 feline 」「 pet 」などのベクトルとも近くなります。 + +以下では、「 cat 」と「 kitten 」をベクトル検索した結果を確認します。 + + + + + + + + + +ご覧のとおり、「 cat 」と「 kitten 」の検索結果は非常に似ています。 + +つまり、モデルが意味を「理解」できるため、「 cat 」と「 kitten 」のベクトルは意味的に近いのです。 + + + +同様に、「 cat 」のベクトルは、綴りを誤った「 caat 」や「 catt 」のベクトルとも近くなります。 + + + + + + + + + +ここでは結果はほぼ同一になります。 + + + +この頑健性こそがベクトル検索の大きな強みです。検索者はデータセットで使用されている正確な単語を知る必要がありません。特に、検索対象の概念が明確に定義されていない場合や、検索者がデータセットに詳しくない場合に有用です。 + +### 多様性 + +ベクトル検索は多用途でもあります。テキスト・画像・音声など複数のデータモダリティ、および複数言語を対象に検索できます。 + +ベクトルは対象オブジェクトの意味を数値で表現しているため、モダリティや言語が異なっても同じ意味であれば同じベクトルで表現できます。 + +実際、複数モダリティや複数言語(あるいはその両方)をまたいで検索できるモデルも存在します。これは、モダリティや言語に依存せず、すべてのデータを比較可能なベクトルに変換できるモデルを使用することで実現しています。 + +![複数モダリティにわたるベクトル化](./_img/multimodal_example.png) + +## キーワード検索の強み + +### 精確性 + +キーワード検索は、正確な一致を見つける必要がある場面に最適です。学術研究、ドメイン固有データの検索、技術的なトラブルシューティングなど、検索すべき正確な用語が存在するシナリオで特に有用です。 + +検索語に完全一致する結果を返せることで、ユーザーは自分のクエリに最も関連する情報を受け取れます。 + +具体的には、次の例では「 imaging 」で検索します。 + + + + + + + + + +結果を確認します。 + + + +キーワード検索で「 imaging 」を検索すると、その単語を含む 1 件のみが返されます。 +## ハイブリッド検索の強み + +ハイブリッド検索の大きな強みは、そのレジリエンスです。これについて詳しく見ていきましょう。 + +### レジリエンス + +ハイブリッド検索は、 ベクトル 検索とキーワード検索の双方で上位にランク付けされた結果を組み合わせるため、レジリエンスがあります。これにより、それぞれの検索方式の弱点を補うことができます。 + +以下のハイブリッド検索の例をご覧ください。 + + + + + + + + + +ここで結果を確認できます。 + + + +上記のキーワード検索結果( " imaging " )に加えて、意味的に関連する結果( " X-rays " )も取得できていることがわかります。 + +ハイブリッド検索は、 ベクトル 検索とキーワード検索の両方の結果を組み合わせるため、少なくともどちらか一方で高いスコアを得たオブジェクトを見つけ出します。このアプローチにより、各検索方式を相互に補完する効果が得られます。 + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/20_selection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/20_selection.mdx new file mode 100644 index 000000000..35d313b25 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/20_selection.mdx @@ -0,0 +1,105 @@ +--- +title: 適切な検索タイプの選択 +description: 最適な結果を得るために Weaviate の検索戦略を選択します。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/20_selection.py'; + + +## 概要 + +適切な検索タイプを選択することは、効果的な検索タスクの鍵です。ニーズに合った検索タイプの選び方を見ていきましょう。 + + +## 指針 + + +### ベクトル検索の利用タイミング + +ベクトル検索は最も堅牢で多用途な検索タイプです。そのため、意味、すなわちベクトル表現が最も重要となる状況に適しています。 + +クロスモーダル、オブジェクトベース、または多言語検索では、ベクトル検索が唯一の実用的な選択肢となる場合があります。 + +ベクトル検索から始めるべきケース: + +- **非テキストまたはクロスモーダル検索**: テキストで画像を探す、あるいはその逆など、異なるメディア間で検索する際に必須です。 +- **オブジェクトベースの検索**: 抽出したテキストチャンク、画像、動画に似たオブジェクトを探す場合、ベクトル検索がおそらく唯一の実用的な解決策です。 +- **多言語コンテキスト**: 従来のキーワード検索では不十分な多言語検索における定番の選択肢です。 +- **複雑なクエリ理解**: 文脈や言語のニュアンスを理解する必要がある複雑なクエリに対して、ベクトル検索は優れた性能を発揮します。 + +### キーワード検索の利用タイミング + +キーワード検索は、検索語を正確に一致させることが期待・要求される場合に有用です。法律、医療、技術分野など、正確な用語が重要な特定ドメインが該当します。 + +また、ユーザーが入力ミスをしにくく、サニタイズされたフォームやドロップダウンメニューを通じて予測可能な語を入力する場合にも効果的です。 + +まとめると、キーワード検索から始めるべきケース: + +**正確な用語の一致**: 法律・医療・技術分野など、特定の用語が重要な領域に最適です。 +**予測可能なユーザー入力**: フォームやドロップダウンなど、定義済みの語を入力する状況で効果的です。 +**シンプルで直接的なクエリ**: 自然言語処理の複雑さが不要な、単純な検索ニーズに適しています。 +**高速かつ特定の結果**: 特定のキーワードやフレーズに基づく情報を素早く取得するのに向いています。 + +### ハイブリッド検索の利用タイミング + +ハイブリッド検索は「扱いづらい」状況に最適な選択です。 + +ハイブリッド検索はベクトル検索とキーワード検索の結果セットを組み合わせるため、ベクトル検索の堅牢さとキーワード検索の精度の両方をバランス良く提供できます。 + +その結果、ベクトル検索やキーワード検索の特定のユースケースに当てはまらないほとんどの検索ニーズに対して、ハイブリッド検索は一般的に優れた選択肢となります。 + +まとめると、ハイブリッド検索を検討すべきケース: + +- **幅広いトピック範囲**: 対象コーパスが多岐にわたるテーマを含む場合に効果的です。 +- **多様な検索シナリオ**: 現実のシナリオでは、ベクトルとキーワードの両検索結果を組み合わせる必要があることが多く、そのような場面で役立ちます。 +- **予測不能なユーザー入力**: ユーザーが自由にクエリを入力できる実際の多くのシーンに最適です。あるユーザーは直接一致を求める一方、別のユーザーは全体的な意味を重視する場合があります。 + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/30_strategies.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/30_strategies.mdx new file mode 100644 index 000000000..fda388148 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/30_strategies.mdx @@ -0,0 +1,209 @@ +--- +title: 検索結果を改善するための戦略 +description: データ取得を強化するための Weaviate 検索戦略を探る。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/30_strategies.py'; + + +## 概要 + +適切な検索タイプを選択することに加えて、検索結果の品質を向上させるために活用できる戦略がいくつかあります。 + +ここでは、それらの戦略を見ていきます。 + +## ベクトル検索の改善 + +ベクトル検索を向上させる鍵は、オブジェクトのベクトル表現が検索ニーズに合致していること、つまり目的に適したものであることです。 + +### ベクトライザーの選定 + +独自のベクトルを挿入しない限り、Weaviate ベクトライザー モジュールと、そのモジュール内のモデルを使用してデータのベクトルを生成します。 + +ベクトライザー モジュールとモデルの選択は重要です。これにより、データのどの側面がベクトル表現に取り込まれるか、モデルがデータをどの程度「理解」できるかが決まります。 + +まず第一に、データタイプに最適なベクトライザー モジュールを選択してください。たとえば、テキスト データを扱う場合は `text2vec` モジュールを、画像やマルチモーダル データを扱う場合は `multi2vec` モジュールを使用するのが適切です。 + +ベクトライザー選択については別のユニットで取り上げますが、迷った場合は以下を試してください。 +- テキスト データ:`text2vec-cohere` または `text2vec-openai`(API ベース) + - Cohere には 100 以上の言語に対応した多言語モデルがあります。 +- 画像、または画像とテキスト:`multi2vec-clip` + +ローカル推論コンテナでテキストを扱いたい場合は、`text2vec-transformers` を使用し、`sentence-transformers/all-MiniLM-L12-v2` などの一般的なモデルを試してみてください。 + +### リランカーの利用 + +リランカー モジュールは検索結果の品質を向上させる優れた方法です。 + +リランカー モジュールはベクトル検索の結果を受け取り、追加の基準または別のモデルを用いて結果を再ランク付けします。これにより、高品質(ただし遅い)モデルをリランキングに使用しつつ、高速な一次検索の恩恵を受けることができます。 + +たとえば、`text2vec-cohere` モジュールでベクトル検索を実行し、その結果を `reranker-cohere` モジュールで再ランク付けするといった使い方が可能です。 + +### プロパティの選定 + +ベクトル化はオブジェクトの「意味」を捉えます。そのため、検索基準に関連しないプロパティはベクトル化プロセスから除外するべきです。 + +例として、商品オブジェクトに製造工程や製造場所などのメタデータが含まれている場合、ベクトル検索を商品の特徴に基づいて行いたいのであれば、製造工程や製造場所のプロパティはベクトル化から除外します。 + +これは、以下のようにベクトル化時にプロパティをスキップするかどうかを指定することで実現できます。コレクション名やプロパティ名についても同様に設定可能です。 + + + + + + + + + +### チャンク化 + +チャンク化とは、テキストを小さなチャンクに分割し、それぞれを個別にベクトル化するプロセスを指します。これは各ベクトルが含む情報量を決定するため非常に重要です。 + +経験則として、検索ニーズが細かいほどチャンクサイズを小さくする必要があります。たとえば、特定の概念やアイデアを検索する場合は、文章や小さなテキストウィンドウなど、より小さな単位にチャンク化します。逆に、章や書籍などのより大きな概念を検索する場合は、それに応じてチャンク化することが適切です。 + +詳細は Weaviate Academy の [チャンク化ユニット](../chunking/index.mdx) をご覧ください。 + +## キーワード検索の改善 + +### トークナイズ + +BM25 検索を「キーワード」検索と表現しますが、実際には正確に一致するのは「単語」ではなく「トークン」です。これはベクトル埋め込み生成時に使用されるトークナイズとは異なり、BM25 検索やフィルタリングのために転置インデックスを構築する際に使用されます。 + +したがって、トークナイズはマッチングに使用されるトークンを決定する重要なプロセスです。 + +利用可能なオプションは `word`、`lowercase`、`whitespace`、`field` です。デフォルト(`word`)は散文には十分かもしれませんが、大文字小文字や記号を含む厳密な一致が重要なテキストでは `whitespace` などが適している場合があります。 + +利用可能なトークナイズ オプション: + +import TokenizationDefinition from '/_includes/tokenization_definition.mdx'; + + + +トークナイズはコレクション設定で指定できます。 + + + + + + + + + +### プロパティの選択とブースト + +特定のプロパティでの一致が検索結果に過度な影響を及ぼしている場合、それらを検索対象から除外したり、特定プロパティの重要度をブーストしたりできます。 + +たとえば、`description` プロパティでの一致は `notes` プロパティでの一致よりも重要かもしれません。これはクエリ時に指定できます。 + + + + + + + + +## ハイブリッド検索の改善 + +### Alpha パラメータ + +alpha パラメータは、ベクトル検索結果とキーワード検索結果のバランスを決定します。 + +検索をよりベクトルベースにしたい場合は、alpha 値を大きくします。逆に、検索をよりキーワードベースにしたい場合は、alpha 値を小さくします。 + + + + + + + + + +### 融合アルゴリズム + +融合アルゴリズムは、ベクトル検索とキーワード検索の結果をどのように統合するかを決定します。 + +デフォルトでは、各結果セットの順位の逆数を合計する "ranked fusion" アルゴリズムが使用されます。これに対し、各結果セットの正規化されたスコアを合計する "relative score fusion" アルゴリズムを使用することもできます。 + +一般的に、relative score fusion アルゴリズムの方が良い結果になることが多いですが、ユースケースによって異なるため、両方を試して最適な方を確認してください。 + + + + + + + + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_30_improve_search.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_30_improve_search.mdx new file mode 100644 index 000000000..660709cbb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_30_improve_search.mdx @@ -0,0 +1,13 @@ +--- +title: 検索の改善 +--- + +- 検索品質の評価 +- 検索品質の改善 + - ベクトライザー + - データ構造 + - 検索タイプ +- 検索速度の改善 + - 推論速度 + - リソース需要 + - クエリのボトルネック \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_img/multimodal_example.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_img/multimodal_example.png new file mode 100644 index 000000000..628d4d5be Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_img/multimodal_example.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/05_review.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/05_review.py new file mode 100644 index 000000000..4982b0e95 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/05_review.py @@ -0,0 +1,105 @@ +from uuid import UUID +import os + +weaviate_url = os.getenv("WEAVIATE_URL") +weaviate_key = os.getenv("WEAVIATE_API_KEY") + +# START connectionCode +import weaviate +import weaviate.classes as wvc + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=wvc.init.Auth.api_key(weaviate_key), + headers={ + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") # Replace with your OpenAI API key (for vector and hybrid searches) + } +) +# END connectionCode + +# START nearTextExample +questions = client.collections.use("JeopardyQuestion") +response = questions.query.near_text( + query="space travel", # Your query string + limit=2 +) + +for o in response.objects: + print(o.uuid) + print(o.properties) +# END nearTextExample + +assert len(response.objects) == 2 +assert "question" in response.objects[0].properties.keys() + + +response = questions.query.near_text( + query="space travel", + limit=1, + include_vector=True +) +vector_input = response.objects[0].vector +object_input = response.objects[0].uuid + +# START nearVectorExample +questions = client.collections.use("JeopardyQuestion") +response = questions.query.near_vector( + near_vector=vector_input, # Your vector object + limit=2 +) + +for o in response.objects: + print(o.uuid) + print(o.properties) +# END nearVectorExample + +assert len(response.objects) == 2 +assert "question" in response.objects[0].properties.keys() + + +# START nearObjectExample +questions = client.collections.use("JeopardyQuestion") +response = questions.query.near_object( + near_object=object_input, # Your object UUID + limit=2 +) + +for o in response.objects: + print(o.uuid) + print(o.properties) +# END nearObjectExample + +assert len(response.objects) == 2 +assert "question" in response.objects[0].properties.keys() + + +# START bm25Example +questions = client.collections.use("JeopardyQuestion") +response = questions.query.bm25( + query="space travel", # Your query string + limit=2 +) + +for o in response.objects: + print(o.uuid) + print(o.properties) +# END bm25Example + +assert len(response.objects) == 2 +assert "question" in response.objects[0].properties.keys() + + +# START hybridExample +questions = client.collections.use("JeopardyQuestion") +response = questions.query.hybrid( + query="space travel", # Your query string + limit=2 +) + +for o in response.objects: + print(o.uuid) + print(o.properties) +# END hybridExample + +assert len(response.objects) == 2 +assert "question" in response.objects[0].properties.keys() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/10_strengths.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/10_strengths.py new file mode 100644 index 000000000..41f5b71ee --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/10_strengths.py @@ -0,0 +1,160 @@ +from uuid import UUID +import os +import weaviate +import weaviate.classes as wvc +import json + +weaviate_url = os.getenv("WEAVIATE_URL") +weaviate_key = os.getenv("WEAVIATE_API_KEY") + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=wvc.init.Auth.api_key(weaviate_key), + headers={ + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") + } +) + + +# START robustnessExampleWords +for query in ["cat", "kitten"]: + questions = client.collections.use("JeopardyQuestion") + response = questions.query.near_text( + query=query, + limit=1, + return_metadata=wvc.query.MetadataQuery(distance=True), + return_properties=["question", "answer"] + ) + + for o in response.objects: + print(f"\n===== Search results for {query} =====") + print(f"Distance: {o.metadata.distance:.3f}") + print(json.dumps(o.properties, indent=2)) +# END robustnessExampleWords + +assert len(response.objects) == 1 +assert "question" in response.objects[0].properties.keys() + + +""" +# START responseRobustnessExampleWords +===== Search results for cat ===== +Distance: 0.170 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} + +===== Search results for kitten ===== +Distance: 0.150 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} +# END responseRobustnessExampleWords +""" + + + +# START robustnessExampleSpelling +for query in ["cat", "catt", "caat"]: + questions = client.collections.use("JeopardyQuestion") + response = questions.query.near_text( + query=query, + limit=1, + return_metadata=wvc.query.MetadataQuery(distance=True), + return_properties=["question", "answer"] + ) + + for o in response.objects: + print(f"\n===== Search results for {query} =====") + print(f"Distance: {o.metadata.distance:.3f}") + print(json.dumps(o.properties, indent=2)) +# END robustnessExampleSpelling + +assert len(response.objects) == 1 +assert "question" in response.objects[0].properties.keys() + + +""" +# START responseRobustnessExampleSpelling +===== Search results for cat ===== +Distance: 0.170 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} + +===== Search results for catt ===== +Distance: 0.177 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} + +===== Search results for caat ===== +Distance: 0.184 +{ + "answer": "Fat cat", + "question": "A flabby tabby" +} +# END responseRobustnessExampleSpelling +""" + + +# START bm25Example +questions = client.collections.use("JeopardyQuestion") +response = questions.query.bm25( + query="imaging", # Your query string + return_properties=["question", "answer"], + limit=2 +) + +for o in response.objects: + print(o.uuid) + print(json.dumps(o.properties, indent=2)) +# END bm25Example + +assert "question" in response.objects[0].properties.keys() + +""" +# START bm25Results +49fe3d7c-61a5-5916-99bb-052d07c7c251 +{ + "answer": "magnetic resonance imaging", + "question": "MRI, which stands for this, cannot be used on patients with pacemakers or artificial metal joints" +} +# END bm25Results +""" + + +# START hybridExample +questions = client.collections.use("JeopardyQuestion") +response = questions.query.hybrid( + query="imaging", # Your query string + return_properties=["question", "answer"], + limit=2 +) + +for o in response.objects: + print(o.uuid) + print(json.dumps(o.properties, indent=2)) +# END hybridExample + +assert "question" in response.objects[0].properties.keys() + + +""" +# START hybridResults +49fe3d7c-61a5-5916-99bb-052d07c7c251 +{ + "answer": "magnetic resonance imaging", + "question": "MRI, which stands for this, cannot be used on patients with pacemakers or artificial metal joints" +} +9041bce6-b5d1-5637-bcbe-2ebb8a689fe0 +{ + "answer": "X-rays", + "question": "These electromagnetic rays used to take pictures of your insides were originally known as Roentgen rays" +} +# END hybridResults +""" diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/20_selection.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/20_selection.py new file mode 100644 index 000000000..e69de29bb diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/30_strategies.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/30_strategies.py new file mode 100644 index 000000000..00aea2d7c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/_snippets/30_strategies.py @@ -0,0 +1,135 @@ +from uuid import UUID +import os +import weaviate +import weaviate.classes as wvc +import json + + +client = weaviate.connect_to_local( + headers={ + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") + } +) + + +client.collections.delete("Product") + +# START skipVectorizationExample +products = client.collections.create( + name="Product", + vector_config=wvc.Configure.Vectors.text2vec_openai( + # highlight-start + vectorize_collection_name=True + # highlight-end + ), + properties=[ + wvc.config.Property( + name="name", + data_type=wvc.config.DataType.TEXT, + # highlight-start + vectorize_property_name=True, + # highlight-end + ), + wvc.config.Property( + name="description", + data_type=wvc.config.DataType.TEXT, + ), + wvc.config.Property( + name="manufacturing_process", + data_type=wvc.config.DataType.TEXT, + # highlight-start + skip_vectorization=True # Skip unwanted property + # highlight-end + ), + ] +) +# END skipVectorizationExample + +client.collections.delete("Product") + + + +client.collections.delete("SomeCollection") + +# START tokenizationExample +things = client.collections.create( + name="SomeCollection", + properties=[ + wvc.config.Property( + name="name", + data_type=wvc.config.DataType.TEXT, + # highlight-start + tokenization=wvc.config.Tokenization.WORD # Default + # highlight-end + ), + wvc.config.Property( + name="description", + data_type=wvc.config.DataType.TEXT, + tokenization=wvc.config.Tokenization.WHITESPACE # Will keep case & special characters + ), + wvc.config.Property( + name="email", + data_type=wvc.config.DataType.TEXT, + # highlight-start + tokenization=wvc.config.Tokenization.FIELD # Do not tokenize at all + # highlight-end + ), + ] +) +# END tokenizationExample + +client.collections.delete("SomeCollection") + +from weaviate.classes.init import Auth + +weaviate_url = os.getenv("WEAVIATE_URL") +weaviate_key = os.getenv("WEAVIATE_API_KEY") + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=Auth.api_key(weaviate_key), + headers={ + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") + } +) + +# START selectAndBoostExample +questions = client.collections.use("JeopardyQuestion") + +response = questions.query.bm25( + "animal", + limit=5, + query_properties=["question^3", "answer"] # Boost the impact of "question" property by 3 +) + +for o in response.objects: + print(o.properties) +# END selectAndBoostExample + + +# START adjustAlpha +questions = client.collections.use("JeopardyQuestion") + +response = questions.query.hybrid( + "imaging", + alpha=0.1, # Mostly a vector search (Try it with alpha=0.9) + limit=5 +) + +for o in response.objects: + print(o.properties) +# END adjustAlpha + + +# START changeFusionType +questions = client.collections.use("JeopardyQuestion") + +response = questions.query.hybrid( + "imaging", + fusion_type=wvc.query.HybridFusion.RELATIVE_SCORE, # Use relative score fusion + limit=5 +) + +for o in response.objects: + print(o.properties) +# END changeFusionType diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/index.mdx new file mode 100644 index 000000000..c47a4547d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/standalone/which_search/index.mdx @@ -0,0 +1,53 @@ +--- +title: 自分に最適な検索方法はどれ? +description: さまざまな Weaviate の検索手法を比較し、プロジェクトに最適な方法を選択します。 +sidebar_position: 10 +--- + +## ユニット概要 + + + + + + + +Weaviate では、 **ベクトル** ・ **キーワード** ・ **ハイブリッド** の 3 種類の検索手法を提供しています。 + +それぞれの方法には固有の強みと適用範囲があり、どれを選択するかは検索関連タスクの成否を左右します。 + +本セクションでは、これらの検索タイプを比較し、いつ・なぜ各検索手法を使うべきかを直感的に判断できるようになるための知識を提供します。 + +検索タイプの選択が検索結果の品質だけでなく、検索処理全体のパフォーマンスにもどのように影響するかを検討します。 + +さらに、検索結果の品質と検索処理のパフォーマンスを向上させるための戦略についても解説します。 + + +### 前提条件 + +- `weaviate-client` がインストールされた Python ( 3 ) 環境。 +- Weaviate の検索機能に関する知識。 +- 中級程度のコーディングスキル ( 例: Python )。 +- (推奨) [クエリ 1](../../zero_to_mvp/102_queries_1/index.mdx) と [クエリ 2](../../zero_to_mvp/104_queries_2/index.mdx) を完了していること。 + + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## Questions and feedback + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/10_client.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/10_client.mdx new file mode 100644 index 000000000..25a3abf85 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/10_client.mdx @@ -0,0 +1,36 @@ +--- +title: Weaviate Python クライアント +description: Weaviate におけるカスタム ベクトル 用クライアント設定 +--- + +## インストール + +最新の Weaviate Python client ライブラリは pip を使用してインストールできます。クライアントライブラリは Python 3.8 以降でテストされています。以下のコマンドでインストールします: + +```bash +pip install -U weaviate-client +``` + +最新のメジャーバージョンは `v4` です (例: `4.x.x`)。以下のようにバージョンを確認できます: + +```bash +pip show weaviate-client +``` + +## 基本的な使い方 + +Python から Weaviate client ライブラリを次のように読み込みます: + +```python +import weaviate +``` + +client には、Weaviate との連携を容易にする補助クラス (`weaviate.classes` など) や関数が用意されています。 + +次に、Weaviate インスタンスを作成して接続する方法を示します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/10_create_wcs.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/10_create_wcs.mdx new file mode 100644 index 000000000..5b7fa8f05 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/10_create_wcs.mdx @@ -0,0 +1,67 @@ +--- +title: "オプション 1: Weaviate Cloud (WCD) インスタンス" +description: "カスタム ベクトル用の Weaviate Cloud インスタンスの作成" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../../_snippets/101_connect.py'; + +ここでは、Weaviate Cloud ( WCD ) インスタンスを作成します。WCD はクラウド上で稼働する完全マネージド型の Weaviate インスタンスです。インストールやメンテナンスが不要なため、Weaviate を始めるのに最適な方法です。 + +### WCD コンソールにログインする + +[WCD コンソール](https://console.weaviate.cloud/) にアクセスし、認証情報でログインします。まだアカウントをお持ちでない場合は、ログイン画面の Register here リンクから登録できます。 + +### Weaviate インスタンスを作成する + +コンソールで Dashboard に移動し、Create cluster ボタンをクリックします。次の画面で以下を設定してください。 + +- 「Free sandbox」タブを選択 +- クラスター名を入力 +- 「Enable authentication」を「Yes」に設定 + +Create ボタンをクリックすると、Weaviate インスタンスが作成されます。完了まで数分かかります。 + +### Weaviate インスタンスの詳細を取得する + +インスタンスが作成されると、Details ボタンをクリックして詳細を確認できます。クラスター URL と API キーを確認してください。 + +これらの情報は Weaviate インスタンスへ接続する際に必要です。 + +### WCD インスタンスへ接続する + +Weaviate Cloud ( WCD ) インスタンスへ接続するには、クラスター URL と API キーが必要です。これらは WCD コンソールで確認できます。 + +`connect_to_weaviate_cloud` 関数を使用して WCD インスタンスへ接続します。 + + + +#### 推論 API キーを提供する + +いくつかの Weaviate モジュールは、データのベクトル化や大規模言語モデル統合のために推論 API を使用できます。これらのサービスの API キーは、インスタンス生成時に Weaviate へ渡せます。 + +このコースでは Cohere を使用するため、`headers={"X-Cohere-Api-Key": }` のように Cohere API キーを Weaviate に渡します。 + + + +:::note 次のステップ +これを完了した場合、次のページ [オプション 2: ローカル Weaviate インスタンス](./20_create_docker.mdx) をスキップし、[Weaviate との通信](../30_communicate.mdx) に進んでください。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/20_create_docker.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/20_create_docker.mdx new file mode 100644 index 000000000..6ad5d67fe --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/20_create_docker.mdx @@ -0,0 +1,90 @@ +--- +title: "オプション 2: ローカル Docker インスタンス" +description: "カスタム ベクトル 用 Weaviate Docker インスタンスの作成" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../../_snippets/101_connect.py'; + +:::note 既に Weaviate インスタンスを作成しましたか? +クラウド インスタンスを [作成済み](./10_create_wcs.mdx) の場合は、このページをスキップして、[Weaviate との通信](../30_communicate.mdx) に進んでください。 +::: + +ここでは、Docker を使用して Weaviate インスタンスを作成します。 + +### docker-compose ファイルのダウンロードと実行 + +お使いのマシンに Docker をインストールしてください。公式の [Docker インストール ガイド](https://docs.docker.com/get-docker/) に従うことを推奨します。 + +新しいディレクトリを作成し、ターミナルでそのディレクトリに移動します。次に、`docker-compose.yml` という新しいファイルを作成し、以下の内容を追加します。 + +```yaml +--- +services: + weaviate_anon: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_API_BASED_MODULES: 'true' + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node1' +... + +``` + +### Weaviate インスタンスの作成 + +次のコマンドを実行して Weaviate を起動します。 + +```bash +docker compose up +``` + +### Weaviate インスタンス情報の取得 + +インスタンスが作成されると、`http://localhost:8080` でアクセスできます。 + +### Weaviate インスタンスへ接続 + +Weaviate インスタンスへ接続するには、`connect_to_local` 関数を使用します。 + + + +#### 推論 API キーの指定 + +一部の Weaviate モジュールはデータのベクトル化や大規模言語モデル統合のために推論 API を利用できます。これらのサービスの API キーは、インスタンス作成時に Weaviate へ渡すことができます。 + +このコースでは Cohere を使用するため、以下のように `headers={"X-Cohere-Api-Key": }` を通じて Cohere API キーを Weaviate に渡します。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/index.mdx new file mode 100644 index 000000000..3643293ee --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/20_create_instance/index.mdx @@ -0,0 +1,19 @@ +--- +title: Weaviate インスタンスの作成 +description: Weaviate でカスタムベクトルインスタンスを作成する +--- + +このユニットでは、 Weaviate Cloud (WCD) インスタンスを作成するか、ローカル Docker インスタンスを作成するかを選択できます。 + +- [Weaviate Cloud (WCD) インスタンスを作成する](./10_create_wcs.mdx) + - マネージドサービスを利用し、インストールやメンテナンスを気にしたくない場合におすすめです。 +- [ローカル Docker インスタンスを作成する](./20_create_docker.mdx) + - ローカルマシンで Weaviate を実行したい場合、またはインストールとメンテナンスを完全に制御したい場合におすすめです。 + +どちらのオプションでもこのコースを進めることはできます。どちらにするか迷った場合は、まず WCD インスタンスから始めることをおすすめします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/30_communicate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/30_communicate.mdx new file mode 100644 index 000000000..ea3cdfb4c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/30_communicate.mdx @@ -0,0 +1,65 @@ +--- +title: Weaviate との通信 +description: Weaviate におけるカスタム ベクトルの通信設定 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/101_connect.py'; + +ここでは、Python クライアント ライブラリを使用して Weaviate と通信する基本操作を行います。 + +### Weaviate のステータス確認 + +`is_live` 関数を使用して、Weaviate インスタンスが起動しているかどうかを確認できます。 + + + +### サーバー メタ情報の取得 + +`meta` 関数を使用して、Weaviate インスタンスのメタ情報を取得できます。 + + + +これにより、サーバーのメタ情報がコンソールに出力されます。出力例は次のとおりです。 + +
+ get_meta 出力 + + +
+ +### 接続の終了 + +Weaviate クライアントの使用が終わったら、接続を閉じる必要があります。これによりリソースが解放され、接続が適切に終了します。 + +ベストプラクティスとして `try`-`finally` ブロックの使用を推奨します。簡潔さのため、残りのコード スニペットには `try`-`finally` ブロックを含めません。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/index.mdx new file mode 100644 index 000000000..1081259b1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/101_setup_weaviate/index.mdx @@ -0,0 +1,24 @@ +--- +title: Weaviate のセットアップ +description: カスタム ベクトル を使用して Weaviate をセットアップするためのステップバイステップ ガイド。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/10_preparation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/10_preparation.mdx new file mode 100644 index 000000000..08e914096 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/10_preparation.mdx @@ -0,0 +1,36 @@ +--- +title: 準備 +--- + +このセクションでは、映画データセットと Weaviate 外部で生成された対応する ベクトル を Weaviate インスタンスに取り込む方法を説明します。 + +### Weaviate インスタンス + +Weaviate インスタンスがセットアップされていることを確認してください。すでに [インスタンスを作成](../101_setup_weaviate/20_create_instance/index.mdx) し、接続できる状態になっているはずです。 + + + +### ソースデータ + +今回は [TMDB](https://www.themoviedb.org/) から取得した映画データセットを使用します。データセットはこの [GitHub リポジトリ](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json) にあり、 1990 年から 2024 年に公開された約 700 本の映画に関する書誌情報が含まれています。 + +
+ サンプルデータを見る + +| | backdrop_path | genre_ids | id | original_language | original_title | overview | popularity | poster_path | release_date | title | video | vote_average | vote_count | +|---:|:---------------------------------|:----------------|-----:|:--------------------|:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------:|:---------------------------------|:---------------|:----------------------------|:--------|---------------:|-------------:| +| 0 | /3Nn5BOM1EVw1IYrv6MsbOS6N1Ol.jpg | [14, 18, 10749] | 162 | en | Edward Scissorhands | A small suburban town receives a visit from a castaway unfinished science experiment named Edward. | 45.694 | /1RFIbuW9Z3eN9Oxw2KaQG5DfLmD.jpg | 1990-12-07 | Edward Scissorhands | False | 7.7 | 12305 | +| 1 | /sw7mordbZxgITU877yTpZCud90M.jpg | [18, 80] | 769 | en | GoodFellas | The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway. | 57.228 | /aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg | 1990-09-12 | GoodFellas | False | 8.5 | 12106 | +| 2 | /6uLhSLXzB1ooJ3522ydrBZ2Hh0W.jpg | [35, 10751] | 771 | en | Home Alone | Eight-year-old Kevin McCallister makes the most of the situation after his family unwittingly leaves him behind when they go on Christmas vacation. But when a pair of bungling burglars set their sights on Kevin's house, the plucky kid stands ready to defend his territory. By planting booby traps galore, adorably mischievous Kevin stands his ground as his frantic mother attempts to race home before Christmas Day. | 3.538 | /onTSipZ8R3bliBdKfPtsDuHTdlL.jpg | 1990-11-16 | Home Alone | False | 7.4 | 10599 | +| 3 | /vKp3NvqBkcjHkCHSGi6EbcP7g4J.jpg | [12, 35, 878] | 196 | en | Back to the Future Part III | The final installment of the Back to the Future trilogy finds Marty digging the trusty DeLorean out of a mineshaft and looking for Doc in the Wild West of 1885. But when their time machine breaks down, the travelers are stranded in a land of spurs. More problems arise when Doc falls for pretty schoolteacher Clara Clayton, and Marty tangles with Buford Tannen. | 28.896 | /crzoVQnMzIrRfHtQw0tLBirNfVg.jpg | 1990-05-25 | Back to the Future Part III | False | 7.5 | 9918 | +| 4 | /3tuWpnCTe14zZZPt6sI1W9ByOXx.jpg | [35, 10749] | 114 | en | Pretty Woman | When a millionaire wheeler-dealer enters a business contract with a Hollywood hooker Vivian Ward, he loses his heart in the bargain. | 97.953 | /hVHUfT801LQATGd26VPzhorIYza.jpg | 1990-03-23 | Pretty Woman | False | 7.5 | 7671 | + +
+ +次に、対応するオブジェクトコレクションを作成し、データをインポートします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/20_create_collection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/20_create_collection.mdx new file mode 100644 index 000000000..9c52626a0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/20_create_collection.mdx @@ -0,0 +1,85 @@ +--- +title: コレクションの作成 +description: カスタム ベクトルでのオブジェクト コレクションの作成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + + Weaviate はデータを「コレクション」に保存します。コレクションとは、同じデータ構造を共有するオブジェクトの集合です。映画データベースでは、映画のコレクション、俳優のコレクション、レビューのコレクションを持つことができます。 + +ここでは映画のコレクションを作成します。 + +## コード + +この例では、映画データ用のコレクションを作成します。 + + + +各コレクション定義には名前が必要です。そのうえで、この例のように追加パラメーターを定義できます。 + +## コードの説明 + +### プロパティ + +プロパティは、コレクションに保存したいオブジェクト属性です。各プロパティには名前とデータ型があります。 + +映画データベースでは、`title`、`release_date`、`genre_ids` などのプロパティがあり、データ型として `TEXT` (文字列)、`DATE` (日付)、`INT` (整数) などを使用します。`genre_ids` のように整数の配列を持つことも可能です。 + +#### 自動スキーマ + + Weaviate はデータから自動的に[スキーマを推論する](/weaviate/config-refs/collections.mdx#auto-schema)ことができます。ただし、より細かく制御し予期しない動作を防ぐために、プロパティを明示的に定義することを推奨します。 + +### ベクトライザー設定 + +このコード例では、独自のベクトルを指定するため、ベクトライザーを `none` としています。 + + + +### 生成設定 + +コレクションを生成モデル (たとえば大規模言語モデル) と一緒に使用する場合は、生成モジュールを指定する必要があります。 + +このコード例では、デフォルトオプションで `cohere` モジュール (正式名称は `generative-cohere`) を指定しています。 + + + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +### Python クラス + +コード例では `Property`、`DataType`、`Configure` などのクラスを使用しています。これらは `weaviate.classes.config` サブモジュールで定義されており、コレクションを定義するために利用されます。 + +利便性のため、サブモジュールを `wc` としてインポートし、そのクラスを使用しています。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/25_generate_vectors.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/25_generate_vectors.mdx new file mode 100644 index 000000000..a98247a0f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/25_generate_vectors.mdx @@ -0,0 +1,70 @@ +--- +title: (ボーナス) ベクトルを生成する +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +カスタム ベクトル を使用しているため、自分で生成する必要があります。 + +この手順は任意です。次のセクションでは、あらかじめ生成された ベクトル をダウンロードして使用する方法を説明します。ベクトル の生成方法に興味がある場合は、引き続きお読みください。 + +### コード + +次の例では、映画データセットの埋め込みを生成します。 + + + +これにより、データセット内の各映画に対して ベクトル が生成され、映画を Weaviate に追加するときに利用できます。 + +## コードの解説 + +### モデル + +ベクトル 埋め込みの生成には `embed-multilingual-v3.0` Cohere モデルを使用します。ローカルで生成したい場合は `transformers` ライブラリを使用することも可能です。 + +### ソース テキスト + +映画のタイトルと概要を結合して、モデル用のソース文字列を作成します。モデルはこのテキストを「翻訳」して ベクトル に変換します。 + + + +### バッチで埋め込みを取得する + +連結した文字列をバッファに保存し、バッチで埋め込みを取得します。これにより、モデルへのリクエスト回数を抑え、タイムアウトを防げます。 + + + +### 埋め込みをエクスポートする + +生成した埋め込みをファイルに保存し、映画を Weaviate に追加する際に利用できるようにします。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/30_import_data.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/30_import_data.mdx new file mode 100644 index 000000000..ddb7bd26c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/30_import_data.mdx @@ -0,0 +1,94 @@ +--- +title: データのインポート +description: カスタム ベクトル オブジェクト コレクションへのデータ インポート +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +## コード + +この例では、映画データをコレクションへインポートします。 + + + +コードの概要: +- ソース データを読み込み、コレクションを取得 +- バッチャー (`batch`) オブジェクトを使ったコンテキスト マネージャーに入る +- データをループし、オブジェクトと対応するベクトルをバッチャーへ追加 +- インポート エラーを出力 + +## コードの解説 + +### 準備 + +requests ライブラリを使用して、今回の例では JSON ファイルからデータを読み込みます。その後、操作しやすいように Pandas DataFrame へ変換します。 + +次に、`client.collections.get` でコレクション オブジェクトを作成し、コレクションと対話できるようにします。 + +### バッチ コンテキスト マネージャー + +`batch` オブジェクトはコンテキスト マネージャーで、オブジェクトをバッチャーへ追加できます。大量のデータをインポートする際、バッチ サイズの管理や送信タイミングの複雑さを抽象化してくれるため便利です。 + + + +この例では `.fixed_size()` メソッドを使用して、バッチあたりのオブジェクト数を設定しています。他にも、1 分あたりのオブジェクト数を指定する `.rate_limit()` や、インポート中に自動でバッチ サイズを決定・更新する `.dynamic()` などのバッチャー タイプがあります。 + +### データをバッチャーへ追加 + +#### データ型の変換 + +Weaviate 用の正しいデータ型へ変換します。たとえば、`release_date` は datetime オブジェクトに、`genre_ids` は整数のリストに変換します。 + + + +#### オブジェクトをバッチャーへ追加 + +次にデータをループし、各オブジェクトをバッチャーへ追加します。`batch.add_object` メソッドでオブジェクトを追加すると、指定したバッチャー タイプに従ってバッチが送信されます。 + +ここではベクトル データも併せて渡している点に注意してください。 + + + +### エラー処理 + +1 つのバッチには複数のオブジェクトが含まれるため、インポートに失敗するオブジェクトが発生する可能性があります。バッチャーはこれらのエラーを保存します。 + +エラーを出力して問題を確認し、例外を投げるなどの対応を行うことができます。この例では単にエラーを出力しています。 + + + +新しいコンテキスト マネージャーに入るとエラー リストはクリアされるため、新しいバッチャーを初期化する前にエラーを処理する必要があります。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/index.mdx new file mode 100644 index 000000000..f6679b20f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/102_object_collections/index.mdx @@ -0,0 +1,24 @@ +--- +title: データベースへの投入 +description: Weaviate でカスタムオブジェクトコレクションをシームレスに管理します。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/10_vector.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/10_vector.mdx new file mode 100644 index 000000000..803855f02 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/10_vector.mdx @@ -0,0 +1,76 @@ +--- +title: ベクトル検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_10_vector.py'; + +このシナリオでは、データオブジェクトと独自の ベクトル を追加しています。そのため、類似度検索には ベクトル の入力も必要になります。これは `near vector` クエリで実行できます。 + +### コード + +この例では、入力 ベクトル との類似度に基づいて "Movie" からエントリーを検索し、上位 5 件のタイトルと公開年を表示します。 + + + +## コードの解説 + +結果は、クエリとデータベースオブジェクトのテキスト間の ベクトル 埋め込みの類似度に基づいています。この例では、埋め込みはクエリ内で手動入力しています。 + +`limit` パラメーターは、返す結果の最大件数を設定します。 + +`return_metadata` パラメーターには `MetadataQuery` クラスのインスタンスを渡し、検索結果に含めるメタデータを指定します。現在のクエリでは、クエリとの ベクトル 距離を返します。 + +
+ 例: 実行結果 + +```text +In Time 2011 +Distance to query: 0.179 + +Gattaca 1997 +Distance to query: 0.180 + +I, Robot 2004 +Distance to query: 0.182 + +Mad Max: Fury Road 2015 +Distance to query: 0.190 + +The Maze Runner 2014 +Distance to query: 0.193 +``` + +
+ +### レスポンスオブジェクト + +返されるオブジェクトはカスタムクラスのインスタンスです。その `objects` 属性は検索結果のリストで、各要素は別のカスタムクラスのインスタンスです。 + +各オブジェクトは以下を満たします。 +- Blob データ型を除き、すべてのプロパティと UUID をデフォルトで含みます。 +- 参照、メタデータ、ベクトル など、それ以外の情報はデフォルトでは含みません。 + +### クエリ ベクトルの取得方法 + +この例のクエリ ベクトル は、[データ取り込み](../102_object_collections/25_generate_vectors.mdx) で取得した方法と同様に得られます。唯一の違いは、ベクトル をデータベースに保存せず、クエリで直接使用する点です。 + + + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/20_keyword_hybrid.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/20_keyword_hybrid.mdx new file mode 100644 index 000000000..10ca41ac5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/20_keyword_hybrid.mdx @@ -0,0 +1,107 @@ +--- +title: キーワード & ハイブリッド検索 +description: オブジェクトコレクションにおけるハイブリッドキーワード検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_20_searches.py'; + +キーワードの類似度に基づいてアイテムを検索するキーワード ( BM25 ) 検索、または BM25 とセマンティック / ベクトル検索を組み合わせたハイブリッド検索も実行できます。 + +## キーワード検索 + +### コード + +この例では、"Movie" コレクション内から "history" という用語に対して最も高いキーワード検索スコアを持つエントリーを取得し、上位 5 件のタイトルと公開年を出力します。 + + + +### コードの解説 + +結果は、いわゆる [BM25f](https://en.wikipedia.org/wiki/Okapi_BM25) アルゴリズムを使用したキーワード検索スコアに基づいています。 + +`limit` パラメーターは、返却する最大件数を設定します。 + +`return_metadata` パラメーターには `MetadataQuery` クラスのインスタンスを渡し、検索結果で返却するメタデータを指定します。現在のクエリでは BM25 スコアである `score` を返却しています。 + +
+ 例: 結果 + +```text +American History X 1998 +BM25 score: 2.707 + +A Beautiful Mind 2001 +BM25 score: 1.896 + +Legends of the Fall 1994 +BM25 score: 1.663 + +Hacksaw Ridge 2016 +BM25 score: 1.554 + +Night at the Museum 2006 +BM25 score: 1.529 +``` + +
+ + +## ハイブリッド検索 + +### コード + +この例では、"Movie" コレクション内から "history" という用語に対して最も高いハイブリッド検索スコアを持つエントリーを取得し、上位 5 件のタイトルと公開年を出力します。 + + + +### コードの解説 + +結果はハイブリッド検索スコアに基づいています。ハイブリッド検索は BM25 とセマンティック / ベクトル検索の結果をブレンドします。 + +カスタムベクトルを使用しているため、`vector` パラメーターを使ってベクトルを手動でハイブリッドクエリに渡します。 + +`limit` パラメーターは、返却する最大件数を設定します。 + +`return_metadata` パラメーターには `MetadataQuery` クラスのインスタンスを渡し、検索結果で返却するメタデータを指定します。現在のクエリではハイブリッドスコアである `score` を返却しています。 + +
+ 例: 結果 + +```text +Night at the Museum 2006 +Hybrid score: 0.016 + +The Butterfly Effect 2004 +Hybrid score: 0.014 + +Legends of the Fall 1994 +Hybrid score: 0.014 + +Hidden Figures 2016 +Hybrid score: 0.012 + +A Beautiful Mind 2001 +Hybrid score: 0.012 +``` + +
+ + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/30_filters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/30_filters.mdx new file mode 100644 index 000000000..40fe40fc3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/30_filters.mdx @@ -0,0 +1,55 @@ +--- +title: フィルター +description: オブジェクト検索用フィルター +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_20_searches.py'; + +フィルターを使用すると、検索結果をより正確に絞り込むことができます。プロパティだけでなくメタデータによるフィルタリングも可能で、`and` や `or` 条件を組み合わせてさらに結果を絞り込めます。 + +### Code + +この例では、クエリ ベクトル との類似度に基づいて「Movie」を検索し、 2010 年以降に公開されたもののみを対象とします。上位 5 件のタイトルと公開年を出力します。 + + + +## コードの説明 + +このクエリは、ベクトル検索用に以前示した [サンプル](./10_vector.mdx) と同じですが、フィルターが追加されています。ここでの `filters` パラメーターには、`Filter` クラスのインスタンスを渡してフィルター条件を指定します。今回のクエリでは、公開年が 2010 年より後のものだけに結果を制限しています。 + +
+ 結果例 + +```text +Oppenheimer 2023 +Distance to query: 0.754 + +Everything Everywhere All at Once 2022 +Distance to query: 0.778 + +Meg 2: The Trench 2023 +Distance to query: 0.779 + +Eternals 2021 +Distance to query: 0.787 + +John Wick: Chapter 4 2023 +Distance to query: 0.790 +``` + +
+ + +## ご質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/index.mdx new file mode 100644 index 000000000..31ca5c5af --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/103_object_searches/index.mdx @@ -0,0 +1,24 @@ +--- +title: 検索の実行 +description: Weaviate でカスタム ベクトル を使用してオブジェクト ベースの検索を最適化します。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/10_setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/10_setup.mdx new file mode 100644 index 000000000..49a6add5f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/10_setup.mdx @@ -0,0 +1,40 @@ +--- +title: "RAG:概要" +description: "Object RAG のセットアップ" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +### 目的 + +検索拡張生成 ( RAG ) は、セマンティック検索の検索能力と、大規模言語モデルなどの AI モデルの生成能力という、両者の長所を組み合わせる方法です。これにより、 Weaviate インスタンスからオブジェクトを取得し、その取得したオブジェクトをもとに出力を生成できます。 + +### セットアップ + +コレクションを作成するときに、以下のように `generative_module` パラメーターを指定しました。 + + + +これにより、取得したオブジェクトをもとに出力を生成するための生成モジュールが選択されます。この例では `cohere` モジュールと `Command-R` ファミリーの大規模言語モデルを使用しています。 + +ベクトライザー モジュールのときと同様に、生成モジュールのプロバイダーから API キーが必要です。この場合は Cohere から取得した API キーが必要になります。 + +### RAG クエリ + +RAG クエリは、 Weaviate では「生成クエリ」とも呼ばれます。これらの機能には、コレクション オブジェクトの `generate` サブモジュールを通じてアクセスできます。 + +生成クエリは通常の検索クエリに加えて実行され、取得された各オブジェクトに対して RAG クエリを実行します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/20_single_prompt.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/20_single_prompt.mdx new file mode 100644 index 000000000..cb28035aa --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/20_single_prompt.mdx @@ -0,0 +1,57 @@ +--- +title: "'Single prompt' 生成" +description: Object RAG におけるシングルプロンプト +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/104_rag.py'; + +'シングルプロンプト'生成では、取得した各オブジェクトに対して RAG クエリが実行されます。同じプロンプトで各オブジェクトを個別に変換したい場合に便利です。 + +### コード + +この例では、入力 ベクトル に類似する「Movie」クラスのエントリを検索します。その後、大規模言語モデルに各映画のタイトルをフランス語へ翻訳するよう指示します。 + +それぞれの結果はコンソールに出力されます。 + + + +## コード解説 + +`single_prompt` パラメーターには、波かっこを使って 1 つ以上のプロパティを渡す必要があります。ここでは `"... {title} ..."` のように記述しています。これにより、取得した各オブジェクトの `title` プロパティが Weaviate から大規模言語モデルへ渡されます。 + +
+ 結果例 + +```text +In Time +À temps +Gattaca +Gattaca +I, Robot +Je, Robot +Mad Max: Fury Road +Mad Max: Fury Road +The Maze Runner +Le Labyrinthe +``` + +
+ +### レスポンス オブジェクト + +各レスポンス オブジェクトは通常の検索クエリの応答とほぼ同じですが、`generated` 属性が追加されています。この属性には、各オブジェクトに対して生成された結果が格納されます。 + + +## ご質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/30_grouped_task.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/30_grouped_task.mdx new file mode 100644 index 000000000..032e92682 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/30_grouped_task.mdx @@ -0,0 +1,61 @@ +--- +title: "「Grouped task」生成" +description: "RAG 向け Grouped Task 設定" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/104_rag.py'; + +「Grouped task」生成では、取得したオブジェクトの集合に対して RAG クエリを実行します。これにより、1 つのプロンプトでオブジェクト全体をまとめて変換したい場合に便利です。 + +### コード + +この例では、入力ベクトルとの類似度に基づいて「Movie」内のエントリーを検索します。その後、大規模言語モデルに対し、取得したエントリー間の共通点を見つけるよう指示します。 + +生成されたテキストと、それぞれの検索結果がコンソールに出力されます。 + + + +## コードの解説 + +`grouped_task` クエリでは、プロンプトを `grouped_task` パラメーターにそのまま渡すだけです。これにより Weaviate は + +- 取得したすべてのオブジェクトのテキストプロパティ +- プロンプト + +を大規模言語モデルに渡します。 + +
+ Example results + +```text +In Time +Gattaca +I, Robot +Mad Max: Fury Road +The Maze Runner +These movies all take place in a futuristic or dystopian society where the characters must navigate complex systems and face challenges related to technology, society, and survival. They all explore themes of control, power, and the consequences of scientific advancements on humanity. +``` + +
+ +### オプションパラメーター + +使用するプロパティのリストを `grouped_properties` パラメーターとして渡すこともできます。これにより、大規模言語モデルに渡すデータ量を削減し、不要なプロパティを省くのに役立ちます。 + +### レスポンスオブジェクト + +`grouped_task` パラメーター付きの RAG クエリは、`generated` という追加属性を持つレスポンスを返します。この属性にはオブジェクト集合に対して生成された出力が含まれます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/index.mdx new file mode 100644 index 000000000..b2d960bb6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/104_object_rag/index.mdx @@ -0,0 +1,24 @@ +--- +title: LLM と Weaviate (RAG) +description: Weaviate での RAG ワークフローにおけるカスタム ベクトル の扱い方を学びます。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/900_next_steps.mdx new file mode 100644 index 000000000..b14a6109f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/900_next_steps.mdx @@ -0,0 +1,7 @@ +--- +title: 次のステップ +--- + +import IntroNextSteps from '../_snippets/intro_next_steps.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/101_connect.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/101_connect.py new file mode 100644 index 000000000..4db54d000 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/101_connect.py @@ -0,0 +1,159 @@ +# WCDInstantiation +import weaviate +from weaviate.classes.init import Auth +import os + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key +) +# END WCDInstantiation + +client.close() + +# WCDAPIKeyInstantiation +import weaviate +from weaviate.classes.init import Auth +import os + +headers = { + "X-Cohere-Api-Key": os.getenv("COHERE_APIKEY") +} # Replace with your Cohere API key + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) +# END WCDAPIKeyInstantiation + +client.close() + +# DockerInstantiation +import weaviate + +client = weaviate.connect_to_local() +# END DockerInstantiation + +# DockerAPIKeyInstantiation +import weaviate +import os + +headers = { + "X-Cohere-Api-Key": os.getenv("COHERE_APIKEY") +} # Replace with your Cohere API key + +client = weaviate.connect_to_local(headers=headers) +# END DockerAPIKeyInstantiation + + +# PollLiveness +assert client.is_live() # This will raise an exception if the client is not live +# END PollLiveness + + +# GetMeta +import json + +metainfo = client.get_meta() +print(json.dumps(metainfo, indent=2)) # Print the meta information in a readable format +# END GetMeta + + +""" +# OutputGetMeta +{ + "hostname": "http://[::]:8080", + "modules": { + "backup-gcs": { + "bucketName": "weaviate-wcs-prod-cust-europe-west2-workloads-backups", + "rootName": "8616b69e-f8d2-4547-ad92-70b9557591c0" + }, + "generative-aws": { + "documentationHref": "https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html", + "name": "Generative Search - AWS" + }, + "generative-cohere": { + "documentationHref": "https://docs.cohere.com/reference/generate", + "name": "Generative Search - Cohere" + }, + "generative-openai": { + "documentationHref": "https://platform.openai.com/docs/api-reference/completions", + "name": "Generative Search - OpenAI" + }, + "generative-palm": { + "documentationHref": "https://cloud.google.com/vertex-ai/docs/generative-ai/chat/test-chat-prompts", + "name": "Generative Search - Google PaLM" + }, + "qna-openai": { + "documentationHref": "https://platform.openai.com/docs/api-reference/completions", + "name": "OpenAI Question & Answering Module" + }, + "ref2vec-centroid": {}, + "reranker-cohere": { + "documentationHref": "https://txt.cohere.com/rerank/", + "name": "Reranker - Cohere" + }, + "text2vec-aws": { + "documentationHref": "https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings", + "name": "AWS Module" + }, + "text2vec-cohere": { + "documentationHref": "https://docs.cohere.ai/embedding-wiki/", + "name": "Cohere Module" + }, + "text2vec-huggingface": { + "documentationHref": "https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task", + "name": "Hugging Face Module" + }, + "text2vec-jinaai": { + "documentationHref": "https://jina.ai/embeddings/", + "name": "JinaAI Module" + }, + "text2vec-openai": { + "documentationHref": "https://platform.openai.com/docs/guides/embeddings/what-are-embeddings", + "name": "OpenAI Module" + }, + "text2vec-palm": { + "documentationHref": "https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings", + "name": "Google PaLM Module" + } + }, + "version": "1.23.8" +} +# END OutputGetMeta +""" + + +client.close() + + +# TryFinallyCloseDemo +import weaviate +from weaviate.classes.init import Auth +import os + +# END TryFinallyCloseDemo +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key +) +# TryFinallyCloseDemo +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local(...) + +try: + # Work with the client here - e.g.: + assert client.is_live() + pass + +finally: # This will always be executed, even if an exception is raised + client.close() # Close the connection & release resources +# END TryFinallyCloseDemo diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/102_collection.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/102_collection.py new file mode 100644 index 000000000..76b4f9b4e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/102_collection.py @@ -0,0 +1,197 @@ +# CreateMovieCollection +import weaviate +import os + +# CreateMovieCollection # SubmoduleImport +import weaviate.classes.config as wc + +# CreateMovieCollection # END SubmoduleImport + +# END CreateMovieCollection +from weaviate.classes.init import Auth + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key +) + +# CreateMovieCollection +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(..., headers=headers) or +# client = weaviate.connect_to_local(..., headers=headers) + +# END CreateMovieCollection + +# Actual instantiation + +client.collections.delete("MovieCustomVector") + +# CreateMovieCollection +client.collections.create( + name="MovieCustomVector", + properties=[ + wc.Property(name="title", data_type=wc.DataType.TEXT), + wc.Property(name="overview", data_type=wc.DataType.TEXT), + wc.Property(name="vote_average", data_type=wc.DataType.NUMBER), + wc.Property(name="genre_ids", data_type=wc.DataType.INT_ARRAY), + wc.Property(name="release_date", data_type=wc.DataType.DATE), + wc.Property(name="tmdb_id", data_type=wc.DataType.INT), + ], + # Define the vectorizer module (none, as we will add our own vectors) + vector_config=wc.Configure.Vectors.self_provided(), + # Define the generative module + generative_config=wc.Configure.Generative.cohere() + # END generativeDefinition # CreateMovieCollection +) + +client.close() +# END CreateMovieCollection + + +# See https://docs.cohere.com/reference/embed for further explanations +# ManuallyGenerateEmbeddings +import requests +import pandas as pd +import os +from typing import List +import cohere +from cohere import Client as CohereClient + +co_token = os.getenv("COHERE_APIKEY") +co = cohere.Client(co_token) + + +# Define a function to call the endpoint and obtain embeddings +def vectorize(cohere_client: CohereClient, texts: List[str]) -> List[List[float]]: + + response = cohere_client.embed( + texts=texts, model="embed-multilingual-v3.0", input_type="search_document" + ) + + return response.embeddings + + +# Get the source data +data_url = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json" +resp = requests.get(data_url) +df = pd.DataFrame(resp.json()) + +# Loop through the dataset to generate vectors in batches +emb_dfs = list() +src_texts = list() +for i, row in enumerate(df.itertuples(index=False)): + # Concatenate text to create a source string + src_text = "Title" + row.title + "; Overview: " + row.overview + # Add to the buffer + src_texts.append(src_text) + if (len(src_texts) == 50) or (i + 1 == len(df)): # Get embeddings in batches of 50 + # Get a batch of embeddings + output = vectorize(co, src_texts) + index = list(range(i - len(src_texts) + 1, i + 1)) + emb_df = pd.DataFrame(output, index=index) + # Add the batch of embeddings to a list + emb_dfs.append(emb_df) + # Reset the buffer + src_texts = list() + + +emb_df = pd.concat(emb_dfs) # Create a combined dataset + +# Save the data as a CSV +os.makedirs("scratch", exist_ok=True) # Create a folder if it doesn't exist +emb_df.to_csv( + f"scratch/movies_data_1990_2024_embeddings.csv", + index=False, +) +# END ManuallyGenerateEmbeddings + +assert len(emb_df) == len(df) +assert type(output[0]) == list + + +# BatchImportData +import weaviate +import pandas as pd +import requests +from datetime import datetime, timezone +import json +from weaviate.util import generate_uuid5 +from tqdm import tqdm +import os + +# END BatchImportData +headers = {"X-Cohere-Api-Key": os.getenv("COHERE_APIKEY")} + +from weaviate.classes.init import Auth + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) + +# BatchImportData +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local(...) + +# END BatchImportData + +# BatchImportData +data_url = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json" +data_resp = requests.get(data_url) +df = pd.DataFrame(data_resp.json()) + +# Load the embeddings (embeddings from the previous step) +embs_path = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024_embeddings.csv" +# Or load embeddings from a local file (if you generated them earlier) +# embs_path = "scratch/movies_data_1990_2024_embeddings.csv" + +emb_df = pd.read_csv(embs_path) + +# Get the collection +movies = client.collections.use("MovieCustomVector") + +# Enter context manager +with movies.batch.fixed_size(batch_size=200) as batch: + # Loop through the data + for i, movie in enumerate(df.itertuples(index=False)): + # Convert data types + # Convert a JSON date to `datetime` and add time zone information + release_date = datetime.strptime(movie.release_date, "%Y-%m-%d").replace( + tzinfo=timezone.utc + ) + # Convert a JSON array to a list of integers + genre_ids = json.loads(movie.genre_ids) + + # Build the object payload + movie_obj = { + "title": movie.title, + "overview": movie.overview, + "vote_average": movie.vote_average, + "genre_ids": genre_ids, + "release_date": release_date, + "tmdb_id": movie.id, + } + + # Get the vector + vector = emb_df.iloc[i].to_list() + + # Add object (including vector) to batch queue + batch.add_object( + properties=movie_obj, + uuid=generate_uuid5(movie.id), + vector=vector # Add the custom vector + # references=reference_obj # You can add references here + ) + # Batcher automatically sends batches + +# Check for failed objects +if len(movies.batch.failed_objects) > 0: + print(f"Failed to import {len(movies.batch.failed_objects)} objects") + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/103_10_vector.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/103_10_vector.py new file mode 100644 index 000000000..01c0626a6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/103_10_vector.py @@ -0,0 +1,76 @@ +# MetadataSemanticSearch +import weaviate +import weaviate.classes.query as wq +import os + +# END MetadataSemanticSearch + +# MetadataSemanticSearch + +# END MetadataSemanticSearch + +from weaviate.classes.init import Auth + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key +) + +# MetadataSemanticSearch +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local(...) + +# END MetadataSemanticSearch + + +# GetQueryVector # MetadataSemanticSearch +# Define a function to call the endpoint and obtain embeddings +from typing import List +import os +import cohere +from cohere import Client as CohereClient + +co_token = os.getenv("COHERE_APIKEY") +co = cohere.Client(co_token) + + +# Define a function to call the endpoint and obtain embeddings +def vectorize(cohere_client: CohereClient, texts: List[str]) -> List[List[float]]: + + response = cohere_client.embed( + texts=texts, model="embed-multilingual-v3.0", input_type="search_document" + ) + + return response.embeddings + + +query_text = "dystopian future" +query_vector = vectorize(co, [query_text])[0] +# END GetQueryVector # END MetadataSemanticSearch + + +# MetadataSemanticSearch +# Get the collection +movies = client.collections.use("MovieCustomVector") + +# Perform query +response = movies.query.near_vector( + near_vector=query_vector, # A list of floating point numbers + limit=5, + return_metadata=wq.MetadataQuery(distance=True), +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END MetadataSemanticSearch diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/103_20_searches.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/103_20_searches.py new file mode 100644 index 000000000..a1e18ab7f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/103_20_searches.py @@ -0,0 +1,147 @@ +# START-ANY +import weaviate +import weaviate.classes.query as wq +import os + +# END-ANY + +# FilteredSemanticSearch +from datetime import datetime + +# END FilteredSemanticSearch + +# START-ANY + +# END-ANY + +from weaviate.classes.init import Auth + +headers = {"X-Cohere-Api-Key": os.getenv("COHERE_APIKEY")} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-Cohere-Api-Key": os.getenv("COHERE_APIKEY")} # Replace with your Cohere API key +# client = weaviate.connect_to_weaviate_cloud(..., headers=headers) or +# client = weaviate.connect_to_local(..., headers=headers) + +# END-ANY + + +# START-ANY +# Define a function to call the endpoint and obtain embeddings +from typing import List +import os +import cohere +from cohere import Client as CohereClient + +co_token = os.getenv("COHERE_APIKEY") +co = cohere.Client(co_token) + + +# Define a function to call the endpoint and obtain embeddings +def vectorize(cohere_client: CohereClient, texts: List[str]) -> List[List[float]]: + + response = cohere_client.embed( + texts=texts, model="embed-multilingual-v3.0", input_type="search_document" + ) + + return response.embeddings + + +# END-ANY + + +query_text = "history" +query_vector = vectorize(co, [query_text])[0] + +# MetadataBM25Search +# Get the collection +movies = client.collections.use("MovieCustomVector") + +# Perform query +response = movies.query.bm25( + query="history", limit=5, return_metadata=wq.MetadataQuery(score=True) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"BM25 score: {o.metadata.score:.3f}\n" + ) # Print the BM25 score of the object from the query + +client.close() +# END MetadataBM25Search + + +print("\n\n") + +client.connect() + +# MetadataHybridSearch +# Get the collection +movies = client.collections.use("MovieCustomVector") + +# Perform query +response = movies.query.hybrid( + query="history", # For BM25 part of the hybrid search + vector=query_vector, # For vector part of the hybrid search + limit=5, + return_metadata=wq.MetadataQuery(score=True), +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Hybrid score: {o.metadata.score:.3f}\n" + ) # Print the hybrid search score of the object from the query + +client.close() +# END MetadataHybridSearch + + +print("\n\n") + +client.connect() + +query_text = "history" +query_vector = vectorize(co, [query_text])[0] + +# FilteredSemanticSearch +# Get the collection +movies = client.collections.use("MovieCustomVector") + +# Perform query +response = movies.query.near_vector( + near_vector=query_vector, + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + # highlight-start + filters=wq.Filter.by_property("release_date").greater_than(datetime(2020, 1, 1)) + # highlight-end +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END FilteredSemanticSearch diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/104_rag.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/104_rag.py new file mode 100644 index 000000000..74cd1e824 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/_snippets/104_rag.py @@ -0,0 +1,106 @@ +# GetQueryVector +# Define a function to call the endpoint and obtain embeddings +from typing import List +import os +import cohere +from cohere import Client as CohereClient + +co_token = os.getenv("COHERE_APIKEY") +co = cohere.Client(co_token) + + +# Define a function to call the endpoint and obtain embeddings +def vectorize(cohere_client: CohereClient, texts: List[str]) -> List[List[float]]: + + response = cohere_client.embed( + texts=texts, model="embed-multilingual-v3.0", input_type="search_document" + ) + + return response.embeddings + + +# END GetQueryVector + + +# START-ANY +import os +import weaviate +import os + +# END-ANY + +from weaviate.classes.init import Auth + +headers = {"X-Cohere-Api-Key": os.getenv("COHERE_APIKEY")} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-Cohere-Api-Key": os.getenv("COHERE_APIKEY")} # Replace with your Cohere API key +# client = weaviate.connect_to_weaviate_cloud(..., headers=headers) or +# client = weaviate.connect_to_local(..., headers=headers) + +# END-ANY + +query_text = "dystopian future" +query_vector = vectorize(co, [query_text])[0] + +# SinglePromptGeneration +# Get the collection +movies = client.collections.use("MovieCustomVector") + +# Perform query +response = movies.generate.near_vector( + near_vector=query_vector, + limit=5, + # highlight-start + single_prompt="Translate this into French: {title}" + # highlight-end +) + +# Inspect the response +for o in response.objects: + # highlight-start + print(o.properties["title"]) # Print the title + # highlight-end + print(o.generated) # Print the generated text (the title, in French) + +client.close() +# END SinglePromptGeneration + + +print("\n\n") + +client.connect() + + +# GroupedTaskGeneration +# Get the collection +movies = client.collections.use("MovieCustomVector") + +# Perform query +response = movies.generate.near_vector( + near_vector=query_vector, + limit=5, + # highlight-start + grouped_task="What do these movies have in common?", + # grouped_properties=["title", "overview"] # Optional parameter; for reducing prompt length + # highlight-end +) + +# Inspect the response +for o in response.objects: + print(o.properties["title"]) # Print the title +# highlight-start +print(response.generative.text) # Print the generated text (the commonalities between them) +# highlight-end + +client.close() +# END GroupedTaskGeneration diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/index.md new file mode 100644 index 000000000..bce03a443 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_custom_vectors/index.md @@ -0,0 +1,23 @@ +--- +title: "101V 独自ベクトルの操作" +description: "Python でカスタム ベクトル を用いて Weaviate による最適化されたデータ検索を開始します。" +sidebar_position: 101 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +このプロジェクトベースのコースでは、 Weaviate と事前にベクトル化された映画データセットを使用して、あらゆるデータおよび独自の ベクトル を扱う方法を学びます。 + +オブジェクトとそれに対応する ベクトル を保存・インデックス化する方法を実践的に学びます。また、 ベクトル 検索、キーワード検索、ハイブリッド検索、およびフィルターを用いてデータを検索する方法を習得します。さらに、取得したオブジェクトに基づいて出力を生成するために、 Weaviate の 検索拡張生成 ( RAG ) 機能を活用する方法も学びます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/10_client.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/10_client.mdx new file mode 100644 index 000000000..65cce1b7c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/10_client.mdx @@ -0,0 +1,36 @@ +--- +title: Weaviate Python クライアント +description: Weaviate でのマルチモーダルデータのクライアント設定 +--- + +## インストール + +最新の Weaviate Python クライアントライブラリは pip でインストールできます。クライアントライブラリは Python 3.8 以降でテストされています。次のコマンドでインストールしてください: + +```bash +pip install -U weaviate-client +``` + +最新のメジャーバージョンは `v4` (例: `4.x.x`) です。バージョンは次のように確認できます: + +```bash +pip show weaviate-client +``` + +## 基本的な利用 + +Python から、次のように Weaviate クライアントライブラリを読み込みます: + +```python +import weaviate +``` + +このクライアントは、 Weaviate と簡単にやり取りできるよう、ヘルパークラス(例: `weaviate.classes` 内)と関数を提供しています。 + +次に、 Weaviate インスタンスを作成して接続する方法を紹介します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/20_create_docker.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/20_create_docker.mdx new file mode 100644 index 000000000..67fbf41f1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/20_create_docker.mdx @@ -0,0 +1,98 @@ +--- +title: ローカル Docker インスタンスの作成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/101_connect.py'; + +:::note クラウドインスタンスは使えますか? +マルチモーダル ベクトルの生成は現在ローカルモデルのみで可能です。そのため、本コースではローカルの Docker インスタンスの Weaviate を使用します。Weaviate の外部でベクトルを生成する場合は、クラウドインスタンスを利用できます。詳細は [Work with: your own vectors](../../starter_custom_vectors/index.md) コースをご覧ください。 +::: + +ここでは、Docker を使用して Weaviate インスタンスとマルチモーダル ベクトライザーコンテナを作成します。 + +### docker-compose ファイルのダウンロードと実行 + +お使いのマシンに Docker をインストールします。[公式 Docker インストールガイド](https://docs.docker.com/get-docker/) に従うことを推奨します。 + +新しいディレクトリを作成し、ターミナルでそのディレクトリに移動します。その後、`docker-compose.yml` という新しいファイルを作成し、次の内容を追加します。 + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + volumes: + - weaviate_data:/var/lib/weaviate + restart: on-failure:0 + environment: + CLIP_INFERENCE_API: 'http://multi2vec-clip:8080' + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'multi2vec-clip' + ENABLE_API_BASED_MODULES: 'true' + CLUSTER_HOSTNAME: 'node1' + multi2vec-clip: + image: cr.weaviate.io/semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1 + environment: + ENABLE_CUDA: '0' +volumes: + weaviate_data: +... + +``` + +### Weaviate インスタンスの作成 + +次のコマンドを実行して Weaviate を起動します。 + +```bash +docker compose up +``` + +### Weaviate インスタンスの詳細 + +インスタンスが作成されたら、`http://localhost:8080` でアクセスできます。 + +### Weaviate インスタンスへの接続 + +Weaviate インスタンスに接続するには、`connect_to_local` 関数を使用します。 + + + +#### 推論 API キーの提供 + +一部の Weaviate モジュールは、データのベクトル化や大規模言語モデル統合のために推論 API を使用できます。これらのサービスの API キーは、インスタンス作成時に Weaviate へ渡すことができます。 + +本コースでは OpenAI(検索拡張生成に使用)を利用するため、以下のように `headers={"X-OpenAI-Api-Key": }` を指定して OpenAI API キーを Weaviate に渡してください。 + + + +## 質問やフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/30_communicate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/30_communicate.mdx new file mode 100644 index 000000000..9a6701f8b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/30_communicate.mdx @@ -0,0 +1,67 @@ +--- +title: Weaviate との通信 +description: マルチモーダルデータの通信設定 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/101_connect.py'; + +ここでは、Python クライアントライブラリを使用して Weaviate と通信するための基本操作を行います。 + +### Weaviate のステータス確認 + +Weaviate インスタンスが稼働しているかどうかは `is_live` 関数で確認できます。 + + + +### サーバー メタ情報の取得 + +Weaviate インスタンスのメタ情報は `meta` 関数で取得できます。 + + + +これにより、サーバーのメタ情報がコンソールに出力されます。出力は以下のようになります。 + +
+ get_meta 出力 + +CLIP モデルの追加情報により、出力が少し長くなっています。 + + +
+ +### 接続のクローズ + +Weaviate クライアントの使用が終わったら、接続をクローズしてください。これによりリソースが解放され、接続が適切に閉じられます。 + +ベストプラクティスとして `try`-`finally` ブロックの使用を推奨します。簡潔にするため、以降のコードスニペットでは `try`-`finally` ブロックは省略します。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/index.mdx new file mode 100644 index 000000000..b44af1151 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/101_setup_weaviate/index.mdx @@ -0,0 +1,24 @@ +--- +title: Weaviate のセットアップ +description: マルチモーダル データ処理機能を備えた Weaviate のセットアップ ガイド。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/10_preparation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/10_preparation.mdx new file mode 100644 index 000000000..bbd1198dd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/10_preparation.mdx @@ -0,0 +1,36 @@ +--- +title: 準備 +--- + +このセクションでは、マルチモーダルな CLIP モデルを使用してテキストと画像データを埋め込み、映画データセットで Weaviate インスタンスを充填します。 + +### Weaviate インスタンス + +Weaviate インスタンスがセットアップされていることを確認してください。[インスタンスを作成](../101_setup_weaviate/20_create_docker.mdx) 済みで、接続できる状態である必要があります。 + +### ソースデータ + +ここでは、[ TMDB ](https://www.themoviedb.org/) から取得した映画データセットを使用します。このデータセットは [GitHub リポジトリ](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json) にあり、1990 年から 2024 年に公開された約 700 本の映画に関する書誌情報が含まれています。 + +マルチモーダルプロジェクトとして、各映画の [対応するポスター](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024_posters.zip) も同じリポジトリから使用します。 + +
+ サンプルテキストデータを表示 + +| | backdrop_path | genre_ids | id | original_language | original_title | overview | popularity | poster_path | release_date | title | video | vote_average | vote_count | +|---:|:---------------------------------|:----------------|-----:|:--------------------|:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------:|:---------------------------------|:---------------|:----------------------------|:--------|---------------:|-------------:| +| 0 | /3Nn5BOM1EVw1IYrv6MsbOS6N1Ol.jpg | [14, 18, 10749] | 162 | en | Edward Scissorhands | A small suburban town receives a visit from a castaway unfinished science experiment named Edward. | 45.694 | /1RFIbuW9Z3eN9Oxw2KaQG5DfLmD.jpg | 1990-12-07 | Edward Scissorhands | False | 7.7 | 12305 | +| 1 | /sw7mordbZxgITU877yTpZCud90M.jpg | [18, 80] | 769 | en | GoodFellas | The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway. | 57.228 | /aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg | 1990-09-12 | GoodFellas | False | 8.5 | 12106 | +| 2 | /6uLhSLXzB1ooJ3522ydrBZ2Hh0W.jpg | [35, 10751] | 771 | en | Home Alone | Eight-year-old Kevin McCallister makes the most of the situation after his family unwittingly leaves him behind when they go on Christmas vacation. But when a pair of bungling burglars set their sights on Kevin's house, the plucky kid stands ready to defend his territory. By planting booby traps galore, adorably mischievous Kevin stands his ground as his frantic mother attempts to race home before Christmas Day. | 3.538 | /onTSipZ8R3bliBdKfPtsDuHTdlL.jpg | 1990-11-16 | Home Alone | False | 7.4 | 10599 | +| 3 | /vKp3NvqBkcjHkCHSGi6EbcP7g4J.jpg | [12, 35, 878] | 196 | en | Back to the Future Part III | The final installment of the Back to the Future trilogy finds Marty digging the trusty DeLorean out of a mineshaft and looking for Doc in the Wild West of 1885. But when their time machine breaks down, the travelers are stranded in a land of spurs. More problems arise when Doc falls for pretty schoolteacher Clara Clayton, and Marty tangles with Buford Tannen. | 28.896 | /crzoVQnMzIrRfHtQw0tLBirNfVg.jpg | 1990-05-25 | Back to the Future Part III | False | 7.5 | 9918 | +| 4 | /3tuWpnCTe14zZZPt6sI1W9ByOXx.jpg | [35, 10749] | 114 | en | Pretty Woman | When a millionaire wheeler-dealer enters a business contract with a Hollywood hooker Vivian Ward, he loses his heart in the bargain. | 97.953 | /hVHUfT801LQATGd26VPzhorIYza.jpg | 1990-03-23 | Pretty Woman | False | 7.5 | 7671 | + +
+ +次に、対応するオブジェクトコレクションを作成し、データをインポートします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/20_create_collection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/20_create_collection.mdx new file mode 100644 index 000000000..14a60236e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/20_create_collection.mdx @@ -0,0 +1,91 @@ +--- +title: コレクションの作成 +description: 多モーダル データ コレクションの作成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +Weaviate はデータを「コレクション」に保存します。コレクションとは、同じデータ構造を共有するオブジェクトの集合です。映画データベースでは、映画のコレクション、俳優のコレクション、レビューのコレクションを持つことができます。 + +ここでは映画のコレクションを作成します。 + +## コード + +次の例では映画データ用のコレクションを作成しています。 + + + +各コレクション定義には名前が必要です。そのうえで、この例のように追加パラメーターを指定できます。 + +## コードの解説 + +### プロパティ + +プロパティは、コレクションに保存したいオブジェクトの属性です。各プロパティには名前とデータ型があります。 + +映画データベースでは、`title`、`release_date`、`genre_ids` などのプロパティがあり、データ型として `TEXT`(文字列)、`DATE`(日付)、`INT`(整数)などがあります。`genre_ids` のように整数の配列を持つことも可能です。 + +多モーダル オブジェクトとして、画像データである `poster` プロパティもあり、これは `BLOB`(バイナリ ラージ オブジェクト)データ型で保存されます。 + +#### 自動スキーマ + +Weaviate は [スキーマを自動推論](/weaviate/config-refs/collections.mdx#auto-schema) できます。しかし、より細かく制御し予期しない結果を避けるために、プロパティを明示的に定義することを推奨します。 + +### ベクトライザー設定 + +ベクトルを自分で指定しない場合、Weaviate は指定されたベクトライザーを使用してデータからベクトル埋め込みを生成します。 + +このコード例では `multi2vec-clip` モジュールを指定しています。このモジュールは CLIP モデルを用いてテキストと画像データからベクトル埋め込みを生成します。 + +テキストおよび画像プロパティを任意の数だけベクトル化対象として指定でき、重み付けも自由です。重みは、各プロパティがベクトル埋め込み生成においてどれだけ重要かを示します。この例では画像である `poster` プロパティを 90% の重みで、文字列である `title` プロパティを 10% の重みでベクトル化しています。 + + + +### 生成設定 + +コレクションを生成モデル(例: 大規模言語モデル)と一緒に使用したい場合は、生成モジュールを指定する必要があります。 + +このコード例では `openai` モジュール(正式名 `generative-openai`)をデフォルト設定で指定しています。 + + + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +### Python クラス + +コード例では、`Property`、`DataType`、`Configure` などのクラスを使用しています。これらは `weaviate.classes.config` サブモジュールで定義され、コレクションの定義に使用されます。 + +利便性のため、サブモジュールを `wc` としてインポートし、そのクラスを利用しています。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/30_import_data.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/30_import_data.mdx new file mode 100644 index 000000000..978e4ee7d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/30_import_data.mdx @@ -0,0 +1,111 @@ +--- +title: データのインポート +description: マルチモーダルデータコレクションへのデータインポート +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +## コード + +この例では、映画データをコレクションにインポートします。 + + + +コードの内容: +- ソースのテキストと画像データを読み込みます +- コレクションを取得します +- バッチャー( `batch` )オブジェクトを用いたコンテキストマネージャーに入ります +- データをループ処理し、次を行います: + - テキストに対応する画像を探します + - 画像を base64 に変換します + - オブジェクトをバッチャーに追加します +- インポートエラーを出力します + +## コードの説明 + +### 準備 + +まず、requests ライブラリを使用してソースからデータを読み込みます。ここではテキストデータを含む JSON ファイルとポスター画像を含む Zip ファイルです。テキストデータは Pandas DataFrame に変換して操作しやすくし、画像は Zip ファイルから展開します。 + +次に、コレクションと対話できるように `client.collections.get` を使用してコレクションオブジェクトを作成します。 + +### バッチコンテキストマネージャー + +`batch` オブジェクトはコンテキストマネージャーであり、オブジェクトをバッチャーへ追加できます。大量のデータをインポートする際に、バッチサイズの管理や送信タイミングの複雑さを抽象化できるため便利です。 + + + +この例では `.fixed_size()` メソッドを使用してバッチあたりのオブジェクト数を設定するバッチャーを作成しています。その他にも、分毎のオブジェクト数を指定する `.rate_limit()` や、インポート中に自動でバッチサイズを調整する `.dynamic()` などのバッチャータイプがあります。 + +### バッチャーへのデータ追加 + +#### データ型の変換 + +データは文字列から Weaviate に適した型へ変換されます。たとえば `release_date` は datetime オブジェクトに、`genre_ids` は整数のリストに変換します。 + + + +画像データを `BLOB` データ型として保存するため、画像を base64 に変換します。 + + + +#### オブジェクトをバッチャーに追加 + +次にデータをループ処理し、各オブジェクトをバッチャーへ追加します。`batch.add_object` メソッドでオブジェクトを追加すると、バッチャーは指定されたタイプに従ってバッチを送信します。 + + + +### エラー処理 + +バッチには複数のオブジェクトが含まれるため、一部のオブジェクトがインポートに失敗する可能性があります。バッチャーはこれらのエラーを保持します。 + +エラーを出力することで原因を確認し、例外を発生させるなどの処理を行えます。この例では、単にエラーを出力しています。 + + + +新しいコンテキストマネージャーに入るとエラーリストはクリアされるため、新しいバッチャーを初期化する前にエラー処理を行う必要があります。 + +## ベクトルの生成元 + +バッチャーがキューを Weaviate に送信すると、オブジェクトはコレクション(ここでは映画コレクション)に追加されます。 + +コレクションにはベクトライザーモジュールが設定されており、ここではベクトルを指定していません。そのため、Weaviate は指定されたベクトライザーを使用してデータからベクトル埋め込みを生成します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/index.mdx new file mode 100644 index 000000000..ff7d5ec5a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/102_mm_collections/index.mdx @@ -0,0 +1,24 @@ +--- +title: データベースへのデータ投入 +description: Weaviate でマルチモーダルコレクションを効率的に扱います。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/10_multimodal.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/10_multimodal.mdx new file mode 100644 index 000000000..9375fdf3b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/10_multimodal.mdx @@ -0,0 +1,148 @@ +--- +title: マルチモーダル検索 +description: マルチモーダル検索手法 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_searches.py'; + + Weaviate を使用すると、意味に基づいて類似アイテムを見つけるセマンティック検索を実行できます。これは、データベース内のアイテムのベクトル埋め込みを比較することで実現します。 + +マルチモーダルモデルを使用しているため、サポートされている任意のモダリティとの類似度に基づいてオブジェクトを検索できます。つまり、テキストまたは画像との類似度を基準に映画を検索できます。 + +## 画像クエリ + +### コード + +この例では、「MovieMM」のエントリを [国際宇宙ステーションのこの画像](https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/International_Space_Station_after_undocking_of_STS-132.jpg/440px-International_Space_Station_after_undocking_of_STS-132.jpg) との類似度に基づいて検索し、上位 5 件の一致のタイトルと公開年を出力します。 + +
+ クエリ画像 + +![国際宇宙ステーション](https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/International_Space_Station_after_undocking_of_STS-132.jpg/440px-International_Space_Station_after_undocking_of_STS-132.jpg) + +
+ + + +### コードの解説 + +結果は、クエリとデータベースオブジェクトのベクトル埋め込み同士の類似度に基づきます。この場合、ベクトライザー モジュールが入力画像の埋め込みを生成します。 + +`limit` パラメーターは返される結果の最大数を指定します。 + +`return_metadata` パラメーターには `MetadataQuery` クラスのインスタンスを渡し、検索結果に含めるメタデータを指定します。現在のクエリでは、クエリとのベクトル距離を返しています。 + +上位の結果はすべて宇宙をテーマにした映画であることから分かるように、出力はクエリ画像のトーンに非常によく似ています。 + +
+ 結果例 + +上位 5 件のポスター: +Interstellar +Gravity +Arrival +Armageddon +Godzilla + +Weaviate output: + +```text +Interstellar 2014 157336 +Distance to query: 0.354 + +Gravity 2013 49047 +Distance to query: 0.384 + +Arrival 2016 329865 +Distance to query: 0.386 + +Armageddon 1998 95 +Distance to query: 0.400 + +Godzilla 1998 929 +Distance to query: 0.441 +``` + +
+ +### レスポンスオブジェクト + +返されるオブジェクトはカスタムクラスのインスタンスです。`objects` 属性は検索結果のリストで、それぞれが別のカスタムクラスのインスタンスになります。 + +各オブジェクトには、以下が適用されます: +- 既定では、すべてのプロパティとその UUID が含まれますが、 blob データ型のプロパティは除外されます。 + - `poster` プロパティは blob なので、既定では含まれません。 + - `poster` プロパティを含める場合は、`return_properties` パラメーターで取得したい他のプロパティとともに指定してください。 +- 参照、メタデータ、ベクトルなど、その他の情報は既定では含まれません。 + + +## テキスト検索 + +### コード + +この例では、「MovieMM」のエントリをクエリ「red」との類似度に基づいて検索し、上位 5 件の一致のタイトルと公開年を出力します。 + + + +### コードの解説 + +結果は、クエリとデータベースオブジェクトのベクトル埋め込み同士の類似度に基づきます。この場合、ベクトライザー モジュールが入力テキストの埋め込みを生成します。 + +その他のパラメーターは前の例と同じです。 + +実際の結果には、ポスターに赤い配色が含まれる映画が表示されます。これは、 CLIP ベクトライザーが画像の色情報をベクトルにエンコードしているためです。 + +
+ 結果例 + +上位 5 件のポスター: +Deadpool 2 +Bloodshot +Deadpool +300 +The Hunt for Red October + +Weaviate output: + +```text +Deadpool 2 2018 383498 +Distance to query: 0.670 + +Bloodshot 2020 338762 +Distance to query: 0.677 + +Deadpool 2016 293660 +Distance to query: 0.678 + +300 2007 1271 +Distance to query: 0.682 + +The Hunt for Red October 1990 1669 +Distance to query: 0.683 +``` + +
+ +### レスポンスオブジェクト + +返されるオブジェクトの形式は前の例と同じです。 + + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/20_keyword_hybrid.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/20_keyword_hybrid.mdx new file mode 100644 index 000000000..2b1aea24c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/20_keyword_hybrid.mdx @@ -0,0 +1,105 @@ +--- +title: キーワード検索 & ハイブリッド検索 +description: マルチモーダルコレクションでのハイブリッドキーワード検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_searches.py'; + +キーワード( BM25 )検索を使用してキーワード類似度に基づいてアイテムを探したり、 BM25 とセマンティック/ ベクトル検索を組み合わせたハイブリッド検索を実行したりできます。 + +## キーワード検索 + +### コード + +この例では、"MovieMM" 内で "history" という語に対して最も高いキーワード検索スコアを持つエントリーを検索し、上位 5 件のタイトルと公開年を出力します。 + + + +### コードの説明 + +結果は、[BM25f](https://en.wikipedia.org/wiki/Okapi_BM25) アルゴリズムを用いたキーワード検索スコアに基づいています。 + +`limit` パラメーターは、返される結果数の上限を設定します。 + +`return_metadata` パラメーターには、検索結果で返すメタデータを設定するために `MetadataQuery` クラスのインスタンスを渡します。現在のクエリでは、結果の BM25 スコアである `score` を返します。 + +
+ 例: 結果 + +```text +American History X 1998 +BM25 score: 2.707 + +A Beautiful Mind 2001 +BM25 score: 1.896 + +Legends of the Fall 1994 +BM25 score: 1.663 + +Hacksaw Ridge 2016 +BM25 score: 1.554 + +Night at the Museum 2006 +BM25 score: 1.529 +``` + +
+ + +## ハイブリッド検索 + +### コード + +この例では、"MovieMM" 内で "history" という語に対して最も高いハイブリッド検索スコアを持つエントリーを検索し、上位 5 件のタイトルと公開年を出力します。 + + + +### コードの説明 + +結果はハイブリッド検索スコアに基づいています。ハイブリッド検索は、 BM25 とセマンティック/ ベクトル検索の結果をブレンドします。 + +`limit` パラメーターは、返される結果数の上限を設定します。 + +`return_metadata` パラメーターには、検索結果で返すメタデータを設定するために `MetadataQuery` クラスのインスタンスを渡します。現在のクエリでは、結果のハイブリッドスコアである `score` を返します。 + +
+ 例: 結果 + +```text +Legends of the Fall 1994 +Hybrid score: 0.016 + +Hacksaw Ridge 2016 +Hybrid score: 0.016 + +A Beautiful Mind 2001 +Hybrid score: 0.015 + +The Butterfly Effect 2004 +Hybrid score: 0.015 + +Night at the Museum 2006 +Hybrid score: 0.012 +``` + +
+ + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/30_filters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/30_filters.mdx new file mode 100644 index 000000000..3c0af19e9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/30_filters.mdx @@ -0,0 +1,55 @@ +--- +title: フィルター +description: マルチモーダル検索のフィルター +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_searches.py'; + +検索結果を正確に絞り込むためにフィルターを使用できます。プロパティだけでなくメタデータでもフィルタリングでき、`and` や `or` 条件で複数のフィルターを組み合わせてさらに結果を絞り込むことも可能です。 + +### コード + +この例では、クエリ「dystopian future」との類似度に基づいて「MovieMM」内のエントリーを検索し、2010 年以降に公開されたものだけから上位 5 件のタイトルと公開年を出力します。 + + + +## コードの解説 + +このクエリは検索用に前述したもの([こちら](./10_multimodal.mdx))と同じですが、フィルターが追加されています。ここでの `filters` パラメーターには、`Filter` クラスのインスタンスを渡してフィルター条件を設定します。現在のクエリでは、公開年が 2010 年より後の結果のみを取得するようにフィルタリングしています。 + +
+ 例の結果 + +```text +Dune 2021 +Distance to query: 0.199 + +Tenet 2020 +Distance to query: 0.200 + +Mission: Impossible - Dead Reckoning Part One 2023 +Distance to query: 0.207 + +Onward 2020 +Distance to query: 0.214 + +Jurassic World Dominion 2022 +Distance to query: 0.216 +``` + +
+ + +## ご質問やフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/index.mdx new file mode 100644 index 000000000..ff8c8a8c6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/103_mm_searches/index.mdx @@ -0,0 +1,24 @@ +--- +title: 検索を実行する +description: Weaviate の Python クライアントでマルチモーダル検索手法を学びます。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/10_setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/10_setup.mdx new file mode 100644 index 000000000..a0a81174c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/10_setup.mdx @@ -0,0 +1,40 @@ +--- +title: "RAG の概要" +description: "マルチモーダル RAG のセットアップ" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +### 動機 + +検索拡張生成 (Retrieval augmented generation, RAG) は、セマンティック検索の検索機能と、大規模言語モデルなどの AI モデルの生成機能という双方の長所を組み合わせる手法です。これにより、Weaviate インスタンスからオブジェクトを取得し、その結果に基づいて出力を生成できます。 + +### セットアップ + +コレクションを作成する際、次のように `generative_module` パラメーターを指定しました。 + + + +これは、取得したオブジェクトを基に出力を生成するために使用される生成モジュールを選択します。この例では `openai` モジュールと `GPT` 系列の大規模言語モデルを使用しています。 + +以前にベクトライザー モジュールを使用したときと同様に、生成モジュールのプロバイダーから API キーが必要です。この場合は OpenAI の API キーが必要になります。 + +### RAG クエリ + +RAG クエリは、Weaviate では「生成クエリ」とも呼ばれます。これらの機能には、コレクション オブジェクトの `generate` サブモジュールからアクセスできます。 + +各生成クエリは通常の検索クエリに加えて動作し、取得した各オブジェクトに対して RAG クエリを実行します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/20_single_prompt.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/20_single_prompt.mdx new file mode 100644 index 000000000..d1aaa9569 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/20_single_prompt.mdx @@ -0,0 +1,57 @@ +--- +title: "'シングル プロンプト' 生成" +description: マルチモーダル RAG 用シングル プロンプト +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/104_rag.py'; + +「シングル プロンプト」生成では、取得した各オブジェクトに対して RAG クエリを実行します。同じプロンプトで各オブジェクトを個別に変換したい場合に便利です。 + +### コード + +この例では、[国際宇宙ステーションのこの画像](https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/International_Space_Station_after_undocking_of_STS-132.jpg/440px-International_Space_Station_after_undocking_of_STS-132.jpg) に類似した 「 MovieMM 」 内のエントリーを検索します。次に、大規模言語モデルに各映画のタイトルをフランス語へ翻訳するよう指示します。 + +得られた各結果はコンソールに出力されます。 + + + +## コードの解説 + +波括弧を使って `single_prompt` パラメータに 1 つ以上のプロパティを渡す必要があります。ここでは `"... {title} ..."` として渡しています。これにより、 Weaviate は取得した各オブジェクトの `title` プロパティを大規模言語モデルへ渡します。 + +
+ 結果例 + +```text +Interstellar +Interstellaire +Gravity +Gravité +Arrival +Arrivée +Armageddon +Armageddon +Godzilla +Godzilla +``` + +
+ +### レスポンス オブジェクト + +レスポンス オブジェクトは通常の検索クエリのものとほぼ同じですが、`generated` 属性が追加されています。この属性には、各オブジェクトに対して生成された出力が格納されます。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/30_grouped_task.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/30_grouped_task.mdx new file mode 100644 index 000000000..83b673a2d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/30_grouped_task.mdx @@ -0,0 +1,58 @@ +--- +title: "「グループ化タスク」生成" +description: マルチモーダル RAG 用の Grouped Task +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/104_rag.py'; + +「グループ化タスク」生成では、取得したオブジェクトの集合に対して RAG クエリを実行します。1 つのプロンプトでオブジェクト全体を変換したい場合に便利です。 + +### コード + +この例では、「MovieMM」内から [国際宇宙ステーションの画像](https://upload.wikimedia.org/wikipedia/commons/thumb/0/04/International_Space_Station_after_undocking_of_STS-132.jpg/440px-International_Space_Station_after_undocking_of_STS-132.jpg) に類似したエントリーを検索し、その後、大規模言語モデルに各エントリー間の共通点を見つけるよう指示します。 + +各結果はコンソールに出力されます。 + + + +## コードの解説 + +`grouped_task` クエリでは、プロンプトをそのまま `grouped_task` パラメーターに渡すだけです。これにより Weaviate は以下を大規模言語モデルに渡します。 +- 取得したすべてのオブジェクトの text プロパティ +- プロンプト + +
+ 結果例 + +```text +Interstellar +Gravity +Arrival +Armageddon +Godzilla +These movies all involve space exploration, extraterrestrial beings, or catastrophic events threatening Earth. They all deal with themes of survival, human ingenuity, and the unknown mysteries of the universe. +``` + +
+ +### 追加パラメーター + +使用するプロパティのリストを `grouped_properties` パラメーターとして渡すこともできます。大規模言語モデルに渡すデータ量を減らし、不要なプロパティを省く際に便利です。 + +### レスポンスオブジェクト + +`grouped_task` パラメーターを使った RAG クエリは、追加で `generated` 属性を含むレスポンスを返します。この属性には、オブジェクト集合に対して生成された出力が格納されます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/index.mdx new file mode 100644 index 000000000..d8b7e65df --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/104_mm_rag/index.mdx @@ -0,0 +1,24 @@ +--- +title: LLMs と Weaviate (RAG) +description: マルチモーダル 検索拡張生成 (RAG) の概要 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/900_next_steps.mdx new file mode 100644 index 000000000..b14a6109f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/900_next_steps.mdx @@ -0,0 +1,7 @@ +--- +title: 次のステップ +--- + +import IntroNextSteps from '../_snippets/intro_next_steps.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/101_connect.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/101_connect.py new file mode 100644 index 000000000..273cbc573 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/101_connect.py @@ -0,0 +1,523 @@ +# DockerInstantiation +import weaviate + +client = weaviate.connect_to_local() +# END DockerInstantiation + +client.close() + +# DockerAPIKeyInstantiation +import weaviate +import os + +headers = { + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") +} # Replace with your OpenAI API key + +client = weaviate.connect_to_local(headers=headers) +# END DockerAPIKeyInstantiation + +# PollLiveness +assert client.is_live() # This will raise an exception if the client is not live +# END PollLiveness + + +# GetMeta +import json + +metainfo = client.get_meta() +print(json.dumps(metainfo, indent=2)) # Print the meta information in a readable format +# END GetMeta + + +""" +# OutputGetMeta +{ + "hostname": "http://[::]:8080", + "modules": { + "multi2vec-clip": { + "clip_model": { + "_commit_hash": null, + "_name_or_path": "/root/.cache/torch/sentence_transformers/sentence-transformers_clip-ViT-B-32/0_CLIPModel", + "add_cross_attention": false, + "architectures": [ + "CLIPModel" + ], + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "length_penalty": 1, + "logit_scale_init_value": 2.6592, + "max_length": 20, + "min_length": 0, + "model_type": "clip", + "no_repeat_ngram_size": 0, + "num_beam_groups": 1, + "num_beams": 1, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "text_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": 0, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": 2, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 512, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 2048, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "max_position_embeddings": 77, + "min_length": 0, + "model_type": "clip_text_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 8, + "num_beam_groups": 1, + "num_beams": 1, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": 1, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false, + "vocab_size": 49408 + }, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": "torch.float32", + "torchscript": false, + "transformers_version": null, + "typical_p": 1, + "use_bfloat16": false, + "vision_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 768, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "image_size": 224, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 3072, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "min_length": 0, + "model_type": "clip_vision_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 12, + "num_beam_groups": 1, + "num_beams": 1, + "num_channels": 3, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "patch_size": 32, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false + } + }, + "text_model": { + "_commit_hash": null, + "_name_or_path": "./models/text/0_CLIPModel", + "add_cross_attention": false, + "architectures": [ + "CLIPModel" + ], + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "length_penalty": 1, + "logit_scale_init_value": 2.6592, + "max_length": 20, + "min_length": 0, + "model_type": "clip", + "no_repeat_ngram_size": 0, + "num_beam_groups": 1, + "num_beams": 1, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "text_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": 0, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": 2, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 512, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 2048, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "max_position_embeddings": 77, + "min_length": 0, + "model_type": "clip_text_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 8, + "num_beam_groups": 1, + "num_beams": 1, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": 1, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false, + "vocab_size": 49408 + }, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": "torch.float32", + "torchscript": false, + "transformers_version": null, + "typical_p": 1, + "use_bfloat16": false, + "vision_config": { + "_name_or_path": "", + "add_cross_attention": false, + "architectures": null, + "attention_dropout": 0, + "bad_words_ids": null, + "begin_suppress_tokens": null, + "bos_token_id": null, + "chunk_size_feed_forward": 0, + "cross_attention_hidden_size": null, + "decoder_start_token_id": null, + "diversity_penalty": 0, + "do_sample": false, + "dropout": 0, + "early_stopping": false, + "encoder_no_repeat_ngram_size": 0, + "eos_token_id": null, + "exponential_decay_length_penalty": null, + "finetuning_task": null, + "forced_bos_token_id": null, + "forced_eos_token_id": null, + "gradient_checkpointing": false, + "hidden_act": "quick_gelu", + "hidden_size": 768, + "id2label": { + "0": "LABEL_0", + "1": "LABEL_1" + }, + "image_size": 224, + "initializer_factor": 1, + "initializer_range": 0.02, + "intermediate_size": 3072, + "is_decoder": false, + "is_encoder_decoder": false, + "label2id": { + "LABEL_0": 0, + "LABEL_1": 1 + }, + "layer_norm_eps": 1e-05, + "length_penalty": 1, + "max_length": 20, + "min_length": 0, + "model_type": "clip_vision_model", + "no_repeat_ngram_size": 0, + "num_attention_heads": 12, + "num_beam_groups": 1, + "num_beams": 1, + "num_channels": 3, + "num_hidden_layers": 12, + "num_return_sequences": 1, + "output_attentions": false, + "output_hidden_states": false, + "output_scores": false, + "pad_token_id": null, + "patch_size": 32, + "prefix": null, + "problem_type": null, + "projection_dim": 512, + "pruned_heads": {}, + "remove_invalid_values": false, + "repetition_penalty": 1, + "return_dict": true, + "return_dict_in_generate": false, + "sep_token_id": null, + "suppress_tokens": null, + "task_specific_params": null, + "temperature": 1, + "tf_legacy_loss": false, + "tie_encoder_decoder": false, + "tie_word_embeddings": true, + "tokenizer_class": null, + "top_k": 50, + "top_p": 1, + "torch_dtype": null, + "torchscript": false, + "transformers_version": "4.30.2", + "typical_p": 1, + "use_bfloat16": false + } + } + } + }, + "version": "1.23.9" +} +# END OutputGetMeta +""" + + +client.close() + + +# TryFinallyCloseDemo +import weaviate +import os + +# END TryFinallyCloseDemo + +client = weaviate.connect_to_local() + +# TryFinallyCloseDemo +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_local() + +try: + # Work with the client here - e.g.: + assert client.is_live() + pass + +finally: # This will always be executed, even if an exception is raised + client.close() # Close the connection & release resources +# END TryFinallyCloseDemo diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/102_collection.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/102_collection.py new file mode 100644 index 000000000..290fc8780 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/102_collection.py @@ -0,0 +1,146 @@ +# CreateMovieCollection +import weaviate + +# CreateMovieCollection # SubmoduleImport +import weaviate.classes.config as wc + +# CreateMovieCollection # END SubmoduleImport + +# END CreateMovieCollection +client = weaviate.connect_to_local( + port=8280, + grpc_port=50251 +) + +# CreateMovieCollection +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_local(headers=headers) + +# END CreateMovieCollection + +# Actual instantiation + +client.collections.delete("MovieMM") + +# CreateMovieCollection +client.collections.create( + name="MovieMM", # The name of the collection ('MM' for multimodal) + properties=[ + wc.Property(name="title", data_type=wc.DataType.TEXT), + wc.Property(name="overview", data_type=wc.DataType.TEXT), + wc.Property(name="vote_average", data_type=wc.DataType.NUMBER), + wc.Property(name="genre_ids", data_type=wc.DataType.INT_ARRAY), + wc.Property(name="release_date", data_type=wc.DataType.DATE), + wc.Property(name="tmdb_id", data_type=wc.DataType.INT), + wc.Property(name="poster", data_type=wc.DataType.BLOB), + ], + # Define & configure the vectorizer module + vector_config=wc.Configure.Vectors.multi2vec_clip( + image_fields=[wc.Multi2VecField(name="poster", weight=0.9)], # 90% of the vector is from the poster + text_fields=[wc.Multi2VecField(name="title", weight=0.1)], # 10% of the vector is from the title + ), + # Define the generative module + generative_config=wc.Configure.Generative.openai() + # END generativeDefinition # CreateMovieCollection +) + +client.close() +# END CreateMovieCollection + + +# BatchImportData +import weaviate +import pandas as pd +import requests +from datetime import datetime, timezone +import json +from weaviate.util import generate_uuid5 +from tqdm import tqdm +import os +import zipfile +from pathlib import Path +import base64 + +# END BatchImportData +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} +client = weaviate.connect_to_local( + port=8280, + grpc_port=50251, + headers=headers +) + +# BatchImportData +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_local() + +# END BatchImportData + +# BatchImportData +data_url = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json" +resp = requests.get(data_url) +df = pd.DataFrame(resp.json()) + +# Create a directory for the images +img_dir = Path("scratch/imgs") +img_dir.mkdir(parents=True, exist_ok=True) + +# Download images +posters_url = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024_posters.zip" +posters_path = img_dir / "movies_data_1990_2024_posters.zip" +posters_path.write_bytes(requests.get(posters_url).content) + +# Unzip the images +with zipfile.ZipFile(posters_path, 'r') as zip_ref: + zip_ref.extractall(img_dir) + +# Get the collection +movies = client.collections.use("MovieMM") + +# END BatchImportData + +df = df[:50] # Limit to 50 for testing purposes + +# BatchImportData +# Enter context manager +with movies.batch.fixed_size(50) as batch: + # Loop through the data + for i, movie in tqdm(df.iterrows()): + # Convert data types + # Convert a JSON date to `datetime` and add time zone information + release_date = datetime.strptime(movie["release_date"], "%Y-%m-%d").replace( + tzinfo=timezone.utc + ) + # Convert a JSON array to a list of integers + genre_ids = json.loads(movie["genre_ids"]) + # Convert image to base64 + img_path = (img_dir / f"{movie['id']}_poster.jpg") + with open(img_path, "rb") as file: + poster_b64 = base64.b64encode(file.read()).decode("utf-8") + + # Build the object payload + movie_obj = { + "title": movie["title"], + "overview": movie["overview"], + "vote_average": movie["vote_average"], + "genre_ids": genre_ids, + "release_date": release_date, + "tmdb_id": movie["id"], + "poster": poster_b64, + } + + # Add object to batch queue + batch.add_object( + properties=movie_obj, + uuid=generate_uuid5(movie["id"]) + # references=reference_obj # You can add references here + ) + # Batcher automatically sends batches + +# Check for failed objects +if len(movies.batch.failed_objects) > 0: + print(f"Failed to import {len(movies.batch.failed_objects)} objects") + for failed in movies.batch.failed_objects: + print(f"e.g. Failed to import object with error: {failed.message}") + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/103_searches.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/103_searches.py new file mode 100644 index 000000000..1c5884f23 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/103_searches.py @@ -0,0 +1,180 @@ +# START-ANY +import weaviate +import weaviate.classes.query as wq +import os + +# END-ANY + +# FilteredSemanticSearch +from datetime import datetime + +# END FilteredSemanticSearch + +# START-ANY + +# END-ANY + +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} +client = weaviate.connect_to_local( + port=8280, + grpc_port=50251, + headers=headers +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_local(headers=headers) + +# END-ANY + + +# MetadataMultimodalSearch + +def url_to_base64(url): + import requests + import base64 + + image_response = requests.get(url) + content = image_response.content + return base64.b64encode(content).decode("utf-8") + + +# Get the collection +movies = client.collections.use("MovieMM") + +# Perform query +src_img_path = "https://github.com/weaviate-tutorials/edu-datasets/blob/main/img/International_Space_Station_after_undocking_of_STS-132.jpg?raw=true" +query_b64 = url_to_base64(src_img_path) + +response = movies.query.near_image( + near_image=query_b64, + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + return_properties=["title", "release_date", "tmdb_id", "poster"] # To include the poster property in the response (`blob` properties are not returned by default) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year, o.properties["tmdb_id"] + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END MetadataMultimodalSearch + + +print("\n\n") + +client.connect() + + +# MetadataSemanticSearch +# Get the collection +movies = client.collections.use("MovieMM") + +# Perform query +response = movies.query.near_text( + query="red", + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + return_properties=["title", "release_date", "tmdb_id", "poster"] # To include the poster property in the response (`blob` properties are not returned by default) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year, o.properties["tmdb_id"] + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END MetadataSemanticSearch + + +print("\n\n") + +client.connect() + +# MetadataBM25Search +# Get the collection +movies = client.collections.use("MovieMM") + +# Perform query +response = movies.query.bm25( + query="history", limit=5, return_metadata=wq.MetadataQuery(score=True) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"BM25 score: {o.metadata.score:.3f}\n" + ) # Print the BM25 score of the object from the query + +client.close() +# END MetadataBM25Search + + +print("\n\n") + +client.connect() + +# MetadataHybridSearch +# Get the collection +movies = client.collections.use("MovieMM") + +# Perform query +response = movies.query.hybrid( + query="history", limit=5, return_metadata=wq.MetadataQuery(score=True) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Hybrid score: {o.metadata.score:.3f}\n" + ) # Print the hybrid search score of the object from the query + +client.close() +# END MetadataHybridSearch + + +print("\n\n") + +client.connect() + +# FilteredSemanticSearch +# Get the collection +movies = client.collections.use("MovieMM") + +# Perform query +response = movies.query.near_text( + query="dystopian future", + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + # highlight-start + filters=wq.Filter.by_property("release_date").greater_than(datetime(2020, 1, 1)) + # highlight-end +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END FilteredSemanticSearch diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/104_rag.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/104_rag.py new file mode 100644 index 000000000..68de4b4c4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/_snippets/104_rag.py @@ -0,0 +1,89 @@ +# START-ANY +import os +import weaviate +import os + +# END-ANY + +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} +client = weaviate.connect_to_local( + port=8280, + grpc_port=50251, + headers=headers +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_local(headers=headers) + + +def url_to_base64(url): + import requests + import base64 + + image_response = requests.get(url) + content = image_response.content + return base64.b64encode(content).decode("utf-8") + + +# END-ANY + +# SinglePromptGeneration +# Get the collection +movies = client.collections.use("MovieMM") + +# Perform query +src_img_path = "https://github.com/weaviate-tutorials/edu-datasets/blob/main/img/International_Space_Station_after_undocking_of_STS-132.jpg?raw=true" +query_b64 = url_to_base64(src_img_path) + +response = movies.generate.near_image( + near_image=query_b64, + limit=5, + # highlight-start + single_prompt="Translate this into French: {title}" + # highlight-end +) + +# Inspect the response +for o in response.objects: + # highlight-start + print(o.properties["title"]) # Print the title + # highlight-end + print(o.generated) # Print the generated text (the title, in French) + +client.close() +# END SinglePromptGeneration + + +print("\n\n") + +client.connect() + + +# GroupedTaskGeneration +# Get the collection +movies = client.collections.use("MovieMM") + +# Perform query +src_img_path = "https://github.com/weaviate-tutorials/edu-datasets/blob/main/img/International_Space_Station_after_undocking_of_STS-132.jpg?raw=true" +query_b64 = url_to_base64(src_img_path) + +response = movies.generate.near_image( + near_image=query_b64, + limit=5, + # highlight-start + grouped_task="What do these movies have in common?", + grouped_properties=["title", "overview"] # Optional parameter; for reducing prompt length + # highlight-end +) + +# Inspect the response +for o in response.objects: + print(o.properties["title"]) # Print the title +# highlight-start +print(response.generative.text) # Print the generated text (the commonalities between them) +# highlight-end + +client.close() +# END GroupedTaskGeneration diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/index.md new file mode 100644 index 000000000..ee79f624b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_multimodal_data/index.md @@ -0,0 +1,23 @@ +--- +title: "101M 操作方法:マルチモーダル データ" +description: 多様なデータ統合のために Weaviate でマルチモーダル データを扱う方法を学びます。 +sidebar_position: 102 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +このプロジェクトベースのコースでは、映画のデータセットと Weaviate を使用してマルチモーダル データを扱う方法を学びます。 + +Weaviate のベクトライザー機能を利用して、テキスト データと画像データを意味で一緒に検索できるように保存・インデックス化する実践的な経験を得ます。また、マルチモーダル検索手法やフィルターを使ってそのデータを検索する方法を学びます。さらに、取得したオブジェクトを基に出力を生成するために、Weaviate の検索拡張生成( RAG )機能の使い方も学びます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/10_client.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/10_client.mdx new file mode 100644 index 000000000..c08d94abc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/10_client.mdx @@ -0,0 +1,36 @@ +--- +title: Weaviate Python クライアント +description: Weaviate でのテキストデータ向けクライアントセットアップ +--- + +## インストール + +最新の Weaviate Python クライアントライブラリは `pip` を使用してインストールできます。クライアントライブラリは Python 3.8 以降でテストされています。次のコマンドでインストールしてください: + +```bash +pip install -U weaviate-client +``` + +最新のメジャーバージョンは `v4` (例: `4.x.x`)です。バージョンは次の方法で確認できます: + +```bash +pip show weaviate-client +``` + +## 基本的な使い方 + +Python から Weaviate クライアントライブラリを次のように読み込みます: + +```python +import weaviate +``` + +このクライアントには、Weaviate とのやり取りを容易にするために、`weaviate.classes` 内などのヘルパークラスや関数が用意されています。 + +次に、Weaviate インスタンスを作成して接続する方法を紹介します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx new file mode 100644 index 000000000..d82520842 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/10_create_wcs.mdx @@ -0,0 +1,67 @@ +--- +title: "オプション 1: クラウド WCD インスタンス" +description: テキストデータ用 Weaviate Cloud インスタンスの作成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../../_snippets/101_connect.py'; + +ここでは、 Weaviate Cloud ( WCD ) インスタンスを作成します。 WCD はクラウド上で動作するフルマネージドの Weaviate インスタンスで、インストールやメンテナンスが不要なため、 Weaviate を始めるには最適な方法です。 + +### WCD コンソールへのログイン + +[WCD Console](https://console.weaviate.cloud/) にアクセスし、認証情報でログインします。まだアカウントをお持ちでない場合は、ログイン画面の Register here リンクからサインアップできます。 + +### Weaviate インスタンスの作成 + +コンソールの Dashboard で Create cluster ボタンをクリックします。次の画面で以下を設定してください。 + +- "Free sandbox" タブを選択 +- クラスタ名を入力 +- "Enable authentication" を "Yes" に設定 + +Create ボタンをクリックすると、 Weaviate インスタンスの作成が始まります。完了まで数分かかります。 + +### Weaviate インスタンスの詳細取得 + +インスタンスが作成されると、 Details ボタンをクリックして詳細を確認できます。クラスタ URL と API キーを控えてください。 + +これらは Weaviate インスタンスへ接続する際に必要です。 + +### WCD インスタンスへの接続 + +Weaviate Cloud ( WCD ) インスタンスへ接続するには、クラスタ URL と API キーが必要です。これらは WCD コンソールで確認できます。 + +`connect_to_weaviate_cloud` 関数を使って WCD インスタンスへ接続します。 + + + +#### 推論 API キーの提供 + +一部の Weaviate モジュールでは、ベクトル化や大規模言語モデル統合のために推論 API を使用できます。インスタンス作成時にこれらの API キーを Weaviate に渡すことが可能です。 + +このコースでは OpenAI を使用するため、以下のように `headers={"X-OpenAI-Api-Key": }` を通じて OpenAI API キーを Weaviate に渡します。 + + + +:::note 次のステップ +ここまで完了したら、次のページ [オプション 2: ローカル Weaviate インスタンス](./20_create_docker.mdx) はスキップし、[Weaviate と通信する](../30_communicate.mdx) に進んでください。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx new file mode 100644 index 000000000..130d0ea13 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/20_create_docker.mdx @@ -0,0 +1,90 @@ +--- +title: "オプション 2: ローカル Docker インスタンス" +description: "テキストデータ用 Docker インスタンスの作成" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../../_snippets/101_connect.py'; + +:::note すでに Weaviate インスタンスを作成しましたか? +すでに [クラウドインスタンスを作成](./10_create_wcs.mdx) している場合は、このページをスキップして [Weaviate との通信](../30_communicate.mdx) に進んでください。 +::: + +ここでは、Docker を使用して Weaviate インスタンスを作成します。 + +### docker-compose ファイルのダウンロードと実行 + +お使いのマシンに Docker をインストールしてください。公式の [Docker インストールガイド](https://docs.docker.com/get-docker/) を参照することをおすすめします。 + +新しいディレクトリを作成し、ターミナルでそのディレクトリに移動します。次に `docker-compose.yml` という名前のファイルを作成し、以下の内容を追加します。 + +```yaml +--- +services: + weaviate_anon: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_API_BASED_MODULES: 'true' + BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups' + CLUSTER_HOSTNAME: 'node1' +... + +``` + +### Weaviate インスタンスの作成 + +次のコマンドを実行して Weaviate を起動します。 + +```bash +docker compose up +``` + +### Weaviate インスタンスの詳細 + +インスタンスが作成されると、`http://localhost:8080` でアクセスできます。 + +### Weaviate インスタンスへの接続 + +Weaviate インスタンスに接続するには、`connect_to_local` 関数を使用します。 + + + +#### 推論 API キーの設定 + +一部の Weaviate モジュールでは、データのベクトル化や大規模言語モデルの統合に推論 API を利用できます。インスタンス作成時にこれらのサービス用 API キーを Weaviate に渡すことが可能です。 + +このコースでは OpenAI を使用するため、以下のように `headers={"X-OpenAI-Api-Key": }` を通じて OpenAI API キーを Weaviate に提供できます。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/index.mdx new file mode 100644 index 000000000..7143cc183 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/20_create_instance/index.mdx @@ -0,0 +1,19 @@ +--- +title: Weaviate インスタンスの作成 +description: Weaviate でのテキストデータインスタンスの作成 +--- + +このユニットでは、Weaviate Cloud (WCD) インスタンスを作成するか、ローカル Docker インスタンスを作成するかを選択できます。 + +- [Weaviate Cloud (WCD) インスタンスを作成する](./10_create_wcs.mdx) + - マネージドサービスを利用し、インストールやメンテナンスを気にせずに使用したい場合におすすめです。 +- [ローカル Docker インスタンスを作成する](./20_create_docker.mdx) + - ローカルマシンで Weaviate を実行したい、またはインストールとメンテナンスを完全に制御したい場合におすすめです。 + +どちらのオプションでも本コースでは問題ありません。選択に迷う場合は、まず WCD インスタンスから始めることをおすすめします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/30_communicate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/30_communicate.mdx new file mode 100644 index 000000000..602969b5d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/30_communicate.mdx @@ -0,0 +1,65 @@ +--- +title: Weaviate との通信 +description: Weaviate におけるテキストデータの通信設定 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/101_connect.py'; + +ここでは、Python クライアントライブラリを使用して Weaviate と通信する基本操作を行います。 + +### Weaviate のステータス確認 + +Weaviateインスタンスが起動しているかどうかは `is_live` 関数で確認できます。 + + + +### サーバーメタ情報の取得 + +Weaviateインスタンスのメタ情報は `meta` 関数で取得できます。 + + + +これにより、サーバーのメタ情報がコンソールに出力されます。出力例は次のとおりです。 + +
+ get_meta 出力 + + +
+ +### 接続の終了 + +Weaviateクライアントの使用が終わったら、接続を終了するようにしてください。これによりリソースが解放され、接続が適切にクローズされます。 + +ベストプラクティスとしては `try`-`finally` ブロックを使用することを推奨します。簡潔にするため、以降のコードスニペットでは `try`-`finally` ブロックは省略します。 + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/index.mdx new file mode 100644 index 000000000..5a5e6274c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/101_setup_weaviate/index.mdx @@ -0,0 +1,24 @@ +--- +title: Weaviate をセットアップする +description: Weaviate でのテキスト データ管理をセットアップするためのステップバイステップ ガイド。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/10_preparation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/10_preparation.mdx new file mode 100644 index 000000000..1a5a706b2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/10_preparation.mdx @@ -0,0 +1,41 @@ +--- +title: 準備 +description: テキストコレクションの準備 +--- + +このセクションでは、映画データセットを使用して Weaviate インスタンスにデータを投入し、OpenAI API を用いてテキストデータを埋め込みます。 + +### Weaviate インスタンス + +Weaviate インスタンスをセットアップしておいてください。すでに [インスタンスを作成](../101_setup_weaviate/20_create_instance/index.mdx) し、接続できる状態である必要があります。 + +### OpenAI キー + +本ガイドを進めるには OpenAI API キーが必要です。まだお持ちでない場合は、[OpenAI のウェブサイト](https://openai.com/) でアカウントを作成し、API キーを取得してください。 + + + +### ソースデータ + +[TMDB](https://www.themoviedb.org/) から取得した映画データセットを使用します。データセットはこの [GitHub リポジトリ](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json) にあり、1990 年から 2024 年までに公開された約 700 本の映画の書誌情報が含まれています。 + +
+ サンプルデータを表示 + +| | backdrop_path | genre_ids | id | original_language | original_title | overview | popularity | poster_path | release_date | title | video | vote_average | vote_count | +|---:|:---------------------------------|:----------------|-----:|:--------------------|:----------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------:|:---------------------------------|:---------------|:----------------------------|:--------|---------------:|-------------:| +| 0 | /3Nn5BOM1EVw1IYrv6MsbOS6N1Ol.jpg | [14, 18, 10749] | 162 | en | Edward Scissorhands | A small suburban town receives a visit from a castaway unfinished science experiment named Edward. | 45.694 | /1RFIbuW9Z3eN9Oxw2KaQG5DfLmD.jpg | 1990-12-07 | Edward Scissorhands | False | 7.7 | 12305 | +| 1 | /sw7mordbZxgITU877yTpZCud90M.jpg | [18, 80] | 769 | en | GoodFellas | The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway. | 57.228 | /aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg | 1990-09-12 | GoodFellas | False | 8.5 | 12106 | +| 2 | /6uLhSLXzB1ooJ3522ydrBZ2Hh0W.jpg | [35, 10751] | 771 | en | Home Alone | Eight-year-old Kevin McCallister makes the most of the situation after his family unwittingly leaves him behind when they go on Christmas vacation. But when a pair of bungling burglars set their sights on Kevin's house, the plucky kid stands ready to defend his territory. By planting booby traps galore, adorably mischievous Kevin stands his ground as his frantic mother attempts to race home before Christmas Day. | 3.538 | /onTSipZ8R3bliBdKfPtsDuHTdlL.jpg | 1990-11-16 | Home Alone | False | 7.4 | 10599 | +| 3 | /vKp3NvqBkcjHkCHSGi6EbcP7g4J.jpg | [12, 35, 878] | 196 | en | Back to the Future Part III | The final installment of the Back to the Future trilogy finds Marty digging the trusty DeLorean out of a mineshaft and looking for Doc in the Wild West of 1885. But when their time machine breaks down, the travelers are stranded in a land of spurs. More problems arise when Doc falls for pretty schoolteacher Clara Clayton, and Marty tangles with Buford Tannen. | 28.896 | /crzoVQnMzIrRfHtQw0tLBirNfVg.jpg | 1990-05-25 | Back to the Future Part III | False | 7.5 | 9918 | +| 4 | /3tuWpnCTe14zZZPt6sI1W9ByOXx.jpg | [35, 10749] | 114 | en | Pretty Woman | When a millionaire wheeler-dealer enters a business contract with a Hollywood hooker Vivian Ward, he loses his heart in the bargain. | 97.953 | /hVHUfT801LQATGd26VPzhorIYza.jpg | 1990-03-23 | Pretty Woman | False | 7.5 | 7671 | + +
+ +次に、対応するオブジェクトコレクションを作成し、データをインポートします。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/20_create_collection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/20_create_collection.mdx new file mode 100644 index 000000000..1fdfddfa0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/20_create_collection.mdx @@ -0,0 +1,87 @@ +--- +title: コレクションの作成 +description: テキスト データのためのコレクションの作成 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + + Weaviate はデータを「コレクション」に保存します。コレクションとは、同じデータ構造を共有するオブジェクトの集合です。映画データベースの場合、映画のコレクション、俳優のコレクション、レビューのコレクションなどを作成できます。 + +ここでは映画のコレクションを作成します。 + +## コード + +次の例では、映画データのコレクションを作成します。 + + + +各コレクション定義には名前が必要です。その後、この例で示したように追加のパラメーターを定義できます。 + +## コードの解説 + +### プロパティ + +プロパティとは、コレクションに保存したいオブジェクトの属性です。各プロパティには名前とデータ型があります。 + +映画データベースでは、`title`、`release_date`、`genre_ids` などのプロパティがあり、データ型としては `TEXT`(文字列)、`DATE`(日付)、`INT`(整数)などがあります。`genre_ids` のように整数の配列を持つことも可能です。 + +#### 自動スキーマ + + Weaviate はデータから自動的に[スキーマを推論](/weaviate/config-refs/collections.mdx#auto-schema)できます。ただし、制御性を高め予期しない動作を防ぐため、プロパティを明示的に定義することを推奨します。 + +### ベクトライザー設定 + +ベクトルを自分で指定しない場合、 Weaviate は指定したベクトライザーを用いてデータからベクトル埋め込みを生成します。 + +このコード例では、デフォルト設定で `text2vec-openai` モジュールを指定しています。 + + + +### 生成モジュール設定 + +コレクションを生成モデル(例: 大規模言語モデル)と併用する場合は、生成モジュールの指定が必要です。 + +このコード例では、デフォルト設定で `openai` モジュール(正式名称は `generative-openai`)を指定しています。 + + + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +### Python クラス + +コード例では、`Property`、`DataType`、`Configure` などのクラスを使用しています。これらは `weaviate.classes.config` サブモジュールで定義されており、コレクションを定義する際に利用します。 + +利便性のため、サブモジュールを `wc` としてインポートし、そのクラスを使用しています。 + + + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/30_import_data.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/30_import_data.mdx new file mode 100644 index 000000000..ce3121e72 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/30_import_data.mdx @@ -0,0 +1,106 @@ +--- +title: データのインポート +description: テキストコレクションへのデータインポート +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +## コード + +この例では、映画データをコレクションにインポートします。 + + + +コードの処理内容: +- ソースデータを読み込み、コレクションを取得します +- `batch` オブジェクトを用いたコンテキストマネージャーに入ります +- データをループし、各オブジェクトをバッチャーに追加します +- インポートエラーがあれば表示します + +## コードの説明 + +### 準備 + +`requests` ライブラリを使用してソース (今回は JSON ファイル) からデータを読み込みます。 +その後、取り扱いやすいように Pandas DataFrame に変換します。 + +次に、`client.collections.get` を使ってコレクションオブジェクトを作成し、コレクションへアクセスできるようにします。 + +### バッチコンテキストマネージャー + +`batch` オブジェクトはコンテキストマネージャーで、オブジェクトをバッチャーに追加できます。 +大量のデータをインポートする際、バッチサイズの管理や送信タイミングの調整を抽象化してくれるため便利です。 + + + +この例では `.fixed_size()` メソッドでバッチャーを作成し、バッチあたりのオブジェクト数を設定しています。 +他にも `.rate_limit()` (1 分あたりのオブジェクト数を指定) や `.dynamic()` (インポート中にバッチサイズを自動調整) などのバッチャータイプがあります。 + +### バッチャーへのデータ追加 + +#### データ型の変換 + +データは文字列から、 Weaviate に適した型へ変換されます。 +例として、`release_date` は datetime オブジェクトへ、`genre_ids` は整数のリストへ変換します。 + + + +#### オブジェクトをバッチャーに追加 + +次にデータをループし、各オブジェクトを `batch.add_object` でバッチャーに追加します。 +バッチャーは指定されたタイプに従い、バッチを送信します。 + + + +### エラー処理 + +1 つのバッチには複数のオブジェクトが含まれるため、一部のオブジェクトがインポートに失敗する可能性があります。 +バッチャーはこれらのエラーを保存します。 + +エラーを出力して原因を確認し、例外を発生させるなど適切に対処してください。 +この例ではエラーを単に出力しています。 + + + +新しいコンテキストマネージャーに入るとエラーリストはクリアされるため、新しいバッチャーを初期化する前にエラー処理を行う必要があります。 + +## ベクトルの生成元 + +バッチャーがキューを Weaviate に送信すると、オブジェクトはコレクション (今回は映画コレクション) に追加されます。 + +コレクションにはベクトライザー モジュールが設定されており、ここではベクトルを指定していません。 +そのため、 Weaviate は指定されたベクトライザーを用いてデータからベクトル埋め込みを生成します。 + +## 質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/index.mdx new file mode 100644 index 000000000..d6876651a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/102_text_collections/index.mdx @@ -0,0 +1,24 @@ +--- +title: データベースを構築する +description: Weaviate でテキストコレクションを効率的に整理・管理します。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/10_semantic.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/10_semantic.mdx new file mode 100644 index 000000000..d187d28bb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/10_semantic.mdx @@ -0,0 +1,67 @@ +--- +title: セマンティック検索 +description: テキストデータにおけるセマンティック検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_searches.py'; + +Weaviate を使用すると、意味に基づいて類似アイテムを検索するセマンティック検索を実行できます。これは、データベース内のアイテムのベクトル埋め込みを比較することで行われます。 + +### コード + +この例では、「dystopian future」というクエリとの類似度に基づいて「Movie」のエントリーを検索し、最も一致度の高い 5 件のタイトルと公開年を出力します。 + + + +## コードの解説 + +結果は、クエリとデータベースオブジェクトのテキスト間のベクトル埋め込みの類似度に基づいています。この例では、埋め込みはベクトライザー モジュールによって生成されます。 + +`limit` パラメーターは、返される結果の最大件数を設定します。 + +`return_metadata` パラメーターには `MetadataQuery` クラスのインスタンスを渡し、検索結果として返すメタデータを指定します。現在のクエリでは、クエリとのベクトル距離を返します。 + +
+ Example results + +```text +In Time 2011 +Distance to query: 0.179 + +Gattaca 1997 +Distance to query: 0.180 + +I, Robot 2004 +Distance to query: 0.182 + +Mad Max: Fury Road 2015 +Distance to query: 0.190 + +The Maze Runner 2014 +Distance to query: 0.193 +``` + +
+ +### レスポンスオブジェクト + +返されるオブジェクトはカスタムクラスのインスタンスです。その `objects` 属性は検索結果のリストで、各要素も別のカスタムクラスのインスタンスです。 + +各オブジェクトは次のようになります。 +- デフォルトでは、blob データ型を持つものを除き、すべてのプロパティとその UUID を含みます。 +- デフォルトでは、それ以外の情報 (例: references、metadata、vectors) は含みません。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/20_keyword_hybrid.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/20_keyword_hybrid.mdx new file mode 100644 index 000000000..9384a8fea --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/20_keyword_hybrid.mdx @@ -0,0 +1,105 @@ +--- +title: キーワード & ハイブリッド検索 +description: テキストコレクションにおけるキーワードおよびハイブリッド検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_searches.py'; + +キーワード類似度に基づいてアイテムを検索するキーワード ( BM25 ) 検索、または BM25 とセマンティック/ベクトル検索を組み合わせたハイブリッド検索を実行できます。 + +## キーワード検索 + +### コード + +この例では、用語「history」に対してキーワード検索スコアが最も高い「Movie」のエントリを取得し、上位 5 件のタイトルと公開年を表示します。 + + + +### コードの解説 + +結果は [BM25f](https://en.wikipedia.org/wiki/Okapi_BM25) アルゴリズムを用いたキーワード検索スコアに基づいています。 + +`limit` パラメーターは返却する最大件数を指定します。 + +`return_metadata` パラメーターには `MetadataQuery` クラスのインスタンスを渡し、検索結果に含めるメタデータを設定します。今回のクエリでは、結果の BM25 スコアである `score` を返却しています。 + +
+ 結果例 + +```text +American History X 1998 +BM25 score: 2.707 + +A Beautiful Mind 2001 +BM25 score: 1.896 + +Legends of the Fall 1994 +BM25 score: 1.663 + +Hacksaw Ridge 2016 +BM25 score: 1.554 + +Night at the Museum 2006 +BM25 score: 1.529 +``` + +
+ + +## ハイブリッド検索 + +### コード + +この例では、用語「history」に対してハイブリッド検索スコアが最も高い「Movie」のエントリを取得し、上位 5 件のタイトルと公開年を表示します。 + + + +### コードの解説 + +結果は BM25 とセマンティック/ベクトル検索を組み合わせたハイブリッド検索スコアに基づいています。 + +`limit` パラメーターは返却する最大件数を指定します。 + +`return_metadata` パラメーターには `MetadataQuery` クラスのインスタンスを渡し、検索結果に含めるメタデータを設定します。今回のクエリでは、結果のハイブリッドスコアである `score` を返却しています。 + +
+ 結果例 + +```text +Legends of the Fall 1994 +Hybrid score: 0.016 + +Hacksaw Ridge 2016 +Hybrid score: 0.016 + +A Beautiful Mind 2001 +Hybrid score: 0.015 + +The Butterfly Effect 2004 +Hybrid score: 0.015 + +Night at the Museum 2006 +Hybrid score: 0.012 +``` + +
+ + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/30_filters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/30_filters.mdx new file mode 100644 index 000000000..2c5e739b5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/30_filters.mdx @@ -0,0 +1,55 @@ +--- +title: フィルター +description: テキスト検索のフィルター +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/103_searches.py'; + +フィルターを使用すると、検索結果をより正確に絞り込むことができます。プロパティだけでなくメタデータでもフィルターでき、複数のフィルターを `and` や `or` 条件で組み合わせることで、さらに結果を絞り込めます。 + +### コード + +この例では、クエリ "dystopian future" との類似度に基づいて "Movie" 内のエントリーを検索し、かつ 2020 年以降に公開されたものだけを対象としています。上位 5 件について、タイトルと公開年を出力します。 + + + +## コードの説明 + +このクエリは、[前章](./10_semantic.mdx) で示した セマンティック検索 の例と同じですが、フィルターが追加されています。ここでは `filters` パラメーターに `Filter` クラスのインスタンスを渡し、フィルター条件を設定しています。現在のクエリでは、公開年が 2010 年より後の結果のみを返すようにフィルターしています。 + +
+ 例: 結果 + +```text +Dune 2021 +Distance to query: 0.199 + +Tenet 2020 +Distance to query: 0.200 + +Mission: Impossible - Dead Reckoning Part One 2023 +Distance to query: 0.207 + +Onward 2020 +Distance to query: 0.214 + +Jurassic World Dominion 2022 +Distance to query: 0.216 +``` + +
+ + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/index.mdx new file mode 100644 index 000000000..7363f163b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/103_text_searches/index.mdx @@ -0,0 +1,24 @@ +--- +title: 検索の実行 +description: Weaviate の Python クライアントを使用して効率的なテキストベース検索を実行します。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/10_setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/10_setup.mdx new file mode 100644 index 000000000..c51e3965d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/10_setup.mdx @@ -0,0 +1,40 @@ +--- +title: "RAG:概要" +description: テキスト RAG の設定 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/102_collection.py'; + +### 目的 + +検索拡張生成 (RAG) は、セマンティック検索の検索能力と、大規模言語モデルなどの AI モデルの生成能力という両方の長所を組み合わせる方法です。これにより、Weaviate インスタンスからオブジェクトを取得し、その取得したオブジェクトに基づいて出力を生成できます。 + +### セットアップ + +コレクションを作成した際、ここに示すとおり `generative_module` パラメーターを指定しました。 + + + +これは、取得したオブジェクトをもとに出力を生成するための生成モジュールを選択するものです。この例では `openai` モジュールと、`GPT` 系の大規模言語モデルを使用しています。 + +ベクトライザー モジュールのときと同様に、生成モジュールの提供元から API キーを取得する必要があります。この場合は OpenAI の API キーが必要です。 + +### RAG クエリ + +RAG クエリは、Weaviate では「generative クエリ」とも呼ばれます。これらの機能は、コレクション オブジェクトの `generate` サブモジュールから利用できます。 + +generative クエリは通常の検索クエリに加えて動作し、取得された各オブジェクトに対して RAG クエリを実行します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/20_single_prompt.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/20_single_prompt.mdx new file mode 100644 index 000000000..5cddd6b61 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/20_single_prompt.mdx @@ -0,0 +1,55 @@ +--- +title: " single prompt 生成" +description: Text RAG 用 single prompt +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/104_rag.py'; + +『 single prompt 』生成は、取得された各オブジェクトに対して RAG クエリを実行します。同じ prompt で各オブジェクトを個別に変換したいときに便利です。 + +### コード + +この例では、“ Movie ” クラス内でクエリ ベクトル(“ dystopian future ”)と最も類似する ベクトル を持つエントリーを検索します。その後、各映画の title をフランス語に翻訳するよう大規模言語モデルに指示します。生成された各結果はコンソールに出力されます。 + + + +## コードの解説 + +ここでは `"... {title} ..."` のように波かっこで囲んで、 `single_prompt` パラメーターに 1 つ以上のプロパティを渡す必要があります。これにより Weaviate は、取得した各オブジェクトの `title` プロパティを大規模言語モデルへ渡します。 + +
+ 結果例 + +```text +In Time +À temps +Looper +Boucleur +I, Robot +Je, Robot +The Matrix +La Matrice +Children of Men +Les enfants des hommes +``` + +
+ +### レスポンスオブジェクト + +各レスポンスオブジェクトは通常の検索クエリの結果とほぼ同じですが、追加で `generated` 属性が含まれます。この属性には、各オブジェクトの生成結果が入ります。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/30_grouped_task.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/30_grouped_task.mdx new file mode 100644 index 000000000..a062bbb32 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/30_grouped_task.mdx @@ -0,0 +1,58 @@ +--- +title: "'Grouped task' 生成" +description: Text RAG 用 Grouped Task +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!../_snippets/104_rag.py'; + +「grouped task」生成では、取得したオブジェクト集合に対して RAG(検索拡張生成) クエリを実行します。1 つのプロンプトでオブジェクト群をまとめて変換したい場合に便利です。 + +### コード + +この例では、「dystopian future」のクエリ ベクトルに最も近い "Movie" のエントリを検索します。その後、大規模言語モデルに対し、それらの共通点を見つけるよう指示します。 + +各結果はコンソールに表示されます。 + + + +## コードの解説 + +`grouped_task` クエリでは、プロンプトを `grouped_task` パラメーターに渡すだけです。これにより Weaviate は以下を大規模言語モデルへ渡します。 +- 取得したすべてのオブジェクトのテキスト プロパティ +- プロンプト + +
+ 結果例 + +```text +In Time +Looper +I, Robot +The Matrix +Children of Men +These movies all involve futuristic settings and explore themes related to the manipulation of time, technology, and the potential consequences of advancements in society. They also touch on issues such as inequality, control, and the impact of human actions on the future of humanity. +``` + +
+ +### 追加パラメーター + +`grouped_properties` パラメーターとして使用するプロパティのリストを渡すこともできます。これにより、大規模言語モデルへ渡すデータ量を削減し、不要なプロパティを省くことが可能です。 + +### レスポンス オブジェクト + +`grouped_task` パラメーターを含む RAG クエリは、追加の `generated` 属性を持つレスポンスを返します。この属性には、オブジェクト集合に対して生成された出力が含まれます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/index.mdx new file mode 100644 index 000000000..247ba0f9b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/104_text_rag/index.mdx @@ -0,0 +1,24 @@ +--- +title: LLM と Weaviate( RAG ) +description: Weaviate で検索精度を向上させるためにテキスト データ向け RAG を実装します。 +--- + + + + + + +## 学習目標 + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/900_next_steps.mdx new file mode 100644 index 000000000..b14a6109f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/900_next_steps.mdx @@ -0,0 +1,7 @@ +--- +title: 次のステップ +--- + +import IntroNextSteps from '../_snippets/intro_next_steps.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/101_connect.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/101_connect.py new file mode 100644 index 000000000..82ca65e70 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/101_connect.py @@ -0,0 +1,161 @@ +# WCDInstantiation +import weaviate +from weaviate.classes.init import Auth +import os + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key +) +# END WCDInstantiation + +client.close() + +# WCDAPIKeyInstantiation +import weaviate +from weaviate.classes.init import Auth +import os + +headers = { + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") +} # Replace with your OpenAI API key + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) +# END WCDAPIKeyInstantiation + +client.close() + +# DockerInstantiation +import weaviate + +client = weaviate.connect_to_local() +# END DockerInstantiation + +# DockerAPIKeyInstantiation +import weaviate +import os + +headers = { + "X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY") +} # Replace with your OpenAI API key + +client = weaviate.connect_to_local(headers=headers) +# END DockerAPIKeyInstantiation + +# PollLiveness +assert client.is_live() # This will raise an exception if the client is not live +# END PollLiveness + + +# GetMeta +import json + +metainfo = client.get_meta() +print(json.dumps(metainfo, indent=2)) # Print the meta information in a readable format +# END GetMeta + + +""" +# OutputGetMeta +{ + "hostname": "http://[::]:8080", + "modules": { + "backup-gcs": { + "bucketName": "weaviate-wcs-prod-cust-europe-west2-workloads-backups", + "rootName": "8616b69e-f8d2-4547-ad92-70b9557591c0" + }, + "generative-aws": { + "documentationHref": "https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html", + "name": "Generative Search - AWS" + }, + "generative-cohere": { + "documentationHref": "https://docs.cohere.com/reference/generate", + "name": "Generative Search - Cohere" + }, + "generative-openai": { + "documentationHref": "https://platform.openai.com/docs/api-reference/completions", + "name": "Generative Search - OpenAI" + }, + "generative-palm": { + "documentationHref": "https://cloud.google.com/vertex-ai/docs/generative-ai/chat/test-chat-prompts", + "name": "Generative Search - Google PaLM" + }, + "qna-openai": { + "documentationHref": "https://platform.openai.com/docs/api-reference/completions", + "name": "OpenAI Question & Answering Module" + }, + "ref2vec-centroid": {}, + "reranker-cohere": { + "documentationHref": "https://txt.cohere.com/rerank/", + "name": "Reranker - Cohere" + }, + "text2vec-aws": { + "documentationHref": "https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings", + "name": "AWS Module" + }, + "text2vec-cohere": { + "documentationHref": "https://docs.cohere.ai/embedding-wiki/", + "name": "Cohere Module" + }, + "text2vec-huggingface": { + "documentationHref": "https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task", + "name": "Hugging Face Module" + }, + "text2vec-jinaai": { + "documentationHref": "https://jina.ai/embeddings/", + "name": "JinaAI Module" + }, + "text2vec-openai": { + "documentationHref": "https://platform.openai.com/docs/guides/embeddings/what-are-embeddings", + "name": "OpenAI Module" + }, + "text2vec-palm": { + "documentationHref": "https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings", + "name": "Google PaLM Module" + } + }, + "version": "1.23.8" +} +# END OutputGetMeta +""" + + +client.close() + + +# TryFinallyCloseDemo +import weaviate +import os + +# END TryFinallyCloseDemo + +from weaviate.classes.init import Auth + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key +) + +# TryFinallyCloseDemo +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local(...) + +try: + # Work with the client here - e.g.: + assert client.is_live() + pass + +finally: # This will always be executed, even if an exception is raised + client.close() # Close the connection & release resources +# END TryFinallyCloseDemo diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/102_collection.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/102_collection.py new file mode 100644 index 000000000..77666c42f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/102_collection.py @@ -0,0 +1,128 @@ +# CreateMovieCollection +import weaviate + +# CreateMovieCollection # SubmoduleImport +import weaviate.classes.config as wc +import os + +# CreateMovieCollection # END SubmoduleImport + +# END CreateMovieCollection + +from weaviate.classes.init import Auth + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key +) + +# CreateMovieCollection +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_weaviate_cloud(..., headers=headers) or +# client = weaviate.connect_to_local(..., headers=headers) + +# END CreateMovieCollection + +# Actual instantiation + +client.collections.delete("Movie") + +# CreateMovieCollection +client.collections.create( + name="Movie", + properties=[ + wc.Property(name="title", data_type=wc.DataType.TEXT), + wc.Property(name="overview", data_type=wc.DataType.TEXT), + wc.Property(name="vote_average", data_type=wc.DataType.NUMBER), + wc.Property(name="genre_ids", data_type=wc.DataType.INT_ARRAY), + wc.Property(name="release_date", data_type=wc.DataType.DATE), + wc.Property(name="tmdb_id", data_type=wc.DataType.INT), + ], + # Define the vectorizer module + vector_config=wc.Configure.Vectors.text2vec_openai(), + # Define the generative module + generative_config=wc.Configure.Generative.openai() + # END generativeDefinition # CreateMovieCollection +) + +client.close() +# END CreateMovieCollection + + +# BatchImportData +import weaviate +import pandas as pd +import requests +from datetime import datetime, timezone +import json +from weaviate.util import generate_uuid5 +from tqdm import tqdm +import os + +# END BatchImportData + +from weaviate.classes.init import Auth + +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) + +# BatchImportData +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local(...) + +# END BatchImportData + +# BatchImportData +data_url = "https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/movies_data_1990_2024.json" +resp = requests.get(data_url) +df = pd.DataFrame(resp.json()) + +# Get the collection +movies = client.collections.use("Movie") + +# Enter context manager +with movies.batch.fixed_size(batch_size=200) as batch: + # Loop through the data + for i, movie in tqdm(df.iterrows()): + # Convert data types + # Convert a JSON date to `datetime` and add time zone information + release_date = datetime.strptime(movie["release_date"], "%Y-%m-%d").replace( + tzinfo=timezone.utc + ) + # Convert a JSON array to a list of integers + genre_ids = json.loads(movie["genre_ids"]) + + # Build the object payload + movie_obj = { + "title": movie["title"], + "overview": movie["overview"], + "vote_average": movie["vote_average"], + "genre_ids": genre_ids, + "release_date": release_date, + "tmdb_id": movie["id"], + } + + # Add object to batch queue + batch.add_object( + properties=movie_obj, + uuid=generate_uuid5(movie["id"]) + # references=reference_obj # You can add references here + ) + # Batcher automatically sends batches + +# Check for failed objects +if len(movies.batch.failed_objects) > 0: + print(f"Failed to import {len(movies.batch.failed_objects)} objects") + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/103_searches.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/103_searches.py new file mode 100644 index 000000000..7a32088d8 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/103_searches.py @@ -0,0 +1,139 @@ +# START-ANY +import weaviate +import weaviate.classes.query as wq +import os + +# END-ANY + +# FilteredSemanticSearch +from datetime import datetime + +# END FilteredSemanticSearch + +# START-ANY + +# END-ANY + +from weaviate.classes.init import Auth + +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_weaviate_cloud(..., headers=headers) or +# client = weaviate.connect_to_local(..., headers=headers) + +# END-ANY + +# MetadataSemanticSearch +# Get the collection +movies = client.collections.use("Movie") + +# Perform query +response = movies.query.near_text( + query="dystopian future", limit=5, return_metadata=wq.MetadataQuery(distance=True) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END MetadataSemanticSearch + + +print("\n\n") + +client.connect() + +# MetadataBM25Search +# Get the collection +movies = client.collections.use("Movie") + +# Perform query +response = movies.query.bm25( + query="history", limit=5, return_metadata=wq.MetadataQuery(score=True) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"BM25 score: {o.metadata.score:.3f}\n" + ) # Print the BM25 score of the object from the query + +client.close() +# END MetadataBM25Search + + +print("\n\n") + +client.connect() + +# MetadataHybridSearch +# Get the collection +movies = client.collections.use("Movie") + +# Perform query +response = movies.query.hybrid( + query="history", limit=5, return_metadata=wq.MetadataQuery(score=True) +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Hybrid score: {o.metadata.score:.3f}\n" + ) # Print the hybrid search score of the object from the query + +client.close() +# END MetadataHybridSearch + + +print("\n\n") + +client.connect() + +# FilteredSemanticSearch +# Get the collection +movies = client.collections.use("Movie") + +# Perform query +response = movies.query.near_text( + query="dystopian future", + limit=5, + return_metadata=wq.MetadataQuery(distance=True), + # highlight-start + filters=wq.Filter.by_property("release_date").greater_than(datetime(2020, 1, 1)) + # highlight-end +) + +# Inspect the response +for o in response.objects: + print( + o.properties["title"], o.properties["release_date"].year + ) # Print the title and release year (note the release date is a datetime object) + print( + f"Distance to query: {o.metadata.distance:.3f}\n" + ) # Print the distance of the object from the query + +client.close() +# END FilteredSemanticSearch diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/104_rag.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/104_rag.py new file mode 100644 index 000000000..b31adf951 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/_snippets/104_rag.py @@ -0,0 +1,78 @@ +# START-ANY +import os +import weaviate + +# END-ANY + +from weaviate.classes.init import Auth + +headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.getenv("WEAVIATE_URL"), # Replace with your WCD URL + auth_credentials=Auth.api_key( + os.getenv("WEAVIATE_API_KEY") + ), # Replace with your WCD key + headers=headers, +) + +# START-ANY +# Instantiate your client (not shown). e.g.: +# headers = {"X-OpenAI-Api-Key": os.getenv("OPENAI_APIKEY")} # Replace with your OpenAI API key +# client = weaviate.connect_to_weaviate_cloud(..., headers=headers) or +# client = weaviate.connect_to_local(..., headers=headers) + +# END-ANY + +# SinglePromptGeneration +# Get the collection +movies = client.collections.use("Movie") + +# Perform query +response = movies.generate.near_text( + query="dystopian future", + limit=5, + # highlight-start + single_prompt="Translate this into French: {title}" + # highlight-end +) + +# Inspect the response +for o in response.objects: + # highlight-start + print(o.properties["title"]) # Print the title + # highlight-end + print(o.generated) # Print the generated text (the title, in French) + +client.close() +# END SinglePromptGeneration + + +print("\n\n") + +client.connect() + + +# GroupedTaskGeneration +# Get the collection +movies = client.collections.use("Movie") + +# Perform query +response = movies.generate.near_text( + query="dystopian future", + limit=5, + # highlight-start + grouped_task="What do these movies have in common?", + # grouped_properties=["title", "overview"] # Optional parameter; for reducing prompt length + # highlight-end +) + +# Inspect the response +for o in response.objects: + print(o.properties["title"]) # Print the title +# highlight-start +print(response.generative.text) # Print the generated text (the commonalities between them) +# highlight-end + +client.close() +# END GroupedTaskGeneration diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/index.md new file mode 100644 index 000000000..c2f012f48 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/starter_text_data/index.md @@ -0,0 +1,23 @@ +--- +title: "101T テキストデータの取り扱い" +description: "Weaviate でテキストデータを扱い、強力な検索と分析を始めましょう。" +sidebar_position: 100 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +このプロジェクトベースのコースでは、映画データセットを使いながら、あらゆるテキストデータを Weaviate で扱う方法を学びます。 + +Weaviate のベクトライザー機能を用いて、テキストデータを意味ベースで保存・インデックスし、セマンティック検索、キーワード検索、ハイブリッド検索、さらにフィルターを使ってデータを検索する方法を実践的に体験できます。また、取得したオブジェクトを基に出力を生成する Weaviate の検索拡張生成 ( RAG ) 機能の使い方も学びます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tmp_images/academy_placeholder.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tmp_images/academy_placeholder.jpg new file mode 100644 index 000000000..49a360a8b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tmp_images/academy_placeholder.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/100_basics.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/100_basics.mdx new file mode 100644 index 000000000..ecfb99455 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/100_basics.mdx @@ -0,0 +1,55 @@ +--- +title: トークナイゼーションの概要 +--- + +トークナイゼーションとは、テキストをトークンと呼ばれるより小さな単位に分割する処理です。これは、テキストを多様な文脈で扱う方法に影響を与える重要なステップです。 + +例えば、次のようなテキストを考えてみましょう: + +```text +Ankh-Morpork's police captain +``` + +このテキストは、さまざまな方法でトークン化できます。以下はすべて正しいトークナイゼーションの例です。 + +1. `["Ankh-Morpork's", "police", "captain"]` +1. `["ankh", "morpork", "police", "captain"]` +1. `['An', '##kh', '-', 'Mo', '##rp', '##or', '##k', "'", 's', 'police', 'captain']` + +方法 1 と 2 は単語トークナイゼーションの例であり、方法 3 はサブワード トークナイゼーションの例です。 + +トークナイゼーション方式の選択は、テキストが使用される文脈によって異なります。 + +### キーワード検索・フィルタリング向け + +トークナイゼーション方式の選択は、キーワード検索とフィルタリングの結果に大きく影響し、ユーザーの期待に合う場合もあれば外れる場合もあります。 + +テレビ番組のデータベースでは、`"Superman"` や `"Clark"` という検索で `"Lois & Clark: The New Adventures of Superman"` がヒットすることを期待します。適切なトークナイゼーション方式を選択すれば、これを実現できます。 + +しかし、メールアドレスのデータベースでは、`"john@example.com"` の検索結果に `"john.doe@example.com"` が含まれることは想定しません。この場合、上記とは異なるトークナイゼーション戦略が必要になるでしょう。 + +では、その中間的なケースはどうでしょうか。`"clark"` や `"lois and clark"` の検索で番組を含めるべきかどうかは、検索をどのように機能させたいかによって決まります。 + +このような多様なニーズに対応するため、 Weaviate ではユースケースに合わせてトークナイゼーション方式を設定できます。次のセクションからは、 Weaviate で利用できるトークナイゼーション方式とその設定方法について説明します。 + +### 言語モデル向け + +言語モデルは、テキスト全体の意味を理解し、埋め込みや生成を行います。そのため、言語モデル用の各トークンは意味を表現するよう設計されています。 + +語彙サイズを適切に保ちつつテキストの意味を捉えるために、サブワード トークナイゼーション(上記方法 3)がよく採用されます。これは言語モデルのアーキテクチャの重要な要素です。 + +ただしユーザーレベルでは、トークナイゼーション方式を意識する必要はありません。モデルの開発(学習)と利用(推論)の間で方式を一致させる必要があるため、トークナイゼーションはモデルに組み込まれています。 + +そのため、 Weaviate でテキストを ベクトル化 したり、検索拡張生成 (RAG) を行ったりする場合でも、トークナイゼーション方式を気にする必要はありません。選択したモデルが自動的に処理します。 + +結果として、このコースでは言語モデルの文脈におけるトークナイゼーションの詳細には触れません。 + +:::info 言語モデル用トークナイゼーションに興味がありますか? +この分野は奥が深く、学ぶことが多くあります。詳細を知りたい場合は、 Hugging Face が提供する [トピックの概念ガイド](https://huggingface.co/transformers/tokenizer_summary.html) が参考になります。さらに、 Hugging Face の `transformers` ライブラリを使用した [トークナイザー利用ガイド](https://huggingface.co/learn/nlp-course/en/chapter2/4) もご覧ください。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/200_options.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/200_options.mdx new file mode 100644 index 000000000..76f9ead16 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/200_options.mdx @@ -0,0 +1,141 @@ +--- +title: 利用可能なトークナイゼーションオプション +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Weaviate では、さまざまなトークナイゼーションオプションを選択できます。これらのオプションにより、各プロパティでのキーワード検索やフィルターの方法を設定できます。 + +主なオプションは次のとおりです。 + +- `word`: 英数字のみ・小文字化されたトークン +- `lowercase`: 小文字化されたトークン +- `whitespace`: 空白区切り・大文字小文字を区別するトークン +- `field`: プロパティの値全体を 1 つのトークンとして扱う + +それぞれのオプションについて、動作と利用シーンを詳しく見ていきましょう。 + +## トークナイゼーション手法 + +### `word` + +`word` トークナイゼーションは、英数字以外の文字でテキストを分割し、その後すべてのトークンを小文字化します。 + +`word` トークナイゼーションの例は次のとおりです。 + +| Text | Tokens | +| ---- | ------ | +| `"Why, hello there!"` | `["why", "hello", "there"]` | +| `"Lois & Clark: The New Adventures of Superman"` | `["lois", "clark", "the", "new", "adventures", "of", "superman"]` | +| `"variable_name"` | `["variable", "name"]` | +| `"Email: john.doe@example.com"` | `["email", "john", "doe", "example", "com"]` | + +#### `word` トークナイゼーションを使う場合 + +`word` トークナイゼーションは Weaviate のデフォルト手法です。 + +一般的なテキストデータを検索またはフィルターする場合、まずは `word` を検討するとよいでしょう。 + +ただし、`&`、`@`、`_` などの記号が重要であったり、大文字小文字の区別が必要な場合には、`lowercase` や `whitespace` など別の手法を検討してください。 + +### `lowercase` + +`lowercase` トークナイゼーションは、空白でテキストを分割し、その後すべてのトークンを小文字化します。 + +`lowercase` トークナイゼーションの例は次のとおりです。 + +| Text | Tokens | +| ---- | ------ | +| `"Why, hello there!"` | `["why,", "hello", "there!"]` | +| `"Lois & Clark: The New Adventures of Superman"` | `["lois", "&", "clark:", "the", "new", "adventures", "of", "superman"]` | +| `"variable_name"` | `["variable_name"]` | +| `"Email: john.doe@example.com"` | `["email:", "john.doe@example.com"]` | + +#### `lowercase` トークナイゼーションを使う場合 + +`lowercase` は `word` に記号を含めたイメージです。`&`、`@`、`_` などの記号が意味を持つデータを扱う場合に適しています。 + +たとえば、データベースにコードスニペット、メールアドレス、その他の記号を含む表記があるケースなどです。 + +例として、`"database_address"` を含むオブジェクトをフィルターする場合を考えます。 + +| Text | Tokenization | `"database_address"` でマッチ | +| ---- | ------------ | --------------------- | +| `"database_address"` | `word` | ✅ | +| `"database_address"` | `lowercase` | ✅ | +| `"database_company_address"` | `word` | ✅ | +| `"database_company_address"` | `lowercase` | ❌ | + +フィルタリング動作がどのように変わるかに注目してください。適切なトークナイゼーションを選択することで、検索結果が自身やユーザーの期待に沿うように調整できます。 + +### `whitespace` + +`whitespace` トークナイゼーションは、空白でテキストを分割します。 + +`whitespace` トークナイゼーションの例は次のとおりです。 + +| Text | Tokens | +| ---- | ------ | +| `"Why, hello there!"` | `["Why,", "hello", "there!"]` | +| `"Lois & Clark: The New Adventures of Superman"` | `["Lois", "&", "Clark:", "The", "New", "Adventures", "of", "Superman"]` | +| `"variable_name"` | `["variable_name"]` | +| `"Email: john.doe@example.com"` | `["Email:", "john.doe@example.com"]` | + +#### `whitespace` トークナイゼーションを使う場合 + +`whitespace` は `lowercase` に大文字小文字の区別を加えたものです。固有名詞や略語など、大小文字の違いが重要なデータに適しています。 + +一方で、`whitespace` は厳格すぎる場合があります。たとえば `"superman"` という検索語では `"Superman"` にマッチしません。 + +ただし、クエリ側で小文字と大文字の 2 つのバージョンを生成するなど、ケースバイケースで対処は可能です。 + +逆に、`word` や `lowercase` では大文字小文字を区別した検索は不可能です。 + +### `field` + +`field` トークナイゼーションは、プロパティの値全体を 1 つのトークンとして扱います。 + +`field` トークナイゼーションの例は次のとおりです。 + +| Text | Tokens | +| ---- | ------ | +| `"Why, hello there!"` | `["Why, hello there!"]` | +| `"Lois & Clark: The New Adventures of Superman"` | `["Lois & Clark: The New Adventures of Superman"]` | +| `"variable_name"` | `["variable_name"]` | +| `"Email: john.doe@example.com"` | `["Email: john.doe@example.com"]` | + +#### `field` トークナイゼーションを使う場合 + +`field` は、文字列を正確に同じ順序で一致させる必要がある場合に有用です。一般的には、メールアドレス、URL、その他一意な文字列など、ユニーク ID を含むプロパティに適しています。 + +非常に厳格なため、慎重に利用してください。 + +キーワード検索において `field` の用途は限定的です。たとえば `"computer mouse"` という検索では `"mouse for a computer"`、 `"computer mouse pad"`、 `"a computer mouse"` などにはマッチしません。 + +## ストップワード + +Weaviate は [ストップワード](https://en.wikipedia.org/wiki/Stop_word) をサポートしています。ストップワードとは、出現頻度が高く意味を持たないため、検索クエリから除外されることが多い一般的な単語です。 + +デフォルトでは、Weaviate は [英語のストップワードリスト](https://github.com/weaviate/weaviate/blob/main/adapters/repos/db/inverted/stopwords/presets.go) を使用します。スキーマ定義で [独自のストップワードリストを設定](../../../weaviate/config-refs/indexing/inverted-index.mdx#stopwords) することも可能です。 + +トークナイゼーション後、ストップワードは存在しないものとして扱われます。たとえば `"a computer mouse"` をフィルターしても `"computer mouse"` と同じ結果になります。 +## 言語固有のトークン化 + +上記のトークン化方式は、英語のように単語間をスペースで区切る言語ではうまく機能します。 + +しかし、すべての言語がスペースを自然な意味境界として利用するとは限りません。日本語、中国語、韓国語のように単語がスペースで区切られない言語では、別のトークン化方式を使用する必要があります。 + +Weaviate では、この目的のために `gse` と `trigram`(`v1.24` から)および `kagome_kr`(`v1.25.7` から)のトークン化方式を提供しています。 + +`gse` は、中国語テキスト分割で広く使われている「Jieba」アルゴリズムを実装しています。`trigram` はテキストを可能なかぎりすべてのトライグラムに分割する方式で、日本語のような言語に有用です。 + +`kagome_ja` は、[`Kagome` トークナイザー](https://github.com/ikawaha/kagome?tab=readme-ov-file) と日本語 [MeCab IPA 辞書](https://github.com/ikawaha/kagome-dict/) を用いて、日本語プロパティテキストを分割します。 + +`kagome_kr` は、[`Kagome` トークナイザー](https://github.com/ikawaha/kagome?tab=readme-ov-file) と韓国語 MeCab([mecab-ko-dic](https://bitbucket.org/eunjeon/mecab-ko-dic/src/master/))辞書を用いて、韓国語プロパティテキストを分割します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/300_filters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/300_filters.mdx new file mode 100644 index 000000000..704b83422 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/300_filters.mdx @@ -0,0 +1,219 @@ +--- +title: トークナイゼーションとフィルター +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCreateCollection from '!!raw-loader!./_snippets/310_create_collection.py'; +import PyAddObjects from '!!raw-loader!./_snippets/315_add_objects.py'; +import PyFilters from '!!raw-loader!./_snippets/320_filters.py'; + +さまざまなトークナイゼーション方式について学んだので、実際に試してみましょう。このセクションでは、トークナイゼーションがフィルターにどのような影響を与えるかを確認します。 + +## 準備 + +このセクションでは、実際の Weaviate インスタンスを使い、異なるトークナイゼーション方式がフィルタリング結果に与える影響を確認します。 + +デモ用に非常に小さなカスタムデータセットを使用します。 + + + +以下の Python コードを使用して、同じデータをお手元の Weaviate インスタンスに追加できます。 + +
+ コレクション作成手順 + +複数のプロパティを持つシンプルなオブジェクトコレクションを作成します。各プロパティには同じテキストを格納しますが、トークナイゼーション方式を変えます。 + + + +ここではトークナイゼーションとフィルター(およびキーワード検索)への影響のみを確認するため、オブジェクトのベクトルは追加していません。 + +
+ +
+ オブジェクト追加手順 + +次に、テキストオブジェクトをプロパティとして繰り返し追加します。 + + + +
+ + +## フィルターへの影響 + +オブジェクトを Weaviate に追加したので、異なるトークナイゼーション方式がフィルタリングされた取得にどのような影響を与えるかを見てみましょう。 + +各フィルタークエリは次のようになります。オブジェクトを一連のクエリ文字列でフィルタリングします。 + +再利用可能な関数を用意し、クエリ文字列のセットに基づいてオブジェクトをフィルタリングします。フィルターはバイナリであり、マッチするかしないかのいずれかです。 + +関数はマッチしたオブジェクトのリストを返し、さらに結果を表示します。 + + + +### 「**Clark:**」と「**clark**」の比較 - 雑多なテキスト + +実際のテキストは句読点や大小文字の混在など、しばしば雑多です。ここでは、テレビ番組タイトル `"Lois & Clark: The New Adventures of Superman"` からさまざまな部分文字列を使ってフィルターした例を見てみましょう。 + +次の表は、クエリがタイトルにマッチしたかどうかを示しています。 + +| | `word` | `lowercase` | `whitespace` | `field` | +|---------------|--------|-------------|--------------|---------| +| `"clark"` | ✅ | ❌ | ❌ | ❌ | +| `"Clark"` | ✅ | ❌ | ❌ | ❌ | +| `"clark:" ` | ✅ | ✅ | ❌ | ❌ | +| `"Clark:" ` | ✅ | ✅ | ✅ | ❌ | +| `"lois clark"` | ✅ | ❌ | ❌ | ❌ | +| `"clark lois"` | ✅ | ❌ | ❌ | ❌ | + +
+ Python クエリ & 出力 + + + + + +
+ +コロン (`:`) を含めない限り、`word` トークナイゼーションのみが一貫してタイトルにマッチしている点に注目してください。これは `word` トークナイゼーションがコロンをセパレーターとして扱うためです。 + +ユーザーはクエリに句読点や正確な大文字小文字を含めるとは限りません。そのため、一般的なテキストフィルター用途では `word` トークナイゼーション方式が良い出発点になります。 + +### 「**A mouse**」と「**mouse**」の比較 - ストップワード + +ここでは、「computer mouse」というフレーズのバリエーションをフィルタリングし、いくつかのクエリには余分な単語を含めます。 + +結果を確認しましょう。 + +**`"computer mouse"` のマッチ結果** + +| | `word` | `lowercase` | `whitespace` | `field` | +|------------------------------|-----------|-------------|--------------|---------| +| `"computer mouse"` | ✅ | ✅ | ✅ | ✅ | +| `"a computer mouse"` | ✅ | ✅ | ✅ | ❌ | +| `"the computer mouse:" ` | ✅ | ✅ | ✅ | ❌ | +| `"blue computer mouse" ` | ❌ | ❌ | ❌ | ❌ | + +**`"a computer mouse"` のマッチ結果** + +| | `word` | `lowercase` | `whitespace` | `field` | +|------------------------------|-----------|-------------|--------------|---------| +| `"computer mouse"` | ✅ | ✅ | ✅ | ❌ | +| `"a computer mouse"` | ✅ | ✅ | ✅ | ✅ | +| `"the computer mouse:" ` | ✅ | ✅ | ✅ | ❌ | +| `"blue computer mouse" ` | ❌ | ❌ | ❌ | ❌ | + +
+ Python クエリ & 出力 + + + + + +
+ +結果からわかるように、クエリに "a" や "the" を追加しても、`field` 方式以外ではフィルター結果に影響しません。これは、各トークナイゼーション方式において "a" や "the" がストップワードとして無視されるためです。 + +`field` 方式では、"a" や "the" のようなストップワードのトークン自体が生成されません。入力 `"a computer mouse"` は `["a computer mouse"]` という 1 つのトークンにトークナイズされます。 + +ストップワードでない "blue" のような単語を追加すると、クエリはどのオブジェクトにもマッチしなくなります。 +### "**variable_name**" と "**variable name**" - 記号 + +`word` トークン化はデフォルトとしては優れています。ただし、常に最適とは限りません。ここでは `"variable_name"` のさまざまな表記でフィルターを行い、完全一致 (`"variable_name"`) のオブジェクトにマッチするかどうかを確認する例を見てみましょう。 + +| | `word` | `lowercase` | `whitespace` | `field` | +|------------------------------|-----------|-------------|--------------|---------| +| `"variable_name"` | ✅ | ✅ | ✅ | ✅ | +| `"Variable_Name:" ` | ✅ | ✅ | ❌ | ❌ | +| `"Variable Name:" ` | ✅ | ❌ | ❌ | ❌ | +| `"a_variable_name"` | ✅ | ❌ | ❌ | ❌ | +| `"the_variable_name"` | ✅ | ❌ | ❌ | ❌ | +| `"variable_new_name" ` | ✅ | ❌ | ❌ | ❌ | + +
+ Python クエリ & 出力 + + + + + +
+ +ここで期待される挙動は何でしょうか。`"variable name"` でフィルターしたとき、プロパティが `"variable_name"` であるオブジェクトにマッチすべきでしょうか。 + +では `"variable_new_name"` でフィルターした場合はどうでしょう。たとえばコードベースを検索する場合、ユーザーは `"variable_new_name"` のフィルターが `"variable_name"` にマッチするとは想定していないかもしれません。 + +このように、データにとって記号が重要な場合は、`lowercase` や `whitespace` など、記号を保持するトークン化方法の使用を検討してください。 + +## ディスカッション + +ここまでで、異なるトークン化方法がフィルターにどのように影響するかを説明しました。 + +ほとんどのフィルタリング用途では、`word` トークン化が出発点として適しています。これは大文字・小文字を区別せず、ほとんどの記号を区切り文字として扱います。 + +しかし、記号がデータにとって重要な場合や、大文字・小文字を区別する必要がある場合には、別のトークン化方法を検討すると良いでしょう。 + +それでは `field` トークン化はどうでしょうか。この方法は、テキスト全体を 1 つのトークンとして扱う必要がある場合に最も有用です。メールアドレス、 URL、識別子などのプロパティに適しています。 + +`field` トークン化を用いた典型的なフィルタリング戦略には、完全一致やワイルドカードを用いた部分一致があります。ただし、ワイルドカードベースのフィルターは計算コストが高い(遅い)場合があるため、慎重に使用してください。 + +次に、トークン化がキーワード検索にどのように影響するかについて説明します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/400_searches.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/400_searches.mdx new file mode 100644 index 000000000..cc7d7cd8e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/400_searches.mdx @@ -0,0 +1,192 @@ +--- +title: トークン化と検索 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PySearches from '!!raw-loader!./_snippets/400_searches.py'; + +前のセクションでは、[トークン化がフィルターに与える影響](./300_filters.mdx)をご覧いただきました。トークン化はキーワード検索にも似たように、しかし同一ではない形で影響します。このセクションでは、異なるトークン化方式が検索結果にどのような影響を及ぼすかを見ていきます。 + +:::info ハイブリッド検索の場合は? +ハイブリッド検索は、キーワード検索と ベクトル 検索の結果を組み合わせます。そのため、トークン化はハイブリッド検索のキーワード検索部分にのみ影響し、 ベクトル 検索部分には影響しません。 + +本コースではハイブリッド検索を個別には扱いませんが、ここで説明するキーワード検索への影響は、ハイブリッド検索のキーワード検索部分にも当てはまります。 +::: + +## キーワード検索への影響 + +### キーワード検索におけるトークン化の影響 + +前のセクションと同様の方法を使いますが、今回はフィルターではなくキーワード検索を実行します。 + +キーワード検索は [BM25f アルゴリズム](https://en.wikipedia.org/wiki/Okapi_BM25)で結果を順位付けします。そのため、トークン化がキーワード検索に与える影響は二重です。 + +1. まず、トークン化は結果が検索結果に含まれるかどうかを決定します。検索クエリ内のトークンがオブジェクト内のトークンとまったく一致しない場合、そのオブジェクトは検索結果に含まれません。 +2. 次に、トークン化は検索結果の順位に影響します。BM25f アルゴリズムは一致するトークンの数を考慮するため、どのトークンが一致対象となるかを決めるトークン化方式がランキングに影響します。 + +### 検索セットアップ + +各キーワードクエリは以下のようになります。 + +再利用可能な関数を作成し、キーワード検索を実行してスコア付きの上位結果を表示します。 + + + +### 例 + +#### 「**Clark:**」 vs 「**clark**」 - 不揃いなテキスト + +キーワード検索もフィルターと同様にトークン化の影響を受けますが、微妙な違いがあります。 + +ここでは、TV 番組タイトル「Lois & Clark: The New Adventures of Superman」からさまざまな部分文字列を検索した例を示します。 + +以下の表は、クエリがタイトルに一致したかどうかと、そのスコアを示しています。 + +| | `word` | `lowercase` | `whitespace` | `field` | +|---------------|--------|-------------|--------------|---------| +| `"clark"` | 0.613 | ❌ | ❌ | ❌ | +| `"Clark"` | 0.613 | ❌ | ❌ | ❌ | +| `"clark:" ` | 0.613 | 0.48 | ❌ | ❌ | +| `"Clark:" ` | 0.613 | 0.48 | 0.48 | ❌ | +| `"lois clark"` | 1.226 | 0.48 | ❌ | ❌ | +| `"clark lois"` | 1.226 | 0.48 | ❌ | ❌ | + +
+ Python query & output + + + + + +
+ +ここではフィルターの例と同じオブジェクトが返されていますが、スコアに違いがある点に注目してください。 + +たとえば、`"lois clark"` の検索は `"clark"` の検索よりも高いスコアを返します。これは BM25f アルゴリズムが一致トークンの数を考慮するためであり、検索クエリにできるだけ多くの一致トークンを含めると有利になるためです。 + +もう一つの違いは、キーワード検索ではクエリ内のトークンのいずれかが一致すればオブジェクトが返されることです。フィルターの場合は演算子によって挙動が変わり、たとえば `"Equal"`、`"ContainsAny"`、`"ContainsAll"` などを使い分ける必要があります。 + +次のセクションではこれを示し、ストップワードがどのように扱われるかも説明します。 + +#### 「**A mouse**」 vs 「**mouse**」 - ストップワード + +ここでは、「computer mouse」というフレーズの変形を検索し、一部のクエリに追加の単語を含めています。 + +では、結果を見てみましょう。 + +**`"computer mouse"` に対するマッチ** + +| | `word` | `lowercase` | `whitespace` | `field` | +|------------------------------|-----------|-------------|--------------|---------| +| `"computer mouse"` | 0.889 | 0.819 | 1.01 | 0.982 | +| `"Computer Mouse"` | 0.889 | 0.819 | ❌ | ❌ | +| `"a computer mouse"` | 0.764 | 0.764 | 0.849 | ❌ | +| `"computer mouse pad" ` | 0.764 | 0.764 | 0.849 | ❌ | + +**`"a computer mouse"` に対するマッチ** + +| | `word` | `lowercase` | `whitespace` | `field` | +|------------------------------|-----------|-------------|--------------|---------| +| `"computer mouse"` | 0.889 | 0.819 | 1.01 | ❌ | +| `"Computer Mouse"` | 0.889 | 0.819 | ❌ | ❌ | +| `"a computer mouse"` | 0.764 | 1.552 | 1.712 | 0.982 | +| `"computer mouse pad" ` | 0.764 | 0.688 | 0.849 | ❌ | + +
+ Python query & output + + + + + +
+ +結果はフィルターの例と似ていますが、より微妙で興味深い違いがあります。 + +`word` トークン化では、`computer mouse` の検索結果は `a computer mouse` の検索結果と同一になります。これはストップワード `a` が検索では考慮されないためです。 + +しかし、`"computer mouse"` と `"a computer mouse"` のようにストップワードだけが異なるオブジェクトでもスコアが異なる点に注目してください。これは BM25f アルゴリズムが[ストップワードをインデックスする](../../../weaviate/config-refs/indexing/inverted-index.mdx#stopwords)ためで、スコアには影響があります。 + +ユーザーとしてはこの点を念頭に置き、コレクション定義でストップワードを設定して希望の挙動に合わせることが可能です。 + +また、`lowercase` と `whitespace` のトークン化方式では、クエリ内のストップワードは削除されません。 + +この挙動により、ストップワードを明示的に検索クエリに含めたいユーザーも対応可能です。 +#### 「**variable_name**」と「**variable name**」 − 記号 + +以下のテーブルは、文字列 `variable_name` を使用した keyword 検索の結果と、それに対応するスコアを示しています。 + +| | `word` | `lowercase` | `whitespace` | `field` | +|------------------------------|-----------|-------------|--------------|---------| +| `"variable_name"` | 0.716 | 0.97 | 1.27 | 0.982 | +| `"Variable_Name:" ` | 0.716 | 0.97 | ❌ | ❌ | +| `"Variable Name:" ` | 0.716 | ❌ | ❌ | ❌ | +| `"a_variable_name"` | 0.615 | ❌ | ❌ | ❌ | +| `"the_variable_name"` | 0.615 | ❌ | ❌ | ❌ | +| `"variable_new_name" ` | 0.615 | ❌ | ❌ | ❌ | + +
+ Python query & output + + + + + +
+ +これらの結果は、フィルターの例と同様です。検索で重要となる記号がデータに含まれている場合は、`lowercase` や `whitespace` など、記号を保持する tokenization 方法の使用を検討してください。 + +### 議論 + +keyword 検索と tokenization については以上です。フィルターの場合と同様に、どの tokenization 方法を選択するかは、検索戦略全体の大きな要素となります。 + +keyword 検索における tokenization の一般的なアドバイスは、[フィルターの場合](./300_filters.mdx#-discussions)と似ています。まずは `word` を使用し、データ内で記号や大文字・小文字が重要な情報を持つ場合は `lowercase` や `whitespace` などを検討してください。 + +`field` tokenization は非常に厳格で、完全に一致する文字列が同じ順序で存在しないオブジェクトはヒットしないため、keyword 検索には適さない場合があります。 + +また、keyword 検索は順位付きの結果を返します。そのため、tokenization は結果の集合だけでなく、その集合内での順位にも影響します。 + +これらの点を踏まえ、データとユーザーのニーズに最適な tokenization 戦略を設定してください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/900_next_steps.mdx new file mode 100644 index 000000000..e3e0b10b6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/900_next_steps.mdx @@ -0,0 +1,30 @@ +--- +title: 次のステップ +--- + +おめでとうございます! 転置インデックス向けトークン化に関するこのコースを修了しました。 役に立ち、有益であったことを願っています。 + +学習を続けるためのリソースは、まだたくさんあります。 + +## ドキュメント + +- [リファレンス: 設定: トークン化](/weaviate/config-refs/collections.mdx#tokenization) +- [リファレンス: 設定: ストップワード](/weaviate/config-refs/indexing/inverted-index.mdx#stopwords) +- [概念: 転置インデックス](/weaviate/concepts/indexing/inverted-index.md) +- [概念: フィルタリング](/weaviate/concepts/filtering.md) + +:::note +念のためお伝えすると、特に単語間にスペースが入らない言語などの英語以外のテキストには、そのようなケース向けに Weaviate v1.24 で追加された `trigram` や `gse` のトークン化方式をお試しください。 +::: + +import CTASocials from '../_snippets/cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/310_create_collection.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/310_create_collection.py new file mode 100644 index 000000000..d5d616271 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/310_create_collection.py @@ -0,0 +1,44 @@ +# CreateDemoCollection +import weaviate +from weaviate.classes.config import Property, DataType, Tokenization, Configure + +# END CreateDemoCollection + +client = weaviate.connect_to_local() + +# CreateDemoCollection +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local() + +# END CreateDemoCollection + +client.collections.delete("TokenizationDemo") + +# CreateDemoCollection +tkn_options = [ + Tokenization.WORD, + Tokenization.LOWERCASE, + Tokenization.WHITESPACE, + Tokenization.FIELD, +] + +# Create a property for each tokenization option +properties = [] +for tokenization in tkn_options: + prop = Property( + name=f"text_{tokenization.replace('.', '_')}", + data_type=DataType.TEXT, + tokenization=tokenization + ) + properties.append(prop) + + +client.collections.create( + name="TokenizationDemo", + properties=properties, + vector_config=Configure.Vectors.self_provided() +) + +client.close() +# END CreateDemoCollection diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/315_add_objects.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/315_add_objects.py new file mode 100644 index 000000000..a1da9155d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/315_add_objects.py @@ -0,0 +1,55 @@ +# AddObjects +import weaviate + +# END AddObjects + +client = weaviate.connect_to_local() + +# AddObjects +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local() + +# END AddObjects + +# AddObjects # StringsToAdd +collection = client.collections.use("TokenizationDemo") + +# END AddObjects # END StringsToAdd +# AddObjects +# Get property names +property_names = [p.name for p in collection.config.get().properties] + +# AddObjects # StringsToAdd +phrases = [ + # string with special characters + "Lois & Clark: The New Adventures of Superman", + + # strings with stopwords & varying orders + "computer mouse", + "Computer Mouse", + "mouse computer", + "computer mouse pad", + "a computer mouse", + + # strings without spaces + "variable_name", + "Variable_Name", + "Variable Name", + "a_variable_name", + "the_variable_name", + "variable_new_name", +] +# END AddObjects # END StringsToAdd + +# AddObjects + +for phrase in phrases: + obj_properties = {} + for property_name in property_names: + obj_properties[property_name] = phrase + print(obj_properties) + collection.data.insert(properties=obj_properties) + +client.close() +# END AddObjects diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/320_filters.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/320_filters.py new file mode 100644 index 000000000..f07a67656 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/320_filters.py @@ -0,0 +1,210 @@ +# FilterExampleBasic +import weaviate +from weaviate.classes.query import Filter +from weaviate.collections import Collection +from typing import List + +# END FilterExampleBasic + +client = weaviate.connect_to_local() + +# FilterExampleBasic +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local() + +# END FilterExampleBasic + +# FilterExampleBasic +collection = client.collections.use("TokenizationDemo") + +# END FilterExampleBasic + + +# FilterExampleBasic +# Get property names +property_names = list() +for p in collection.config.get().properties: + property_names.append(p.name) + +query_strings = [""] + + +def filter_demo(collection: Collection, property_names: List[str], query_strings: List[str]): + from weaviate.classes.query import Filter + + for query_string in query_strings: + print("\n" + "=" * 40 + f"\nHits for: '{query_string}'" + "\n" + "=" * 40) + for property_name in property_names: + # highlight-start + response = collection.query.fetch_objects( + filters=Filter.by_property(property_name).equal(query_string), + ) + # highlight-end + if len(response.objects) > 0: + print(f">> '{property_name}' matches") + for obj in response.objects: + print(obj.properties[property_name]) + + +filter_demo(collection, property_names, query_strings) +# END FilterExampleBasic + +client.connect() + +# ClarkExample +filter_demo(collection, property_names, ["clark", "Clark", "clark:", "Clark:", "lois clark", "clark lois"]) +# END ClarkExample + +""" +# ClarkResults +======================================== +Hits for: 'clark' +======================================== +>> 'text_word' matches +Lois & Clark: The New Adventures of Superman + +======================================== +Hits for: 'Clark' +======================================== +>> 'text_word' matches +Lois & Clark: The New Adventures of Superman + +======================================== +Hits for: 'clark:' +======================================== +>> 'text_word' matches +Lois & Clark: The New Adventures of Superman +>> 'text_lowercase' matches +Lois & Clark: The New Adventures of Superman + +======================================== +Hits for: 'Clark:' +======================================== +>> 'text_word' matches +Lois & Clark: The New Adventures of Superman +>> 'text_lowercase' matches +Lois & Clark: The New Adventures of Superman +>> 'text_whitespace' matches +Lois & Clark: The New Adventures of Superman + +======================================== +Hits for: 'lois clark' +======================================== +>> 'text_word' matches +Lois & Clark: The New Adventures of Superman + +======================================== +Hits for: 'clark lois' +======================================== +>> 'text_word' matches +Lois & Clark: The New Adventures of Superman +# END ClarkResults +""" + +# MouseExample +filter_demo(collection, property_names, ["computer mouse", "a computer mouse", "the computer mouse", "blue computer mouse"]) +# END MouseExample + +""" +# MouseResults +======================================== +Hits for: 'computer mouse' +======================================== +>> 'text_word' matches +computer mouse +Computer Mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_lowercase' matches +computer mouse +Computer Mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_whitespace' matches +computer mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_field' matches +computer mouse + +======================================== +Hits for: 'a computer mouse' +======================================== +>> 'text_word' matches +computer mouse +Computer Mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_lowercase' matches +computer mouse +Computer Mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_whitespace' matches +computer mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_field' matches +a computer mouse + +======================================== +Hits for: 'the computer mouse' +======================================== +>> 'text_word' matches +computer mouse +Computer Mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_lowercase' matches +computer mouse +Computer Mouse +mouse computer +computer mouse pad +a computer mouse +>> 'text_whitespace' matches +computer mouse +mouse computer +computer mouse pad +a computer mouse + +======================================== +Hits for: 'blue computer mouse' +======================================== +# END MouseResults +""" + +# UnderscoreExample +filter_demo(collection, property_names, ["variable_name"]) +# END UnderscoreExample + +""" +# UnderscoreResults +======================================== +Hits for: 'variable_name' +======================================== +>> 'text_word' matches +variable_name +Variable_Name +Variable Name +a_variable_name +the_variable_name +variable_new_name +>> 'text_lowercase' matches +variable_name +Variable_Name +>> 'text_whitespace' matches +variable_name +>> 'text_field' matches +variable_name +# END UnderscoreResults +""" + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/400_searches.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/400_searches.py new file mode 100644 index 000000000..bb3d1ac7d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/_snippets/400_searches.py @@ -0,0 +1,234 @@ +# FilterExampleBasic +import weaviate +from weaviate.classes.query import MetadataQuery +from weaviate.collections import Collection +from typing import List + +# END FilterExampleBasic + +client = weaviate.connect_to_local() + +# FilterExampleBasic +# Instantiate your client (not shown). e.g.: +# client = weaviate.connect_to_weaviate_cloud(...) or +# client = weaviate.connect_to_local() + +# END FilterExampleBasic + +# FilterExampleBasic +collection = client.collections.use("TokenizationDemo") + +# END FilterExampleBasic + + +# FilterExampleBasic +# Get property names +property_names = list() +for p in collection.config.get().properties: + property_names.append(p.name) + +query_strings = [""] + + +def search_demo(collection: Collection, property_names: List[str], query_strings: List[str]): + from weaviate.classes.query import MetadataQuery + + for query_string in query_strings: + print("\n" + "=" * 40 + f"\nBM25 search results for: '{query_string}'" + "\n" + "=" * 40) + for property_name in property_names: + # highlight-start + response = collection.query.bm25( + query=query_string, + return_metadata=MetadataQuery(score=True), + query_properties=[property_name] + ) + # highlight-end + if len(response.objects) > 0: + print(f">> '{property_name}' search results") + for obj in response.objects: + print(obj.properties[property_name], round(obj.metadata.score, 3)) + + +search_demo(collection, property_names, query_strings) +# END FilterExampleBasic + +client.connect() + +# ClarkExample +search_demo(collection, property_names, ["clark", "Clark", "clark:", "Clark:", "lois clark", "clark lois"]) +# END ClarkExample + +""" +# ClarkResults +======================================== +BM25 search results for: 'clark' +======================================== +>> 'text_word' search results +Lois & Clark: The New Adventures of Superman 0.613 + +======================================== +BM25 search results for: 'Clark' +======================================== +>> 'text_word' search results +Lois & Clark: The New Adventures of Superman 0.613 + +======================================== +BM25 search results for: 'clark:' +======================================== +>> 'text_word' search results +Lois & Clark: The New Adventures of Superman 0.613 +>> 'text_lowercase' search results +Lois & Clark: The New Adventures of Superman 0.48 + +======================================== +BM25 search results for: 'Clark:' +======================================== +>> 'text_word' search results +Lois & Clark: The New Adventures of Superman 0.613 +>> 'text_lowercase' search results +Lois & Clark: The New Adventures of Superman 0.48 +>> 'text_whitespace' search results +Lois & Clark: The New Adventures of Superman 0.48 + +======================================== +BM25 search results for: 'lois clark' +======================================== +>> 'text_word' search results +Lois & Clark: The New Adventures of Superman 1.226 +>> 'text_lowercase' search results +Lois & Clark: The New Adventures of Superman 0.48 + +======================================== +BM25 search results for: 'clark lois' +======================================== +>> 'text_word' search results +Lois & Clark: The New Adventures of Superman 1.226 +>> 'text_lowercase' search results +Lois & Clark: The New Adventures of Superman 0.48 +# END ClarkResults +""" + +# MouseExample +search_demo(collection, property_names, ["computer mouse", "a computer mouse", "the computer mouse", "blue computer mouse"]) +# END MouseExample + +""" +# MouseResults +======================================== +BM25 search results for: 'computer mouse' +======================================== +>> 'text_word' search results +mouse computer 0.889 +Computer Mouse 0.889 +computer mouse 0.889 +a computer mouse 0.764 +computer mouse pad 0.764 +>> 'text_lowercase' search results +mouse computer 0.819 +Computer Mouse 0.819 +computer mouse 0.819 +a computer mouse 0.688 +computer mouse pad 0.688 +>> 'text_whitespace' search results +mouse computer 1.01 +computer mouse 1.01 +a computer mouse 0.849 +computer mouse pad 0.849 +>> 'text_field' search results +computer mouse 0.982 + +======================================== +BM25 search results for: 'a computer mouse' +======================================== +>> 'text_word' search results +mouse computer 0.889 +Computer Mouse 0.889 +computer mouse 0.889 +a computer mouse 0.764 +computer mouse pad 0.764 +>> 'text_lowercase' search results +a computer mouse 1.552 +mouse computer 0.819 +Computer Mouse 0.819 +computer mouse 0.819 +computer mouse pad 0.688 +>> 'text_whitespace' search results +a computer mouse 1.712 +mouse computer 1.01 +computer mouse 1.01 +computer mouse pad 0.849 +>> 'text_field' search results +a computer mouse 0.982 + +======================================== +BM25 search results for: 'the computer mouse' +======================================== +>> 'text_word' search results +mouse computer 0.889 +Computer Mouse 0.889 +computer mouse 0.889 +a computer mouse 0.764 +computer mouse pad 0.764 +>> 'text_lowercase' search results +mouse computer 0.819 +Computer Mouse 0.819 +computer mouse 0.819 +a computer mouse 0.688 +computer mouse pad 0.688 +Lois & Clark: The New Adventures of Superman 0.48 +>> 'text_whitespace' search results +mouse computer 1.01 +computer mouse 1.01 +a computer mouse 0.849 +computer mouse pad 0.849 + +======================================== +BM25 search results for: 'blue computer mouse' +======================================== +>> 'text_word' search results +mouse computer 0.889 +Computer Mouse 0.889 +computer mouse 0.889 +a computer mouse 0.764 +computer mouse pad 0.764 +>> 'text_lowercase' search results +mouse computer 0.819 +Computer Mouse 0.819 +computer mouse 0.819 +a computer mouse 0.688 +computer mouse pad 0.688 +>> 'text_whitespace' search results +mouse computer 1.01 +computer mouse 1.01 +a computer mouse 0.849 +computer mouse pad 0.849 +# END MouseResults +""" + +# UnderscoreExample +search_demo(collection, property_names, ["variable_name"]) +# END UnderscoreExample + +""" +# UnderscoreResults +======================================== +BM25 search results for: 'variable_name' +======================================== +>> 'text_word' search results +Variable Name 0.716 +Variable_Name 0.716 +variable_name 0.716 +variable_new_name 0.615 +the_variable_name 0.615 +a_variable_name 0.615 +>> 'text_lowercase' search results +Variable_Name 0.97 +variable_name 0.97 +>> 'text_whitespace' search results +variable_name 1.27 +>> 'text_field' search results +variable_name 0.982 +# END UnderscoreResults +""" + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/index.md new file mode 100644 index 000000000..771c9f826 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/tokenization/index.md @@ -0,0 +1,29 @@ +--- +title: "275 (キーワード)トークナイゼーション" +description: "Weaviate におけるトークナイゼーションを深く学び、テキスト検索の精度を向上させます。" +sidebar_position: 275 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js'; + +## コース概要 + +:::info 前提条件 +このコースは単体で完結しています。ただし、[テキスト](../starter_text_data/index.md)、[独自ベクトル](../starter_custom_vectors/index.md)、または[マルチモーダル データ](../starter_multimodal_data/index.md)を扱う 101 レベルのいずれかのコースを先に受講することをおすすめします。 +::: + +このコースではトークナイゼーションと Weaviate の関係について紹介します。具体的には、トークナイゼーションとは何か、検索との関係、そして設定方法を説明します。 + +トークナイゼーションはキーワード検索とフィルタリングだけでなく、言語モデルの文脈にも関連する概念であることに注意してください。 + +**本コースはキーワードの側面に焦点を当てます** が、トークナイゼーションが言語モデルに与える影響についても簡単に触れます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/100_overview.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/100_overview.mdx new file mode 100644 index 000000000..3ef8c2ff9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/100_overview.mdx @@ -0,0 +1,94 @@ +--- +title: "ベクトルインデックス:概要" +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +データベースインデックスとは、検索を効率化するためにデータを整理するデータ構造です。本の目次や図書館の索引のように、必要な情報を素早く見つけられるようにします。 + +
+ Card catalog from page 167 of 'Manual of library classification and shelf arrangement' (1898) +
+ +[ベクトルインデックス](/weaviate/concepts/indexing/vector-index.md) は、ベクトルを保存し検索するために特化したインデックスです。 + +ベクトルインデックスの選択と設定は、インポートや検索のパフォーマンス、そして Weaviate インスタンスのリソース要件に大きく影響します。 + +そのため、ベクトルインデックスは Weaviate における重要なコンポーネントです。 + +## ベクトルインデックスの利点 + +データベースは急速に巨大化するため、特定の項目を検索する時間が許容できないほど長くなったり、検索に必要なリソースが過剰になったりすることがあります。 + +ベクトルインデックスは、大規模データベースでの検索体験を向上させるために設計されています。 + +通常、検索速度・精度・リソース要件という 3 つの要素をバランスするためにトレードオフを行います。 + +## ベクトルインデックスの種類 + +ベクトルインデックスには多くの種類があります。大半は比較すべきベクトル数を減らすことで検索を高速化しますが、その手法はさまざまで、それぞれに長所と短所があります。 + +### グラフインデックス + +グラフインデックスはベクトル間にネットワークを形成し、類似したベクトル同士を接続します。これにより、クエリベクトルに近いベクトルをグラフ上で高速に「トラバース」して見つけられます。 + +import HNSWDiagram from './_snippets/hnsw_diagram.png'; + +
+ Outline of HNSW graph, showing nodes connected in multiple layers +
+ +HNSW(Hierarchical Navigable Small World)は、最も一般的なグラフインデックスタイプです。複数の「レイヤー」にベクトルを配置し、グラフを高速に横断できるようにします。 + +HNSW はスケーラビリティに優れ、インクリメンタル更新が可能で、高次元ベクトルにも効率的です。 + +これは Weaviate のデフォルトインデックスタイプです。 + +### ツリーインデックス + +ツリーインデックスはベクトルをツリー構造に分割します。 + +
+ Complete binary tree (Wikipedia) +
+ +ANNOY(Approximate Nearest Neighbors Oh Yeah)は代表的なツリーインデックスで、ベクトルを二分木に分割します。 + +メモリ効率が高く、低次元ベクトルに適しています。 + +ツリーの特性上、時間とともにインデックスを更新するコストが高くなる場合があります。これはツリーを再構築する必要があるか、インクリメンタルに更新できるかによります。 + +ANNOY 自体はインクリメンタル更新をサポートしていません。 + +### クラスタインデックス + +クラスタインデックスはベクトルを類似度に基づいてグループ化します。その結果、検索空間は最も近傍が存在する可能性が高いクラスタのみに絞られます。 + +検索精度(リコール・適合率)はグラフインデックスより低い傾向がありますが、メモリ効率に優れています。 + +### フラットインデックス + +フラットインデックスは最も単純なインデックスで、すべてのベクトルを 1 つのリストに保存し、全件を走査して最近傍を探します。 + +メモリ効率は非常に高いものの、検索時間はベクトル数に比例して線形に増加するため、スケールは困難です。 + +### Weaviate で利用可能なベクトルインデックス + +Weaviate は `hnsw`、`flat`、`dynamic` の複数のベクトルインデックスタイプをサポートしています。 + +詳細は次のセクションで説明します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/200_hnsw.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/200_hnsw.mdx new file mode 100644 index 000000000..ee3d5f415 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/200_hnsw.mdx @@ -0,0 +1,192 @@ +--- +title: HNSW インデックスの詳細 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +HNSW(「Hierarchical Navigable Small World」)は、高次元の ベクトル を高速かつ高精度に検索できる強力で柔軟な ベクトル インデックス タイプです。 + +検索速度・精度・リソース要件のトレードオフを調整できる一方で、高いスケーラビリティを備えている点も大きな利点です。 + +HNSW は Weaviate のデフォルト インデックス タイプで、どのインデックス タイプを使用するか迷った場合は、まず HNSW から始めることをおすすめします。 + +## 主なアイデア + +HNSW は、グラフを高速に大域的トラバーサルしつつ類似 ベクトル を正確に検索できるよう、 ベクトル 間に接続を作成することに主眼を置いています。 + +具体的には複数のレイヤーを作成し、上位レイヤーほど下位レイヤーの ベクトル をサブセットとして保持します。レイヤーを上がるにつれグラフの大まかな位置を特定する処理が高速になり、位置が定まった後は下位レイヤーへ下りながらよりローカルな検索を行います。 + +最終的には、すべての ベクトル が含まれる最下層に到達します。 + +import HNSWDiagram from './_snippets/hnsw_diagram.png'; + +
+ Outline of HNSW graph, showing nodes connected in multiple layers +
+ +この方法により、検索はまずグラフの適切な領域を素早く特定し、その後最下層で網羅的な検索を実行できます。 + +直感的には、HNSW グラフは高次元版のスキップリストのように捉えられます。上位レイヤーで大域検索を、下位レイヤーでローカル検索を行うイメージです。 + +### トレードオフ + +HNSW は非常に柔軟で、幅広いトレードオフを実現できます。 + +検索速度・精度・リソース要件のバランスは、HNSW のパラメーター調整や [ ベクトル の量子化](../compression/index.md) によって最適化できます。 + +### リソース要件 + +HNSW はインメモリ インデックスであり、グラフ内の各ノードとエッジはすべてメモリに保持されます。 + +したがって、インデックスのメモリサイズは ベクトル 数と ベクトル 間の接続数にほぼ比例します。 + +HNSW インデックスのサイズは ベクトル 数が支配的です。以下の表は一例です。 + +| コンポーネント | サイズ算出 | 典型的サイズ | サイズ @1M ベクトル | サイズ @100M ベクトル | +| --- | --- | --- | --- | --- | +| Node | 4B (float) × N dimensions | 2-12 kB | 2-12 GB | 200-1200 GB | +| Edge | 10B × 20 connections | 200 B | 200 MB | 20 GB | + +ご覧のように、HNSW インデックスのメモリ要件は急速にボトルネックになり得ます。その際は [量子化](../compression/index.md) を用いてメモリサイズを削減できます。 + +### 距離メトリック + +![Vector Distance Calculations](./img/vector_distance.png) + +インデックスで使用する距離メトリックは、 ベクトル 間の距離計算方法を決定します。HNSW では、これが各 ベクトル のグラフ上の配置に影響します。 + +コレクション内の ベクトル に適したメトリックを選択してください。判断には、 ベクトル を生成したモデルのドキュメントを参照します。 + +Weaviate のデフォルトは cosine ですが、[他にも多数のメトリック](/weaviate/config-refs/distances.md) が利用可能です。 + +迷った場合は、多くのモデルで採用されている cosine 距離が堅牢なデフォルトとして推奨されます。 + +### HNSW をインデックス タイプとして指定 + +HNSW は Weaviate のデフォルト ベクトル インデックス タイプです。そのため、コレクションで特定のインデックス タイプを指定しなければ HNSW が使用されます。 + +明示的に指定したい場合は、以下のように設定します。 + + + +## HNSW のチューニング + +HNSW インデックスは、検索速度・精度・リソース要件のトレードオフを調整するためにチューニングできます。 + +主に調整する項目は次のとおりです。 +- ノード間の接続数 +- 「ダイナミックリスト」のサイズ +- 量子化 + +### 接続数 + +import maxConnectionsDiagram from './_snippets/maxConnections.png'; + +
+ Outline of HNSW graph, highlighting connections +
+ +ノード間の最大接続数(`maxConnections`)は、グラフの密結合度を決定します。 + +接続数が多いほど検索精度は向上しますが、検索速度が低下し、メモリ使用量も増加します。 + +デフォルト値は `32` です。最下層では各ノードが最大で `2 * maxConnections` 本の接続を持つ点に注意してください。 + +### ダイナミックリストのサイズ + +HNSW における「ダイナミックリスト」とは、アルゴリズムが検討対象とするノードの一覧を指します。ダイナミックリストは二つの場面で使用されます。 + +検索時には、リストで検討中のノードを追跡し、検索が網羅的になるようにします。 + +インデックス構築時には、接続候補となるノードを保持し、HNSW アルゴリズムが `maxConnections` 本の最適な接続を選定します。この際は近接度だけでなく、グラフ全体の接続性も考慮されます。 + +#### 検索用ダイナミックリストサイズ + +import EfDiagram from './_snippets/ef.png'; + +
+ Outline of HNSW graph, with a hypothetical dynamic list +
+ +検索時のダイナミックリストサイズは、静的または動的に設定できます。 + +静的に設定する場合は、コレクション作成時に `ef` パラメーターを指定します。デフォルトは `-1` で、この値は動的設定に委ねることを意味します。 + +動的に設定する場合は、`dynamicEfMin`、`dynamicEfMax`、`dynamicEfFactor` を組み合わせて指定します。 + +ダイナミックリストサイズは、クエリの limit × `dynamicEfFactor` を基準として、最小値 `dynamicEfMin`、最大値 `dynamicEfMax` によって制限されます。 + +コードで表すと次のようになります。 + +```python +ef = min(max(dynamicEfMin, queryLimit * dynamicEfFactor), dynamicEfMax) +``` + +デフォルト値は `dynamicEfMin = 100`、`dynamicEfMax = 500`、`dynamicEfFactor = 8` です。 +#### インデックス構築時の動的リストサイズ + +import EfConstructionDiagram from './_snippets/efConstruction.png'; + +
+ Outline of HNSW graph, with a note for Ef +
+ +インデックス構築時の動的リストサイズを設定するには、コレクション作成時に `efConstruction` パラメーターを指定します。 + +これにより検索パフォーマンスが向上しますが、インデックス構築処理に負荷がかかります。デフォルト値は `128` です。 + +### 量子化 + +HNSW で量子化を有効にすると、圧縮された ベクトル を使用することでメモリ上のインデックスサイズを削減できます。なお、完全な ベクトル はディスクに保存されており、インデックスから取得後の再スコアリングに使用されます。 + +これは特に大量の ベクトル を扱う場合、Weaviate インスタンスのメモリ要件を大幅に削減する強力な方法となります。 + +量子化の詳細は [Weaviate Academy のコース](../compression/index.md) で学習できます。 + +## Weaviate で HNSW を設定する + +これらの各パラメーターは、Weaviate でコレクションを作成する際に指定できます。なお、ここで取り上げたパラメーターのうち、変更可能なのは `dynamicEf` 関連のパラメーターのみです。 + +### コード例 + + + +### 追加オプション + +Weaviate では、さらに高度な HNSW パラメーターを設定できます。一般的なユースケースでは不要ですが、特定の状況で役立つ場合があります。 + +#### コレクションレベルのパラメーター + +- `cleanup_interval_seconds`: 削除済みノードのクリーンアップ処理を実行する間隔を設定します。 +- `flat_search_cutoff`: この数値より小さい場合は HNSW インデックスではなく総当たり検索を使用します。 +- `vector_cache_max_objects`: メモリにキャッシュできる ベクトル の最大数を設定します。 + +#### 環境変数 + +- `PERSISTENCE_HNSW_MAX_LOG_SIZE`: HNSW の [write-ahead-log](/weaviate/concepts/storage.md#hnsw-vector-index-storage) の最大サイズです。値を大きくするとログ圧縮の効率が向上し、小さくするとメモリ要件を削減できます。 + +## 追加リソース + +- [コンセプト: ベクトルインデックス](/weaviate/concepts/indexing/vector-index.md) +- [リファレンス: ベクトルインデックスのパラメーター](/weaviate/config-refs/indexing/vector-index.mdx) +- [コレクションを管理する方法](../../../weaviate/manage-collections/index.mdx) +- [Weaviate Academy: 圧縮](../compression/index.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/220_flat.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/220_flat.mdx new file mode 100644 index 000000000..91d256182 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/220_flat.mdx @@ -0,0 +1,74 @@ +--- +title: フラット インデックスの詳細 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +「flat」インデックスは、シンプルで効率的な ベクトル インデックスの一種で、小規模な ベクトル コレクションに最適です。 + +## 主なポイント + +flat インデックスは「マップ」データ型を模倣した、非常にシンプルな ベクトル インデックスです。各 ベクトル の位置のみを保持し、検索時にはクエリ ベクトル とコレクション内の各 ベクトル を比較します。予想どおり、必要リソースは非常に少なくて済みますが、 ベクトル 数が増えるにつれて検索速度が低下します。 + +このインデックスが力を発揮するのは、多数の小規模コレクションが存在する大規模ユースケースです。たとえばマルチテナント環境で各エンドユーザーごとに 1 つのコレクションを持つ場合です。典型例としてはメモアプリがあり、各エンドユーザーが自分専用のメモコレクションを持つ、といったケースです。 + +このような環境では、各エンドユーザーがマルチテナント コレクション内の「テナント」として扱われ、それぞれが独立した ベクトル インデックスを持ちます。flat インデックスはまさにこのユースケースに最適です。 + +### トレードオフ + +flat インデックスの最大の妥協点はスケーラビリティがないことです。コレクション内の ベクトル 数が増えると、それに比例して検索時間も線形に増加します。これは各 ベクトル をクエリ ベクトル と比較する必要があるためです。 + +### リソース要件 + +flat インデックスは、 ベクトル 自体ではなくその位置のみを保存するため、必要なメモリは非常に少なくて済みます。 + +特にデータベース全体が成長しても、その成長が各インデックス(テナント)の数によるもので、各インデックス内の ベクトル 数が少ない場合には大きなメリットがあります。 + +### 距離メトリック + +![Vector Distance Calculations](./img/vector_distance.png) + +インデックスで使用する距離メトリックは、 ベクトル 間の距離をどのように計算するかを決定します。 + +コレクション内の ベクトル に合ったメトリックを選択する必要があります。適切なメトリックを知るには、 ベクトル を生成したモデルのドキュメントを参照してください。 + +Weaviate のデフォルトメトリックは cosine ですが、[他にもさまざまなメトリック](/weaviate/config-refs/distances.md) を利用できます。 + +迷った場合は、多くのモデルで採用されている cosine 距離が堅牢なデフォルト選択肢となります。 + +### 量子化 + +flat インデックスで量子化を有効にすると、圧縮済み ベクトル を用いて検索時間を短縮できます。なお、完全な ベクトル も保存されており、初回検索後の再スコアリングに使用されます。 + +これにより、 ベクトル 数が増えるにつれて線形に増加する検索時間をある程度緩和できます。ただし、flat インデックスのスケーラビリティの限界自体は変わりません。 + +量子化について詳しくは [Weaviate Academy のコース](../compression/index.md) をご覧ください。 + +## Weaviate でフラット インデックスを設定する + +これらの各パラメータは、Weaviate でコレクションを作成する際に指定できます。`vector_cache_max_objects` は、量子化を有効にし、その内部で ベクトル キャッシュを有効にした場合にのみ使用されます。 + +### コード例 + + + +## さらに詳しく + +- [コンセプト: ベクトル インデックス](/weaviate/concepts/indexing/vector-index.md) +- [リファレンス: ベクトル インデックスのパラメータ](/weaviate/config-refs/indexing/vector-index.mdx) +- [コレクションの管理方法](../../../weaviate/manage-collections/index.mdx) +- [Weaviate Academy: 圧縮](../compression/index.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/250_dynamic.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/250_dynamic.mdx new file mode 100644 index 000000000..400f0b4f1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/250_dynamic.mdx @@ -0,0 +1,79 @@ +--- +title: 動的インデックスの詳細 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!./_snippets/100_config.py'; + +「 dynamic 」インデックスは、`hnsw` インデックスと `flat` インデックスの利点を組み合わせた “両方の長所取り” のアプローチです。 + +import DynamicAsyncRequirements from '/_includes/dynamic-index-async-req.mdx'; + + + +## 主要な概念 + +簡単に言うと、`dynamic` インデックスは `flat` インデックスを基盤とし、コレクション内の ベクトル 数が既定のしきい値(デフォルトでは 10,000)を超えると自動的に `hnsw` インデックスへ変換されます。 + +その背景には、`flat` インデックスは小規模コレクションに対して非常に効率的ですが、検索時間がコレクション内の ベクトル 数に比例して増加するという性質があります。一方、`hnsw` インデックスは大規模コレクションでより効率的ですが、小規模コレクションではメモリのオーバーヘッドが大きく利点が少ないという問題があります。 + +コレクションごとのサイズが事前に分からない場合や、テナントによってサイズが大きく異なることが予想される場合には、`dynamic` インデックスが最適な選択肢となります。 + +マルチテナンシー構成では、すべてのテナントが最初は `flat` インデックスから開始し、コレクション内の ベクトル 数がしきい値を超えると自動的に `hnsw` インデックスへ切り替わります。 + +現時点では片方向の変換のみ対応しており、一度 `hnsw` に変換されると、後にしきい値を下回っても `flat` へは戻りません。 + +### 距離メトリック + +![ベクトル距離計算](./img/vector_distance.png) + +インデックスで使用する距離メトリックは、 ベクトル 間の距離をどのように計算するかを決定します。HNSW インデックスでは、これが各 ベクトル をグラフ内のどこに配置するかにも影響します。 + +お使いの ベクトル に適したメトリックを選択してください。選定の際は、 ベクトル を生成したモデルのドキュメントを参照すると良いでしょう。 + +Weaviate のデフォルトメトリックは cosine ですが、[他にも利用可能なメトリック](/weaviate/config-refs/distances.md) を使用できます。 + +迷った場合は、多くのモデルで採用されている堅牢なデフォルトである cosine 距離をお勧めします。 + +## Weaviate で dynamic インデックスを設定する + +以下の各パラメーターは、コレクション作成時に指定できます。なお、`vector_cache_max_objects` は量子化を有効にし、かつ ベクトル キャッシュを有効にした場合にのみ使用されます。 + +### 基本設定 + +以下のようにコレクションを dynamic インデックスに設定します。 + + + +### カスタム設定 + +`flat` インデックスが `hnsw` へ変換されるしきい値を設定できます。 + +さらに、インデックスの状態に応じて適用される `flat` および `hnsw` インデックスの各種パラメーターも指定可能です。 + + + +## 参考資料 + +- [Concepts: ベクトル インデックス](/weaviate/concepts/indexing/vector-index.md) +- [References: ベクトル インデックスのパラメーター](/weaviate/config-refs/indexing/vector-index.mdx) +- [コレクションの管理方法](../../../weaviate/manage-collections/index.mdx) +- [Weaviate Academy: 圧縮](../compression/index.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/900_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/900_next_steps.mdx new file mode 100644 index 000000000..d3a85537a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/900_next_steps.mdx @@ -0,0 +1,37 @@ +--- +title: まとめ / 次のステップ +--- + +おめでとうございます!これで ベクトル インデックスに関する本コースを修了しました。お役に立ち、有益だったことを願っています。 + +## インデックス選択 + +インデックス タイプを選択する際は、次を目安にしてください。 + +- **Flat index** : サイズが既知の小規模コレクション向け。 +- **HNSW index** : サイズが既知の大規模コレクション向け。 +- **Dynamic index** : サイズが不明、または時間とともに増加する可能性があるコレクション向け。 + +また、マルチテナント環境では、`dynamic` インデックスをデフォルトにすると便利です。これにより、一部のテナントは `flat` インデックスのままにし、成長したテナントは自動で `hnsw` に変換できます。 + +## さらなるリソース + +学習を継続する際に役立つリソースはこちらです。 + +- [概念: ベクトル インデックス](/weaviate/concepts/indexing/vector-index.md) +- [リファレンス: ベクトル インデックスのパラメーター](/weaviate/config-refs/indexing/vector-index.mdx) +- [コレクションの管理方法](../../../weaviate/manage-collections/index.mdx) +- [Weaviate Academy: 圧縮](../compression/index.md) +- [Weaviate Academy: 名前付き ベクトル](../named_vectors/index.md) + +import CTASocials from '../_snippets/cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/100_config.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/100_config.py new file mode 100644 index 000000000..c267700f4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/100_config.py @@ -0,0 +1,136 @@ +import weaviate + +client = weaviate.connect_to_local() + +collection_name = "CollectionWithHNSW" + +client.collections.delete(name=collection_name) + +# START ConfigHNSW +from weaviate.classes.config import Configure + +client.collections.create( + name=collection_name, + # ... other parameters + # highlight-start + vector_config=Configure.Vectors.text2vec_openai( + vector_index_config=Configure.VectorIndex.hnsw() + ), + # highlight-end +) +# END ConfigHNSW + +client.collections.delete(name=collection_name) + +# START CustomConfigHNSW +from weaviate.classes.config import Configure, VectorDistances + +client.collections.create( + name=collection_name, + # ... other parameters + # highlight-start + vector_config=Configure.Vectors.text2vec_openai( + vector_index_config=Configure.VectorIndex.hnsw( + # Distance metric + distance_metric=VectorDistances.COSINE, + # Parameters for HNSW index construction + ef_construction=256, # Dynamic list size during construction + max_connections=128, # Maximum number of connections per node + quantizer=Configure.VectorIndex.Quantizer.bq(), # Quantizer configuration + # Parameters for HNSW search + ef=-1, # Dynamic list size during search; -1 enables dynamic Ef + dynamic_ef_factor=15, # Multiplier for dynamic Ef + dynamic_ef_min=200, # Minimum threshold for dynamic Ef + dynamic_ef_max=1000, # Maximum threshold for dynamic Ef + ) + ), + # highlight-end +) +# END CustomConfigHNSW + +client.collections.delete(name=collection_name) + +# START ConfigFlat +from weaviate.classes.config import Configure + +client.collections.create( + name=collection_name, + # ... other parameters + # highlight-start + vector_config=Configure.Vectors.text2vec_openai( + vector_index_config=Configure.VectorIndex.flat() + ), + # highlight-end +) +# END ConfigFlat + +client.collections.delete(name=collection_name) + +# START CustomConfigFlat +from weaviate.classes.config import Configure, VectorDistances + +client.collections.create( + name=collection_name, + # ... other parameters + # highlight-start + vector_config=Configure.Vectors.text2vec_openai( + vector_index_config=Configure.VectorIndex.flat( + distance_metric=VectorDistances.COSINE, # Distance metric + quantizer=Configure.VectorIndex.Quantizer.bq(cache=True), # Quantizer configuration + vector_cache_max_objects=1000000, # Maximum number of objects in the cache + ) + ), + # highlight-end +) +# END CustomConfigFlat + +client.collections.delete(name=collection_name) + +# START ConfigDynamic +from weaviate.classes.config import Configure + +client.collections.create( + name=collection_name, + # ... other parameters + # highlight-start + vector_config=Configure.Vectors.text2vec_openai( + vector_index_config=Configure.VectorIndex.dynamic() + ), + multi_tenancy_config=Configure.multi_tenancy(enabled=True), # Dyanmic index works well with multi-tenancy set-ups + # highlight-end +) +# END ConfigDynamic + +client.collections.delete(name=collection_name) + +# START CustomConfigDynamic +from weaviate.classes.config import Configure, VectorDistances + +client.collections.create( + name=collection_name, + # ... other parameters + # highlight-start + vector_config=Configure.Vectors.text2vec_openai( + vector_index_config=Configure.VectorIndex.dynamic( + distance_metric=VectorDistances.COSINE, # Distance metric + threshold=25000, # Threshold for switching to dynamic index + hnsw=Configure.VectorIndex.hnsw( + # Your preferred HNSW configuration + ), + flat=Configure.VectorIndex.flat( + # Your preferred flat configuration + ), + ) + ), + multi_tenancy_config=Configure.multi_tenancy( # Dyanmic index works well with multi-tenancy set-ups + enabled=True, + auto_tenant_creation=True, + auto_tenant_activation=True, + ), + # highlight-end +) +# END CustomConfigDynamic + +client.collections.delete(name=collection_name) + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/ef.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/ef.png new file mode 100644 index 000000000..a5c14cd21 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/ef.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/efConstruction.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/efConstruction.png new file mode 100644 index 000000000..f132d1843 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/efConstruction.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/hnsw_diagram.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/hnsw_diagram.png new file mode 100644 index 000000000..51ffb0b77 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/hnsw_diagram.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/maxConnections.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/maxConnections.png new file mode 100644 index 000000000..92171af7c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/_snippets/maxConnections.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/img/vector_distance.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/img/vector_distance.png new file mode 100644 index 000000000..e64fb2859 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/img/vector_distance.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/index.md new file mode 100644 index 000000000..eca80ce89 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/vector_index/index.md @@ -0,0 +1,29 @@ +--- +title: "230 ベクトル インデックス" +description: Weaviate で ベクトル インデックス を 実装し、検索 クエリ を 高速化 します。 +sidebar_position: 230 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +:::info 前提条件 +このコースは 単体 で 学習 できます。 しかし、[テキスト](../starter_text_data/index.md)、[独自 ベクトル](../starter_custom_vectors/index.md)、または [マルチモーダル データ](../starter_multimodal_data/index.md) を 取り扱う 101 レベル の いずれか の コース を 先に 受講する こと を 推奨 します。 +::: + +ベクトル インデックス は Weaviate の 検索 機能 の 主要 コンポーネント です。 これ により、クエリ ベクトル との 類似度 に 基づいて ベクトル を 検索 し、それら の ベクトル に 関連付け られた オブジェクト を 取得 できます。 + +Weaviate は 複数 の ベクトル インデックス を 提供しており、それぞれ に 長所 と 短所 が あります。 各 インデックス は 設定 可能 で、ユースケース に 合わせて パフォーマンス を 調整 できます。 + +この コース では、Weaviate で 利用 できる さまざま な ベクトル インデックス と、それら を ユースケース に 合わせて 設定 する 方法 を 学び ます。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/10_intro_weaviate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/10_intro_weaviate.mdx new file mode 100644 index 000000000..700b91002 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/10_intro_weaviate.mdx @@ -0,0 +1,289 @@ +--- +title: Weaviate 入門 +description: Weaviate 入門 +--- + +## Weaviate とは + +import ReactPlayer from 'react-player/lazy' + + +
+ +Weaviate はオープンソースの [ベクトル データベース](https://weaviate.io/blog/what-is-a-vector-database) です。とはいえ、これはどういう意味でしょうか?ここで詳しく見ていきましょう。 + +### ベクトル データベース + +Weaviate は、必要な情報をすばやく正確に取得するための優れたツールです。その理由は、Weaviate が優秀な **ベクトル データベース** であるからです。 + +皆さんは SQL を使うリレーショナル データベースなど、従来のデータベースに慣れているかもしれません。データベースは情報を分類・保存・取得できます。**ベクトル** データベースもこれらを行えますが、決定的な違いは「類似度」に基づいて操作できる点です。 + +#### 従来の検索の仕組み + +たとえば、ヨーロッパの「主要」都市に関する記事を収めたリレーショナル データベースを検索するとします。SQL を使用して、次のようなクエリを作成するかもしれません。 + +```sql +SELECT city_name wiki_summary +FROM wiki_city +WHERE (wiki_summary LIKE '%major European city%' OR + wiki_summary LIKE '%important European city%' OR + wiki_summary LIKE '%prominent European city%' OR + wiki_summary LIKE '%leading European city%' OR + wiki_summary LIKE '%significant European city%' OR + wiki_summary LIKE '%top European city%' OR + wiki_summary LIKE '%influential European city%' OR + wiki_summary LIKE '%notable European city%') + (… and so on) +``` + +このクエリは、`wiki_summary` 列に `major`、`important`、`prominent` などの文字列が含まれる都市を返します。 + +多くの場合、これはうまく機能します。しかし、この方法には 2 つの大きな制約があります。 + +#### 従来検索の制約 + +まず、この手法では、その概念を表す可能性のある語句を自分で洗い出す必要がありますが、これは簡単ではありません。 + +さらに、結果として得られるオブジェクトをどのように順位付けするかという問題も解決しません。 + +上記の検索では、ほとんど関連性のない「別のヨーロッパ都市」について言及しているだけのエントリでも、パリやローマのように高い関連性を持つエントリと同じ重み付けになってしまいます。 + +ベクトル データベースは、類似度に基づく検索を可能にすることで、この課題をシンプルにします。 + +#### ベクトル検索の例 + +たとえば、Weaviate では次のようなクエリを実行できます。 + +```graphql +{ + Get { + WikiCity ( + nearText: { concepts: ["Major European city"] } + ) { city_name wiki_summary } + } +} +``` + +すると、クエリ「Major European city」の概念との **類似度でランク付けされた** エントリ一覧が返ってきます。 + +さらに Weaviate は、データを類似度に基づいて「インデックス化」するため、この種のデータ取得が驚くほど高速です。 + +Weaviate はこれらを実現するだけでなく、実際にはもっと多くのことができます。別の言い方をすれば、Weaviate は情報活用を強力に後押しします。 + +:::info ベクトル検索とセマンティック検索 +ベクトル検索は「セマンティック検索」とも呼ばれます。意味 (semantic) の類似度に基づいて結果を返すためです。 +::: + +### オープンソース + +Weaviate はオープンソースです。つまり、その [コードベースがオンライン](https://github.com/weaviate/weaviate) で誰でも閲覧・利用できます[(1)](#-notes)。 + +そして、それが *唯一の* コードベースです。ローカル マシン、クラウド環境、あるいはマネージド サービスである [Weaviate Cloud (WCD)](https://console.weaviate.cloud/) のいずれで実行しても、まったく同じ技術を使っています。 + +したがって、自分のデバイスで無料で Weaviate を動かすことも、利便性のためにマネージド サービスを利用することもできます。また、自分が何を動かしているかを正確に把握でき、オープンソース コミュニティの一員として開発に貢献できるという安心感も得られます。 + +さらに、Weaviate に関する知識はローカル・クラウド・マネージドのどのインスタンスでも共通して役立ちます。WCD で学んだことはローカル実行にもそのまま適用でき、その逆も同様です。😉 + +### 動的な情報 + +私たちは情報を本のような静的なものと考えがちです。しかし Weaviate と最新の AI 駆動型言語モデルを組み合わせれば、静的情報を取得するだけでなく、その上に簡単に新しい価値を構築できます。以下の例をご覧ください。 + +#### 質問応答 + +Wikipedia エントリ一覧を登録しておけば、Weaviate に次のように尋ねられます。 + +:::note 私たちが Weaviate に質問しました: +Lewis Hamilton はいつ生まれましたか? +::: + +すると Weaviate は次のように答えます。 + +:::note Weaviate の回答: +Lewis Hamilton は 1985 年 1 月 7 日に生まれました。([ご自身で確認](https://en.wikipedia.org/wiki/Lewis_Hamilton)) +::: + +
+ クエリとレスポンスを表示 + +#### クエリ + +```graphql +{ + Get { + WikiArticle ( + ask: { + question: "When was Lewis Hamilton born?", + properties: ["wiki_summary"] + }, + limit: 1 + ) { + title + _additional { + answer { + result + } + } + } + } +} +``` + +#### レスポンス + +```json +{ + "data": { + "Get": { + "WikiArticle": [ + { + "_additional": { + "answer": { + "result": " Lewis Hamilton was born on January 7, 1985." + } + }, + "title": "Lewis Hamilton" + } + ] + } + } +} +``` + +
+ +#### 生成検索 + +あるいは Weaviate を使って、取得した情報から文章を生成 (synthesize) することもできます。 + +次の例では、「レーシング ドライバー」を検索し、結果を以下のフォーマットで出力しました。 + +:::note 私たちが Weaviate に依頼しました: +次を読むよう楽しく勧めるツイートを書いてください: ## \{title} (以下のハイライトをまとめて): ## \{wiki_summary} +::: + +その結果は次のとおりです。 + +:::note Weaviate の回答: +Lewis Hamilton、7 回の Formula One World Drivers' Championship 勝者の驚くべきストーリーをチェックしよう!謙虚な始まりから世界で最も影響力のある人物の 1 人になるまで、その旅はインスピレーションに満ちています。#LewisHamilton #FormulaOne #Motorsport #Racing +::: + +
+ クエリとレスポンスを表示 + +#### クエリ + +```graphql +{ + Get { + WikiArticle( + nearText: { + concepts: ["Racing Driver"] + } + limit: 1 + ) { + title + wiki_summary + _additional { + generate( + singleResult: { + prompt: """ + Write a fun tweet encouraging people to read about this: ## {title} + by summarizing highlights from: ## {wiki_summary} + """ + } + ) { + singleResult + error + } + } + } + } +} +``` +#### 回答 + +```json +{ + "data": { + "Get": { + "WikiArticle": [ + { + "_additional": { + "generate": { + "error": null, + "singleResult": "Check out the amazing story of Lewis Hamilton, the 7-time Formula One World Drivers' Championship winner! From his humble beginnings to becoming a global icon, his journey is an inspiring one. #LewisHamilton #FormulaOne #Motorsport #Racing #Inspiration" + } + }, + "title": "Lewis Hamilton", + "wiki_summary": "Sir Lewis Carl Davidson Hamilton (born 7 January 1985) is a British racing driver currently competing in Formula One, driving for Mercedes-AMG Petronas Formula One Team. In Formula One, Hamilton has won a joint-record seven World Drivers' Championship titles (tied with Michael Schumacher), and holds the records for the most wins (103), pole positions (103), and podium finishes (191), among others.\nBorn and raised in Stevenage, Hertfordshire, Hamilton joined the McLaren young driver programme in 1998 at the age of 13, becoming the youngest racing driver ever to be contracted by a Formula One team. This led to a Formula One drive with McLaren for six years from 2007 to 2012, making Hamilton the first black driver to race in the series. In his inaugural season, Hamilton set numerous records as he finished runner-up to Kimi R\u00e4ikk\u00f6nen by one point. The following season, he won his maiden title in dramatic fashion\u2014making a crucial overtake at the last corner on the last lap of the last race of the season\u2014to become the then-youngest Formula One World Champion in history. After six years with McLaren, Hamilton signed with Mercedes in 2013.\nChanges to the regulations for 2014 mandating the use of turbo-hybrid engines saw the start of a highly successful period for Hamilton, during which he won six further drivers' titles. Consecutive titles came in 2014 and 2015 during an intense rivalry with teammate Nico Rosberg. Following Rosberg's retirement in 2016, Ferrari's Sebastian Vettel became Hamilton's closest rival in two championship battles, in which Hamilton twice overturned mid-season point deficits to claim consecutive titles again in 2017 and 2018. His third and fourth consecutive titles followed in 2019 and 2020 to equal Schumacher's record of seven drivers' titles. Hamilton achieved his 100th pole position and race win during the 2021 season. \nHamilton has been credited with furthering Formula One's global following by appealing to a broader audience outside the sport, in part due to his high-profile lifestyle, environmental and social activism, and exploits in music and fashion. He has also become a prominent advocate in support of activism to combat racism and push for increased diversity in motorsport. Hamilton was the highest-paid Formula One driver from 2013 to 2021, and was ranked as one of the world's highest-paid athletes by Forbes of twenty-tens decade and 2021. He was also listed in the 2020 issue of Time as one of the 100 most influential people globally, and was knighted in the 2021 New Year Honours. Hamilton was granted honorary Brazilian citizenship in 2022.\n\n" + } + ] + } + } +} +``` + +
+ + +これらに加え、ベクトル化、要約、分類など多くの機能を今後のユニットで扱います。 + +まずは、Weaviate が本質的には ベクトル データベースであり、取得した情報に対して AI ツールを活用してさらなる処理ができるという点を覚えておいてください。 + +## 復習 + +このセクションでは、Weaviate が何であり、そして高いレベルでどのように動作するのかを学びました。また、 ベクトル 検索が類似度ベースの検索手法であるという概要もご紹介しました。 + +### 復習問題 + + + + + + + +### 重要ポイント + +- Weaviate はオープンソースの ベクトル データベースです。 +- Weaviate のコアライブラリは、ローカル、クラウド、 WCD のいずれで実行しても同じです。 +- ベクトル 検索は類似度ベースの検索です。 +- Weaviate は検索後にデータを取得したあと、それを変換してから返すこともできます。 + +## 注意事項 + +(1) もちろん、ライセンス条項が適用されます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const weaviateOpenSource = [ + { + questionText: 'ローカル デプロイメントとクラウド デプロイメントにおける Weaviate のコードベースの違いは何ですか?', + answerOptions: [ + { answerText: 'クラウド デプロイメントには常に追加モジュールが含まれている。', isCorrect: false, feedback: 'Weaviate のクラウド デプロイメントには特別なモジュールや追加モジュールは含まれていません。'}, + { answerText: 'ローカル デプロイメントは GPU 利用向けに最適化されている。', isCorrect: false, feedback: 'GPU の利用はローカルでもリモートでも推論時に有効化できます。'}, + { answerText: 'クラウド デプロイメントはスケーラビリティに最適化されている。', isCorrect: false, feedback: 'クラウド デプロイメントがスケーラビリティに最適化されるべきだという点には同意しますが、Weaviate のコードベースは配置場所に関係なくスケーラブルになるよう設計されています。'}, + { answerText: '違いはない。同じコードベースである。', isCorrect: true, feedback: 'そのとおりです。GitHub で公開されている同じオープンソースのコードベースです。'}, + ], + }, +]; +export const vectorSearchDefinition = [ + { + questionText: 'ベストなベクトル 検索の説明はどれですか?', + answerOptions: [ + { answerText: 'ベクトル 検索は方向検索である。', isCorrect: false, feedback: 'この文脈での "vector" の定義は方向とは関係ありません。'}, + { answerText: 'ベクトル 検索は類似度ベースの検索である。', isCorrect: true, feedback: 'データ コレクションやデータベースを「意味」の近さで検索します。'}, + { answerText: 'ベクトル 検索は数値ベースの検索である。', isCorrect: false, feedback: '部分的には正しいですが最適な回答ではありません。数値は関わりますが、ベクトル 検索の重要な概念を十分に捉えていません。'}, + ], + }, +]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/15_overview_vectors.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/15_overview_vectors.mdx new file mode 100644 index 000000000..fce1e7626 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/15_overview_vectors.mdx @@ -0,0 +1,110 @@ +--- +title: ベクトル – 概要 +description: Weaviate における ベクトル の概要 +--- + +## ベクトル + +import ReactPlayer from 'react-player/lazy' + + +
+ +すでに学んだように、Weaviate は ベクトル データベースであり、ベクトル 検索は類似度ベースです。では、ベクトル とは何でしょうか。 + +ここでのベクトル は、`[1, 0]` や `[0.513, 0.155, 0.983, ..., 0.001, 0.932]` のように数字を並べたものにすぎません。こうしたベクトル は「意味」を表現するために使われます。 + +これは少し奇妙に感じるかもしれません。しかし実は、知らないうちに意味を捉えるためにベクトル を使ったことがあるかもしれません。たとえば写真編集や MS Paint で使われる RGB カラー システムがそうです。 + +### 数値での意味表現 + +RGB システムでは、3 つの数字の組み合わせで色を表します。例: + +- (255, 0, 0) = 赤 +- (80, 200, 120) = エメラルド + +ここで各数字は、赤・緑・青それぞれの強さを示すダイヤルのようなものと考えられます。 + +では、こうしたダイヤルが何百、何千とあると想像してください。これが、ベクトル が意味を表現する方法です。GPT-x や Weaviate と組み合わせて使う最新の機械学習モデルは、テキスト・コード・画像・動画などあらゆるオブジェクトの「本質」や「意味」をベクトル で表現します。 + +## Weaviate における ベクトル 埋め込み + + + +オブジェクトの意味をベクトル で表したものを「ベクトル 埋め込み」と呼びます。 + +Weaviate はデータオブジェクトとそれに対応するベクトル 埋め込みをインデックス化し保存することで、ベクトル 検索を可能にします。これらのベクトル 埋め込みは機械学習モデルから得られます。 + +要するに、Weaviate はデータを処理・整理し、クエリに似たオブジェクトを取り出せるようにします。これを高速に行うため、従来型データベースにはない 2 つのことを行います。Weaviate は次を行います。 + +- 類似度を定量化する +- ベクトル データをインデックスする + +これらの処理によって、Weaviate は高いパフォーマンスを実現しています。 + +### 類似度の定量化 + +すでに述べたように、ベクトル 検索は類似度ベースですが、実際にはどう判定するのでしょうか。2 つのデータが「似ている」とはどういうことでしょうか。テキストや画像、一般的なオブジェクトどうしの類似性をどう測るのでしょうか。 + +これは一見シンプルですが、掘り下げると非常に奥深いテーマです。 + +ここでは概念だけを押さえましょう。機械学習 (ML) モデルがこのプロセスの鍵です。ベクトル 検索を支える ML モデルは、プロンプトからテキストを生成するモデルと共通点があります。新しいテキストを生成する代わりに、これらの ベクトライザー モデルはテキストや他のメディアの「意味」を捉えます。詳細は後ほど扱います。 + +### ベクトル データのインデックス化 + +ベクトル 検索は計算負荷が非常に高くなりがちです。 + +この問題を解決するため、Weaviate は approximate nearest neighbor (ANN) インデックスと 転置インデックス を組み合わせて使用します。ANN インデックスにより Weaviate は非常に高速なベクトル 検索を実現し、転置インデックスによりブール条件でのフィルタリングが可能になります。 + +詳細は後ほど説明しますが、ここでは Weaviate が高速なベクトル 検索とフィルタリングを両立させていることを覚えておいてください。 + +## 復習 + +このセクションでは、ベクトル が何か、そして Weaviate がそれらをどのように活用するかを大まかに学びました。また、Weaviate が高速なベクトル 検索を実現する 2 つの主要機能についても紹介しました。 + +### 復習演習 + +:::tip Self-reflection +ベクトル とは何かを、自分の言葉で説明できますか? +::: + + + +### 要点 + +- ベクトル は、オブジェクトの意味や本質を捉える一連の数字です。 +- 機械学習モデルは、異なるオブジェクト間の類似度を定量化するうえで不可欠です。 +- Weaviate は approximate nearest neighbor (ANN) インデックスと 転置インデックス を組み合わせることで、高速なベクトル 検索とフィルタリングを実現します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const howWeaviateWorks = [{ + questionText: 'Which of these statements are true?', + answerOptions: [ + { + answerText: 'Weaviate has no way of quantifying similarity between objects.', + isCorrect: false, + feedback: 'Weaviate performs vector searches, which is similarity-based.', + }, + { + answerText: 'The only type of index in Weaviate is the vector index.', + isCorrect: false, + feedback: 'In addition to the vector index, Weaviate uses an inverted index.', + }, + { + answerText: 'Weaviate is a machine learning model.', + isCorrect: false, + feedback: 'While Weaviate can be used with a variety of different models which help it determine object similarity, it is itself not a machine learning model. Weaviate is a vector database.', + }, + { + answerText: 'None of the above', + isCorrect: true, + feedback: 'All of these are false!', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/20_examples_1.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/20_examples_1.mdx new file mode 100644 index 000000000..1e0897d14 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/20_examples_1.mdx @@ -0,0 +1,226 @@ +--- +title: 例 1 - クエリ +description: Hello Weaviate - 例 パート 1 +--- + +## ベクトルの活用 + +import ReactPlayer from 'react-player/lazy' + + +
+ +Weaviate でできることの例をもう少し見てみましょう。 + +まず、デモデータベースを検索して ベクトル検索 を試します。入力テキスト、 ベクトル、オブジェクトなど、さまざまなクエリタイプを使用して、類似度に基づいてオブジェクトを取得する方法を学びます。 + +ベクトル検索 とキーワード検索を比較し、両者の違いを確認したあと、フィルターを用いてこれら 2 つの手法を組み合わせる方法を学びます。 + +### ベクトル検索デモ + +最初の例として、デモデータセットを検索してみましょう。これはクイズ番組 * Jeopardy!* の質問を少しだけ収録したものです。 + +あなたがクイズ ナイトを開催していて、「動物が出てくる映画」に関する質問を取得したいと想像してください。従来のデータベースであれば、単語の一致を探す必要があり、例えば次のようなクエリになるでしょう。 + +```sql +SELECT question, answer +FROM jeopardy_questions +WHERE ( + question LIKE '%animal%' + OR question LIKE '%creature%' + OR question LIKE '%beast%' + ) +AND ( + question LIKE '%movie%' + OR question LIKE '%film%' + OR question LIKE '%picture%' + OR question LIKE '%cinema%' + ) + +``` + +これは書くのが難しいクエリです。さらに悪いことに、特定の動物名もクエリに追加しなければならないかもしれません。 + +Weaviate のクエリはずっと直感的です。次のクエリを実行するとどうなるか見てみましょう。 + +:::note Weaviate で検索した内容: +animals in movies +::: + +
+ 完全なクエリを見る + +```graphql +{ + Get { + JeopardyQuestion ( + nearText: { + concepts: ["animals in movies"] + } + limit: 3 + ) { + question + answer + } + } +} +``` + +
+ +Weaviate は次のような回答を上位に返しました。 + +:::note Weaviate が取得した結果: +- **ミーアキャット**:こちらに見られる哺乳類の群れで、* The Lion King* の ティモン のような動物 +- **犬**:Scooby-Doo、Goofy、Pluto はアニメ版 +- **The Call of the Wild Thornberrys**:動物と話せる Eliza が登場する Nick のアニメに、犬 Buck が加わる Jack London の物語 +::: + +
+ JSON レスポンスを見る + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "answer": "meerkats", + "question": "Group of mammals seen here: [like Timon in The Lion King]" + }, + { + "answer": "dogs", + "question": "Scooby-Doo, Goofy & Pluto are cartoon versions" + }, + { + "answer": "The Call of the Wild Thornberrys", + "question": "Jack London story about the dog Buck who joins a Nick cartoon about Eliza, who can talk to animals" + } + ] + } + } +} +``` + +
+ +いずれの結果にも「animal」や「movie」という語、ましてや両方が含まれていないにもかかわらず、非常に関連性が高いことに注目してください。 + +これこそが ベクトル検索 が便利な理由です。完全一致のテキストがなくても関連するオブジェクトを見つけられます。 + +### ベクトル類似度デモ + +このクエリを実行すると、先ほどと同じような回答が返ってくると期待するかもしれません。 + +```graphql +{ + Get { + JeopardyQuestion ( + nearText: { + concepts: ["European geography"] + } + limit: 3 + ) { + question + answer + _additional { + distance + } + } + } +} +``` + +しかし、このレスポンスを見てください。追加情報に気付きますか? + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.15916324 + }, + "answer": "Bulgaria", + "question": "A European republic: Sofia" + }, + ... + ] + } + } +} + +``` + +
+ Weaviate からの完全な JSON レスポンスを見る + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.15916324 + }, + "answer": "Bulgaria", + "question": "A European republic: Sofia" + }, + { + "_additional": { + "distance": 0.16247147 + }, + "answer": "Balkan Peninsula", + "question": "The European part of Turkey lies entirely on this peninsula" + }, + { + "_additional": { + "distance": 0.16832423 + }, + "answer": "Mediterranean Sea", + "question": "It's the only body of water with shores on the continents of Asia, Africa & Europe" + } + ] + } + } +} + +``` + +
+ +違いは、レスポンスに `distance` 値が含まれていることです。 + +`distance` は、返されたオブジェクトとクエリとの類似度を示します。 + +それが具体的に何を意味するのか、また 2 つのオブジェクトや概念の類似度がどのように決定されるのか疑問に思ったなら、良い質問です! これについては後ほど詳しく説明します。 + +ここでは、距離が小さいほど 2 つのオブジェクトがより似ていると覚えておいてください。 + +## 復習 + + + + + +### 重要なポイント + +- ベクトル検索 は、完全一致のテキストがなくても関連オブジェクトを見つけられます。 +- ベクトル検索 では、distance 値が返されたオブジェクトとクエリの類似度を示します。 +- distance が小さいほど類似度が高いことを示します。 +- ベクトル検索 は、キーワード検索やフィルタリングと組み合わせることで、より洗練された検索結果を得られます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/25_examples_2.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/25_examples_2.mdx new file mode 100644 index 000000000..e91f647be --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/25_examples_2.mdx @@ -0,0 +1,146 @@ +--- +title: 例 2 - 検索を超えて +description: Hello Weaviate - 例 パート 2 +sidebar_position: 25 +--- + +## ベクトル検索のその先 + +import ReactPlayer from 'react-player/lazy' + + +
+ +Weaviate を使用すると、静的な情報を取得するだけでなく、さらに多くのことができます。 + +データベースからオブジェクトを取得するだけではない、いくつかの例を見てみましょう。 + +次の Wikipedia の記事から情報を抽出します。 + +
+ "The Sydney Opera House" Wikipedia summary + +シドニー・オペラハウスは、シドニーにある複数の会場を備えた舞台芸術センターです。シドニー湾の海岸に位置し、世界で最も有名で特徴的な建物のひとつであり、20 世紀建築の傑作と広く見なされています。デンマーク人建築家ヨーン・ウツソンが設計し、その後ピーター・ホール率いるオーストラリアの建築チームが完成させました。建物は 1973 年 10 月 20 日、エリザベス 2 世女王によって正式に開館しました。ウツソンが 1957 年に国際設計コンペで選出されてから着想が始まり、ジョセフ・ケーヒル首相率いるニューサウスウェールズ州政府が 1958 年に着工を許可し、ウツソンが建設を指揮しました。ウツソンの設計を採用するという政府の決定は、その後のコスト超過やスケジュール遅延、最終的なウツソンの辞任などの事情によってしばしば影が薄れています。建物とその周辺は、シドニー湾のベネロング・ポイント全体を占め、シドニー・コーブとファーム・コーブの間、シドニー CBD と王立植物園に隣接し、シドニー・ハーバーブリッジにも近接しています。 + +建物には複数の公演会場があり、年間 1,500 を超える公演が開催され、120 万人以上が来場します。Opera Australia、Sydney Theatre Company、Sydney Symphony Orchestra の 3 つの常駐団体を含む数多くのアーティストが公演を行います。オーストラリアで最も人気のある観光地のひとつとして、年間 800 万人以上が訪れ、約 35 万人がガイドツアーに参加しています。建物はニューサウスウェールズ州政府の機関である Sydney Opera House Trust によって管理されています。 + +2007 年 6 月 28 日、シドニー・オペラハウスは UNESCO 世界遺産に登録されました。それ以前には 1980 年から国民遺産登録簿(現在は廃止)、1983 年から National Trust of Australia 登録、2000 年から City of Sydney Heritage Inventory、2003 年から New South Wales State Heritage Register、2005 年から Australian National Heritage List に登録されていました。また、New7Wonders of the World キャンペーンのファイナリストにも選ばれました。 + +
+ +Weaviate は Wikipedia のエントリーを処理するときに [data objects](/weaviate/concepts/data) を生成します。データオブジェクトはクラスに保存されます。クラスはリレーショナルデータベースのテーブルに大まかに相当し、オブジェクトはそのテーブルのレコードに似ています。 + +### 質問応答デモ + +Weaviate はテキストから知識を抽出できます。 + +```graphql +{ + Get { + WikiArticle ( + ask: { + question: "When did construction for the Sydney Opera House start?", + properties: ["wiki_summary"] + }, + limit: 1 + ) { + title + _additional { + answer { + hasAnswer + property + result + startPosition + endPosition + } + } + } + } +} +``` + +このクエリに対して、Weaviate は最も関連性の高いデータオブジェクトを特定するだけでなく、Wikipedia 記事のテキスト情報に基づいて質問に回答します。 + +
+ レスポンスを表示 + +:::note Weaviate says: +シドニー・オペラハウスの建設は 1958 年に始まりました。 +::: + +
+ +### 生成検索 + +Weaviate はこれらのエントリーを使ってさらに多くのことができます。データストアからオブジェクトを取得し、そのオブジェクトを用いて新しいテキストを生成させることが可能です。たとえば、シドニー・オペラハウスのエントリーを含むオブジェクトを使って新しいテキストを作成できます。 + +```graphql +{ + Get { + WikiArticle( + nearText: { + concepts: ["Sydney Opera House"] + } + limit: 1 + ) { + title + wiki_summary + _additional { + generate( + singleResult: { + prompt: """ + Write a fun tweet encouraging people to read about this: ## {title} + by summarizing highlights from: ## {wiki_summary} + """ + } + ) { + singleResult + error + } + } + } + } +} +``` + +このサンプルコードは Wikipedia のエントリーを基にツイートを生成します! + +
+ レスポンスを表示 + +:::note Weaviate says: +Explore the world-famous Sydney Opera House and its incredible architecture! From the iconic design to the amazing performances, there's something for everyone to enjoy. #SydneyOperaHouse #Explore #Architecture #Performances #Experience +::: + +
+ +このプロセスは `generative search` の例です。生成検索では、Weaviate が情報を取得し、その後 LLM ( 大規模言語モデル ) を活用して情報を再構成します。これは情報活用の方法を大きく変える強力な機能です。 + +プロンプトを変えることで、異なる結果を生成できます。 + +### 次のステップ + +Q&A や生成検索のようなツールは、データに命を吹き込みます。次のセクションでは、ご自身で Weaviate をセットアップし、クエリを実行してみましょう。 + +## レビュー + + + +### 重要なポイント + +- Weaviate は質問応答機能を用いてテキストから知識を抽出し、最も関連性の高いオブジェクトと提供されたテキストに基づく実際の答えを特定できます。 +- 生成検索を使用すると、情報を取得し、たとえば Wikipedia のエントリーを基にツイートを生成するなど、コンテンツを再構成・再利用できます。 +- Weaviate のこれら高度な機能により、データとの対話方法や情報の活用方法が大きく変わります。 + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/40_set_up.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/40_set_up.mdx new file mode 100644 index 000000000..7ea6d9713 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/40_set_up.mdx @@ -0,0 +1,207 @@ +--- +title: データベースとクライアントのセットアップ +description: 迅速かつ効率的にデータ検索を行うための Weaviate のセットアップ方法を学びます。 +sidebar_position: 40 +--- + +import registerImg from '../../../../cloud/img/register.png'; +import WCDcreate from '../../../../cloud/img/wcs-create.png'; +import WCDcreationProgress from '../../../../cloud/img/wcs-creation-progress.png'; + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +## Weaviate を実行するオプション + +[Weaviate Cloud ( WCD )](https://console.weaviate.cloud/) は、Weaviate を代わりに実行してくれるマネージドサービスです。Docker、Kubernetes、または Embedded Weaviate を使用して、ご自身で Weaviate インスタンスを管理することもできます。 + +どのような方法で Weaviate を実行しても、基盤となるコードは同一です。ただし、運用面でいくつか注意すべき違いがあります。 + +### WCD ( 推奨 ) + +[Weaviate Cloud ( WCD )](https://console.weaviate.cloud/) は、ユーザー側で一切のメンテナンスが不要なマネージド SaaS サービスです。Weaviate ( 会社 ) によって管理されています ( ソフトウェア自体が自律的では... *まだ* ありません )。WCD は、新しい Weaviate インスタンスを作成する最速の方法であり、ユーザーの手間が最も少なくて済みます。 + +WCD の Weaviate インスタンスはあらかじめ設定されており、いくつかの Weaviate モジュールがデフォルトで含まれています。また、ユーザー認証をネイティブにサポートしています。 + +WCD には無料の「サンドボックス」ティアがあります。WCD サンドボックスは、本コースで推奨する Weaviate の実行方法です。 + +### Docker と Kubernetes + +コンテナ化ソリューションである [Docker](https://docs.docker.com/) や [Kubernetes](https://kubernetes.io/docs/home/) を使用して Weaviate インスタンスを実行することもできます。 + +自己管理インスタンスでも WCD と同じ Weaviate コードベースが利用できますが、設定やデプロイをすべて自分で管理する必要があります。 + +本コースでは自己管理インスタンスについては扱いません。Docker と Kubernetes については、今後のコースユニットで取り上げる予定です。 + +これらのソリューションに詳しく、今すぐ Weaviate をインストールしたい場合は、[Docker-Compose](/deploy/installation-guides/docker-installation.md) または [Kubernetes](/deploy/installation-guides/k8s-installation.md) のドキュメントをご覧ください。 + +### Embedded Weaviate + +実験的機能として [Embedded Weaviate](/deploy/installation-guides/embedded.md) があります。クライアントライブラリから直接 Weaviate データベースをインスタンス化できます。 + +現在、Embedded Weaviate は評価目的でのみのご利用を推奨しています。 + +## WCD で始める + +### WCD にサインイン + +1. WCD にアクセスするには、[Weaviate Cloud コンソール](https://console.weaviate.cloud) に移動します。 +1. WCD アカウントをお持ちでない場合は、「Register」ボタンをクリックして新しいアカウントを作成します。 +1. 「Sign in with the Weaviate Cloud」をクリックし、WCD のユーザー名とパスワードでサインインします。 + +### Weaviate クラスターを作成 + +新しい Weaviate クラスターを作成するには、「Create cluster」ボタンをクリックします。 + +Create a Cluster ページでは、次の設定を行います。 + +1. **Free sandbox** プランを選択します。 +1. *cluster name* を入力します。サンドボックスの URL は cluster name を基にして作成され、WCD が一意性を保つためサフィックスを付与します。 +1. `Enable Authentication?` を `YES` に設定します。 +1. **Create** を押してサンドボックス インスタンスを作成します。サンドボックスは一定期間後に期限切れになる点にご注意ください。 + +Create instance + +これで新しいインスタンスの作成プロセスが始まります。WCD はサンドボックスの構築中、進行状況を表示します。 + +Creation in progress + +インスタンスの作成には 1~2 分ほどかかります。完了すると、サンドボックスの横にチェックマーク (✔️) が表示されます。 + +
+ サンドボックスの有効期限とオプション + +import SandBoxExpiry from '/_includes/sandbox.expiry.mdx'; + + + +
+ +サンドボックスを操作する方法はいくつかあります。 + +- [クライアントライブラリー](/weaviate/client-libraries/index.mdx) +- [RESTful API](/weaviate/api/rest) +- [GraphQL API](/weaviate/api/index.mdx) + +## Weaviate クライアントのインストール + +:::info Academy material in Python +Weaviate Academy ユニットの初期リリースでは、教材は Python の例を中心に作成されています。

+現在、TypeScript を皮切りに他のクライアント言語の例を追加中です。教材の充実まで今しばらくお待ちください。 +::: + +### 利用可能なクライアント + +現在、Weaviate クライアントは次の言語で提供されています。 + +- Python +- TypeScript +- Java +- Go + +### クライアントの機能 + +import ClientCapabilitiesOverview from '/_includes/client.capabilities.mdx' + + + +### インストール + +以下の手順に従って、希望するクライアントをインストールしてください。 + +import CodeClientInstall from '/_includes/code/quickstart/clients.install.mdx'; + + +## 復習 + +### 復習演習 + + + + + + + +### 重要なポイント + +- Weaviate を実行する方法は複数あります。 +- 最も簡単で推奨される Weaviate インスタンスの実行方法は WCD です。 +- Weaviate クライアントは複数の言語で利用できます。 +- 現在、 Academy の教材は Python のみで利用可能です。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const instanceOptions = [{ + questionText: '次のうち正しくないものはどれですか?', + answerOptions: [ + { + answerText: 'Weaviate Academy では WCD の利用を推奨しています。', + isCorrect: false, + feedback: 'WCD は Weaviate を実行するための推奨オプションです。', + }, + { + answerText: 'Weaviate の最新バージョンは WCD とローカルホストのインスタンスの両方で利用できます。', + isCorrect: false, + feedback: 'Weaviate の最新バージョンは Docker/Kubernetes でも WCD でも実行できます。', + }, + { + answerText: 'このユニットでは Docker/Kubernetes デプロイについて扱います。', + isCorrect: true, + feedback: 'そのトピックは後のユニットで扱います。', + }, + ] +}]; +export const wcdSetup = [{ + questionText: 'Weaviate Academy の演習用に Weaviate インスタンスを設定する際に必要なものは次のうちどれですか?', + answerOptions: [ + { + answerText: '有料の WCD インスタンス', + isCorrect: false, + feedback: 'Weaviate Academy には無料(サンドボックス)ティアで十分です。', + }, + { + answerText: 'OpenID Connect (OIDC) 認証', + isCorrect: false, + feedback: 'OIDC を使用しても構いませんが、必須ではありません。', + }, + { + answerText: '自己ホストの Docker または Kubernetes インスタンス', + isCorrect: false, + feedback: '自己ホストのインスタンスを使用しても構いませんが、必須ではありません。', + }, + { + answerText: '上記はいずれも必要ありません。', + isCorrect: true, + feedback: '準備が整ったようですね 😊。', + }, + ] +}]; +export const clientCapabilities = [{ + questionText: 'Weaviate クライアントについて正しくないものはどれですか?', + answerOptions: [ + { + answerText: 'Weaviate クライアントは Python、TypeScript/JavaScript、Go、Java 向けに提供されています。', + isCorrect: false, + feedback: '現在、これらの言語向けにクライアントが提供されています。', + }, + { + answerText: 'Weaviate クライアントでは実行できない GraphQL クエリはごくわずかです。', + isCorrect: false, + feedback: 'これらのクライアントはすべての RESTful および GraphQL リクエストを実行できます。', + }, + { + answerText: 'Weaviate クライアントは Weaviate に同梱されています。', + isCorrect: true, + feedback: '各言語用の適切なクライアントを個別にインストールする必要があります。', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/50_hands_on.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/50_hands_on.mdx new file mode 100644 index 000000000..190ed7393 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/50_hands_on.mdx @@ -0,0 +1,280 @@ +--- +title: ハンズオン +--- + +### 準備 + +:::note 無料トライアルの OpenAI API キーを取得 +このセクションでは、 OpenAI 推論エンドポイントを使用したクエリを含みます。まだ OpenAI アカウントをお持ちでない場合は、作成することをおすすめします。執筆時点では、 OpenAI が提供するトライアルクレジットで本演習に十分対応できます。 +::: + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +ご自身のWeaviateインスタンスをセットアップしクライアントをインストールできたので、実際に Weaviate を操作してみましょう。 + +### クライアントの生成 + +Weaviate インスタンスへ継続的にアクセスするための `client` オブジェクトを作成します。設定できるパラメーターは次のとおりです。 + +- **Host URL (必須)** + + これはご自身のWeaviateインスタンスの場所を示します。 URL は次のようになります + + ``` + https://your-sandbox-uo2vgb1z.weaviate.network + ``` + +- **認証情報 (任意)** + + 認証が有効な場合、ここで認証情報を必ず指定してください。指定しないと Weaviate インスタンスへアクセスできません。 + + ``` + AbCdEfGhIjKlMnOpAXB6gbBIaxHDuuwWj5OD + ``` +- **追加ヘッダー (任意)** + + 追加ヘッダーを指定して、 Cohere、 Hugging Face、 OpenAI などの推論サービス用 API キーを渡すことができます。 + +以下は、ご自身のWeaviateインスタンスに合わせて編集した、完全に設定されたクライアントのサンプルコードです。 + + + +import ClientInstantiationCode from './_snippets/academy.hello.client.instantiation.mdx'; + + + +### 試してみましょう! + +次に、 Weaviate インスタンスへ接続します。 + +1. 以下のクライアントコードを `connection_example.py` というファイルにコピーします。 +1. ファイルを編集して、ご自身の Weaviate URL を設定します。 +1. サンドボックス用の API キーに置き換えます。 + + サンドボックスの API キーは「Details」ボタンをクリックし、 Authentication タブの「API keys」で確認できます。キーは次のような形式です。 +1. ファイルを実行します。 + + ``` + python3 connection_example.py + ``` + +import ClientCheckConnection from './_snippets/academy.hello.check.connection.mdx'; + + + +おめでとうございます! Weaviate API への最初のリクエストが完了しました。 `meta` REST エンドポイントは、インスタンスの構成情報を返します。 + +Weaviate API では多くの操作が可能です。次のセクションでいくつか例を試してみましょう。詳細は [API ドキュメント](/weaviate/api/index.mdx) をご覧ください。 + +## Weaviate API とクライアント + +### 利用可能な API + +Weaviate では 2 種類の API ― REST API と GraphQL API ― を使用しており、両者が連携して豊富な機能を提供します。 + +:::tip REST API と GraphQL API の違い + **REST API** では次の操作が可能です: +- CRUD (Create, Read, Update, Delete) 操作 +- データベースのメタデータ取得 + + **GraphQL API** では次の操作が可能です: +- データ検索 +- データオブジェクト取得 +- 情報集約 +- ベクトル空間の探索 +::: + +これらの機能については、このユニットを通じて学習します。 + +
+ REST とは? + +REST は **RE**presentational **S**tate **T**ransfer の頭字語です。 + +REST API では複数のエンドポイントが用意されており、それぞれ固有の URL でアプリケーションとやり取りできます。 + +エンドポイントは階層構造で整理され、各エンドポイントがリソースを表します。クライアントはサーバーへリクエストを送信することで、これらリソースに関する情報を取得します。 + +
+ +
+ GraphQL とは? + +GraphQL は API 用のクエリ言語です。 + +2015 年に Facebook から初めて公開され、現在は GraphQL Foundation がメンテナンスしています。 + +GraphQL はサーバーから情報を取得するためのクエリ言語仕様で、 **強い型付け** が特徴です。そのため、クライアントは受け取りたいデータ型を明示的に指定する必要があります。 + +
+ +### REST API へアクセスする + +REST API と GraphQL API には Weaviate クライアントライブラリ、または適切にリクエストを整形できる他ツールからアクセスできます。 + +以下の例では、各タブに表示されるコードは機能的に同一です。 REST の呼び出しは双方ともメタ情報を取得し、 GraphQL の呼び出しも同じデータを要求します。 + +#### 例 1: REST とクライアントのリクエスト比較 + +import ClientRESTObjectGet from './_snippets/academy.clients.rest.object.get.mdx'; + + +#### 例 2: GraphQL とクライアントリクエストの比較 + +import ClientGraphqlGet from './_snippets/academy.clients.graphql.get.mdx'; + + + +では、もう少し本格的なクエリを試してみましょう。 + +## クエリの実行 + + + +### デモインスタンスへの接続 + +ここでは Weaviate のデモインスタンスに接続し、サンプルデータに対してクエリを実行してみます。インスタンスの詳細は次のとおりです。 + +:::info Demo instance details +- `url`: `https://edu-demo.weaviate.network` +- `Weaviate API key`: `readonly-demo` +::: + +以下のインスタンス情報を使用し、次のことを試してください: +- Weaviate クライアントをインスタンス化する +- 上述のようにメタデータを取得して接続を確認する + +下のスニペットを見ずにできればボーナスポイントです: + +import ClientCheckConnectionEdudemo from './_snippets/academy.hello.check.connection.edudemo.mdx'; + +
+ デモインスタンスへ接続する + + + +
+ +### ベクトル検索 + +次のクエリでは `WikiCity` オブジェクトを検索し、「Major European city」というテキストにもっとも近い都市を探します。 + +このクエリを実行するには、先ほど作成した接続ファイルを更新してください。 + +- メタ情報を取得する行をコメントアウトする +- 先ほど作成した OpenAI 認証キーを追加する +- 以下のコードスニペットを追加する + +import QueryVectorSearch from './_snippets/academy.hello.query.vector.search.mdx'; + + + +:::tip Exercise +クエリコンセプトを "Major European city" から別のものに変えてみてください。結果は期待どおりでしょうか? +::: + +### 質問応答 + +この例では `WikiCity` オブジェクトを検索して、「When was the London Olympics?」に答えます。前回のコードを更新し、自分でも試してみてください。 + +import QueryQuestionAnswering from './_snippets/academy.hello.query.question.answering.mdx'; + + + +:::tip Exercise +質問を "When was the London Olympics?" から別の都市に関連する質問へ変えてみてください。どのような結果になりますか? + +どのような質問がよりうまく機能するか観察してみましょう。何かパターンに気づきますか? +::: + +### 生成検索 + +この例も `WikiCity` オブジェクトを検索しますが、 Weaviate の `generative-openai` モジュールを使用して結果を変換します。ここでは、東南アジアの都市についてのツイートを生成します。 + +デモコードを再度更新し、試してみてください: + +import QueryGenerativeSearch from './_snippets/academy.hello.query.generative.search.mdx'; + + + +:::tip Exercise +プロンプトを次のように変えてみてください: + +``` +"Write a tweet with a potentially surprising fact from {wiki_summary}" +``` + +\{wiki_summary} を外すとどうなりますか? +::: + +## 復習 + +### 復習用演習 + + + + + +### 重要なポイント + +- Weaviate では REST と GraphQL の 2 種類の API を使用します。 REST は CRUD 操作とメタデータ取得に使用され、 GraphQL はデータ検索、データオブジェクトの取得、ベクトル空間の探索に使用されます。 +- クライアントライブラリは REST / GraphQL の両 API へアクセスでき、 Weaviate インスタンスとのやり取りを簡便にします。 +- デモの Weaviate インスタンスに接続し、ベクトル検索、質問応答クエリ、生成検索を実行しました。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const apiRecap = [{ + questionText: 'Which of the following is not true about the Weaviate API?', + answerOptions: [ + { + answerText: 'Weaviate users can use both REST and GraphQL.', + isCorrect: false, + feedback: 'They are both available for all users, and serve complementary roles in communicating with Weaviate.', + }, + { + answerText: 'The REST API can be used to retrieve instance configuration data.', + isCorrect: false, + feedback: 'the `meta` endpoint is available for this purpose.', + }, + { + answerText: 'Both GraphQL and REST APIs can be used in Weaviate to perform vector searches.', + isCorrect: true, + feedback: 'Only the GraphQL API performs vector searches.', + }, + { + answerText: 'None of the above.', + isCorrect: false, + feedback: 'The truth is out there!', + }, + ] +}]; +export const clientLimits = [{ + questionText: 'What can\'t Weaviate clients do?', + answerOptions: [ + { + answerText: 'Analyze the retrieved results.', + isCorrect: true, + feedback: 'They cannot perform any data analysis.', + }, + { + answerText: 'Communicate with the Weaviate REST API.', + isCorrect: false, + feedback: 'They can all perform REST API requests.', + }, + { + answerText: 'Communicate with the Weaviate GraphQL API.', + isCorrect: false, + feedback: 'They can all perform GraphQL API requests.', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/90_wrap_up.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/90_wrap_up.mdx new file mode 100644 index 000000000..da93366af --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/90_wrap_up.mdx @@ -0,0 +1,28 @@ +--- +title: まとめ +description: Hello Weaviate のまとめ +sidebar_position: 90 +--- + +## ユニットレビュー + +このユニットでは、 Weaviate の概要をお伝えすることを目指しました。 + +まず、 Weaviate が何であり何ができるかを説明し、その後にベクトルデータベースとベクトル検索について議論し、実際に Weaviate を起動してベクトル検索を実行していただきました。 + +これで、データベースの構築方法やクエリの実行など、 Weaviate についてさらに学習を進めるための基礎知識が身に付きました。まもなく、みなさん自身のプロジェクトを Weaviate で作成できるようになるでしょう。 + +### 学習成果 + +このユニットを終えた今、次のことができるようになっているはずです: +- Weaviate が何かを大まかに説明できる。 +- ベクトル検索とは何かを概説できる。 +- WCD 上に Weaviate インスタンスを作成できる。 +- お好みの Weaviate クライアント(Weaviate Academy では Python)をインストールできる。 +- Weaviate の機能の一部を説明できる。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.clients.graphql.get.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.clients.graphql.get.mdx new file mode 100644 index 000000000..94c19b6a6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.clients.graphql.get.mdx @@ -0,0 +1,115 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```graphql +{ + Get { + WikiArticle { + title + wiki_summary + } + } +} +``` + + + + +```python +result = client.query.get("WikiArticle", ["title", "wiki_summary"]).do() +``` + + +{/* + +import weaviate from 'weaviate-ts-client'; +```js + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace WEAVIATE_INSTANCE_URL with your instance URL +}); + +const response = await client.graphql + .get() + .withClassName('WikiArticle') + .withFields('title wiki_summary') + .do(); +console.log(JSON.stringify(response, null, 2)); +``` + + + + +import ( +```go +package main + + "context" + "fmt" + + "github.com/weaviate/weaviate-go-client/v5/weaviate" + "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql" +) + +func main() { + cfg := weaviate.Config{ + Host: "WEAVIATE_INSTANCE_URL", // Replace WEAVIATE_INSTANCE_URL with your instance URL + Scheme: "http", + } + client := weaviate.New(cfg) + fields := []graphql.Field{ + {Name: "title"}, + {Name: "wiki_summary"}, + } + ctx := context.Background() + result, err := client.GraphQL().Get(). + WithClassName("WikiArticle"). + WithFields(fields...). + Do(ctx) + if err != nil { + panic(err) + } + fmt.Printf("%v", result) +} +``` + + + + +import technology.semi.weaviate.client.Config; +import technology.semi.weaviate.client.WeaviateClient; +import technology.semi.weaviate.client.base.Result; +import technology.semi.weaviate.client.v1.graphql.model.GraphQLResponse; +import technology.semi.weaviate.client.v1.graphql.query.fields.Field; +```java +package technology.semi.weaviate; + + +public class App { + public static void main(String[] args) { + Config config = new Config("https", "WEAVIATE_INSTANCE_URL"); + // Replace WEAVIATE_INSTANCE_URL with your instance URL + WeaviateClient client = new WeaviateClient(config); + + Field title = Field.builder().name("title").build(); + Field url = Field.builder().name("wiki_summary").build(); + + Result result = client.graphQL().get() + .withClassName("WikiArticle") + .withFields(title, url, wordCount) + .run(); + if (result.hasErrors()) { + System.out.println(result.getError()); + return; + } + System.out.println(result.getResult()); + } +} +``` + + */} + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.clients.rest.object.get.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.clients.rest.object.get.mdx new file mode 100644 index 000000000..13c86110c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.clients.rest.object.get.mdx @@ -0,0 +1,106 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```shell +curl http://localhost:8080/v1/meta +``` + + + + +```python +import weaviate + +client = weaviate.Client("http://localhost:8080") + +print(client.get_meta()) +``` + + +{/* + +```js +import weaviate from 'weaviate-ts-client'; + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace WEAVIATE_INSTANCE_URL with your instance URL +}); + +const response = await client.data + .getterById() + .withClassName('WikiArticle') + .withId('36ddd591-2dee-4e7e-a3cc-eb86d30a4303') + .do(); +console.log(JSON.stringify(response, null, 2)); +``` + + + + +```go +package main + +import ( + "context" + "fmt" + + "github.com/weaviate/weaviate-go-client/v5/weaviate" +) + +func main() { + cfg := weaviate.Config{ + Host: "WEAVIATE_INSTANCE_URL", + Scheme: "https", + } + client := weaviate.New(cfg) + + data, err := client.Data().ObjectsGetter(). + WithClassName("WikiArticle"). + WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303"). + Do(context.Background()) + + if err != nil { + panic(err) + } + fmt.Printf("%v", data) +} +``` + + + + +```java +package technology.semi.weaviate; + +import java.util.List; +import technology.semi.weaviate.client.Config; +import technology.semi.weaviate.client.WeaviateClient; +import technology.semi.weaviate.client.base.Result; +import technology.semi.weaviate.client.v1.data.model.WeaviateObject; + +public class App { + public static void main(String[] args) { + Config config = new Config("https", "WEAVIATE_INSTANCE_URL"); + // Replace WEAVIATE_INSTANCE_URL with your instance URL + WeaviateClient client = new WeaviateClient(config); + + Result> result = client.data().objectsGetter() + .withClassName("WikiArticle") + .withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303") + .run(); + + if (result.hasErrors()) { + System.out.println(result.getError()); + return; + } + System.out.println(result.getResult()); + } +} +``` + + */} + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.check.connection.edudemo.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.check.connection.edudemo.mdx new file mode 100644 index 000000000..20f3ad22f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.check.connection.edudemo.mdx @@ -0,0 +1,62 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +import weaviate +import json + +auth_config = weaviate.auth.AuthApiKey(api_key="readonly-demo") + +# Instantiate the client +client = weaviate.Client( + url="https://edu-demo.weaviate.network", + auth_client_secret=auth_config, + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", # Replace with your OpenAI key + } +) + +meta_info = client.get_meta() +print(json.dumps(meta_info, indent=2)) +``` + + + + +
+ 期待される出力 + +```json +{ + "hostname": "http://[::]:8080", + "modules": { + "generative-openai": { + "documentationHref": "https://beta.openai.com/docs/api-reference/completions", + "name": "Generative Search - OpenAI" + }, + "qna-openai": { + "documentationHref": "https://beta.openai.com/docs/api-reference/completions", + "name": "OpenAI Question & Answering Module" + }, + "ref2vec-centroid": {}, + "text2vec-cohere": { + "documentationHref": "https://docs.cohere.com/docs/embeddings", + "name": "Cohere Module" + }, + "text2vec-huggingface": { + "documentationHref": "https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task", + "name": "Hugging Face Module" + }, + "text2vec-openai": { + "documentationHref": "https://beta.openai.com/docs/guides/embeddings/what-are-embeddings", + "name": "OpenAI Module" + } + }, + "version": "1.18.2" +} +``` + +
\ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.check.connection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.check.connection.mdx new file mode 100644 index 000000000..c1730e3d9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.check.connection.mdx @@ -0,0 +1,59 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +import weaviate +import json + +auth_config = weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY") # Replace with your Weaviate API key + +# Instantiate the client +client = weaviate.Client( + url="https://your-endpoint.weaviate.network", # Replace with your sandbox URL + auth_client_secret=auth_config, +) + +meta_info = client.get_meta() +print(json.dumps(meta_info, indent=2)) +``` + + + + +
+ 期待される出力 + +```json +{ + "hostname": "http://[::]:8080", + "modules": { + "generative-openai": { + "documentationHref": "https://beta.openai.com/docs/api-reference/completions", + "name": "Generative Search - OpenAI" + }, + "qna-openai": { + "documentationHref": "https://beta.openai.com/docs/api-reference/completions", + "name": "OpenAI Question & Answering Module" + }, + "ref2vec-centroid": {}, + "text2vec-cohere": { + "documentationHref": "https://docs.cohere.com/docs/embeddings", + "name": "Cohere Module" + }, + "text2vec-huggingface": { + "documentationHref": "https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task", + "name": "Hugging Face Module" + }, + "text2vec-openai": { + "documentationHref": "https://beta.openai.com/docs/guides/embeddings/what-are-embeddings", + "name": "OpenAI Module" + } + }, + "version": "1.18.2" +} +``` + +
\ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.client.instantiation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.client.instantiation.mdx new file mode 100644 index 000000000..6368b7eaa --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.client.instantiation.mdx @@ -0,0 +1,26 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +import weaviate + +# Only if authentication enabled; assuming API key authentication +auth_config = weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY") # Replace with your Weaviate instance API key + +# Instantiate the client +client = weaviate.Client( + url="https://example.weaviate.network", + auth_client_secret=auth_config, # Only necessary if authentication enabled + additional_headers={ + "X-Cohere-Api-Key": "YOUR-COHERE-API-KEY", # Replace with your Cohere key + "X-HuggingFace-Api-Key": "YOUR-HUGGINGFACE-API-KEY", # Replace with your Hugging Face key + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", # Replace with your OpenAI key + } +) +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.generative.search.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.generative.search.mdx new file mode 100644 index 000000000..152757503 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.generative.search.mdx @@ -0,0 +1,48 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +res = client.query.get( + "WikiCity", ["city_name", "wiki_summary"] +).with_near_text({ + "concepts": ["Popular Southeast Asian tourist destination"] +}).with_limit(3).with_generate( + single_prompt=\ + "Write a tweet with a potentially surprising fact from {wiki_summary}" +).do() + +for city_result in res["data"]["Get"]["WikiCity"]: + print(json.dumps(city_result["_additional"], indent=2)) +``` + + + + +
+ 期待される出力 + +```json +{ + "generate": { + "error": null, + "singleResult": " #FunFact: Bangkok is the world's most visited city, with over 22 million visitors in 2019! #Bangkok #Thailand #Travel" + } +} +{ + "generate": { + "error": null, + "singleResult": "Did you know that Ho Chi Minh City is home to many multinational companies and generates nearly a quarter of Vietnam's total GDP? #HCMC #Vietnam #Economy" + } +} +{ + "generate": { + "error": null, + "singleResult": "Surprising fact: Singapore is the only country in Asia with a AAA sovereign credit rating from all major rating agencies. #Singapore #AAA #CreditRating" + } +} +``` + +
\ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.question.answering.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.question.answering.mdx new file mode 100644 index 000000000..4ffc17366 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.question.answering.mdx @@ -0,0 +1,54 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +ask = { + "question": "When was the London Olympics?", + "properties": ["wiki_summary"] +} + +res = ( + client.query + .get("WikiCity", [ + "city_name", + "_additional {answer {hasAnswer property result} }" + ]) + .with_ask(ask) + .with_limit(1) + .do() +) + +print(json.dumps(res, indent=2)) +``` + + + + +
+ 期待される出力 + +```json +{ + "data": { + "Get": { + "WikiCity": [ + { + "_additional": { + "answer": { + "hasAnswer": true, + "property": "wiki_summary", + "result": " 2012" + } + }, + "city_name": "London" + } + ] + } + } +} +``` + +
\ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.vector.search.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.vector.search.mdx new file mode 100644 index 000000000..519fdb16b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/_snippets/academy.hello.query.vector.search.mdx @@ -0,0 +1,64 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +res = client.query.get( + "WikiCity", ["city_name", "country", "lng", "lat"] +).with_near_text({ + "concepts": ["Major European city"] +}).with_limit(5).do() + +print(json.dumps(res, indent=2)) +``` + + + + +
+ 期待される出力 + +```json +{ + "data": { + "Get": { + "WikiCity": [ + { + "city_name": "Paris", + "country": "France", + "lat": 48.8566, + "lng": 2.3522 + }, + { + "city_name": "London", + "country": "United Kingdom", + "lat": 51.5072, + "lng": -0.1275 + }, + { + "city_name": "Madrid", + "country": "Spain", + "lat": 40.4167, + "lng": -3.7167 + }, + { + "city_name": "Berlin", + "country": "Germany", + "lat": 52.5167, + "lng": 13.3833 + }, + { + "city_name": "Budapest", + "country": "Hungary", + "lat": 47.4983, + "lng": 19.0408 + } + ] + } + } +} +``` + +
\ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/index.mdx new file mode 100644 index 000000000..c9a2bf51d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/101_hello_weaviate/index.mdx @@ -0,0 +1,46 @@ +--- +title: P3_101 こんにちは、 Weaviate +description: " Weaviate を始めましょう: セットアップとデータクエリのための入門ガイドです。" +sidebar_position: 101 # Like a subject number (e.g. CS101) +--- + +import ZeroToMvpDeprecationNote from '/docs/academy/py/zero_to_mvp/_snippets/deprecation.md'; + + + +## ユニット概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ + + +ようこそ! + +これは、 Weaviate と共にベクトルの世界を探求する旅の始まりです。このユニットでは、 Weaviate の基礎について概観します。 + +まず、 Weaviate が何であり、何ができるのかを理解します。その後、ベクトルデータベースとベクトル検索とは何かを学び、実際に Weaviate を起動してベクトル検索を実行します。 + +ユニットの終わりには、この後のコースをスムーズに進めたり、ご自身のプロジェクトで Weaviate を活用したりするための強固な基礎知識が身に付きます。 + +### 前提条件 + +- なし + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/10_get.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/10_get.mdx new file mode 100644 index 000000000..6632c3c61 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/10_get.mdx @@ -0,0 +1,298 @@ +--- +title: Get{} オブジェクト +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/10_get.py'; + +:::info Weaviate Academy 準備を完了してください +このユニットを始める前に、必ず [Weaviate Academy Preparation](../setup.mdx) ミニユニットを完了し、クライアントライブラリを実行してデモ Weaviate インスタンスに問題なく接続できることを確認してください。 +


+ +以下のコードスニペットにはクライアントのインスタンス化部分が含まれていません。実行前に、下記の例のようにクライアントをインスタンス化してください。 + + + + + + +::: + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +## `Get` クエリについて + +多くのユースケースにおいて、 Weaviate インスタンスからオブジェクトを取得することは最も一般的な操作となります。 + +例えば、入力クエリに最も関連する複数の文章を取得したり、ある画像に最も類似した画像を取得したりできます。さらに、特定の文章に最も合致する画像セットを取得することも可能です。 + + Weaviate では、このようなオブジェクト取得操作を `Get` 関数で実行します。 + +### `Get` 関数の構文 + +基本的な `Get` 関数は次のようになります。 + +import GetSyntax from './_snippets/academy.queries.get.syntax.mdx'; + + + +- `Class` フィールドは取得対象オブジェクトのクラス名を指定します。 +- `arguments` 引数はオブジェクトを検索する際の条件を指定します。 +- `properties` 引数は取得したいオブジェクトのプロパティを指定し、`_additional` プロパティも含めることができます。 + +それでは、具体的な `Get` クエリを試してみましょう。 + +## スタandalone `Get` クエリ + +基本的なスタンドアロンの `Get` クエリは次のようになります。 + +### 例 + +import GetStandalone from './_snippets/academy.queries.get.standalone.mdx'; + + + + + + + + + + + + +どのような結果が返ってくると思いますか? 各フィールドを構文と対応させてみてください。 + +では実際に実行してみましょう。クエリは次のような結果を返します。 + +
+ JSON レスポンスを見る + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "answer": "Amazon.com", + "question": "On July 16, 1995 this company made its first sale, a science textbook" + }, + { + "answer": "Parfait", + "question": "The French name of this layered ice cream dessert means \"perfect\"" + } + ] + } + } +} +``` + +
+ +### Weaviate からのレスポンスオブジェクト + +上記のとおり、 Weaviate からのレスポンスは JSON 形式で、結果は `data` フィールドから取得できます。レスポンスはクエリ内容および対象オブジェクトを反映する形で整理されています。 + +この例では、`Get` フィールドがクエリ関数を、`JeopardyQuestion` フィールドが取得対象クラスを表し、その配下に返却されたオブジェクトが格納されています。各オブジェクトは、要求した `answer` と `question` のプロパティを持ちます。 + +
+ このクエリを解説 + +このクエリでは `.with_limit(2)` 引数により 2 件のオブジェクトが返されます。これを指定しない場合、 Weaviate は設定に応じた最大件数を返します。 + +:::tip このクエリは便利? +ユーザー固有の検索条件を適用していないため、得られる具体的な結果はそれほど有用でない可能性があります。 + +しかし、 Weaviate インスタンスへ接続できるか、データが正しく取り込まれているかなどの「サニティチェック」としては有効です。 +::: + +
+ +### `Class` と `properties` + +上の例では `Class` に `JeopardyQuestion`、`properties` に `question` と `answer` を指定しました。 + +これは、 Weaviate 内のデータ構造に合わせているため可能です。利用可能なデータクラスとプロパティを確認するには、以下のようにスキーマを確認できます。 + +
+ スキーマを見るには? + +次のようにしてスキーマを取得できます。試してみてください! + +```python +client.schema.get() +``` + +
+ +import ShortSchema from './_snippets/academy.queries.schema.short.mdx'; + + + +`Class` と `properties` は、 Weaviate スキーマで定義されたオブジェクトコレクションに対応している必要があります。 + +`Class` にはデータオブジェクトコレクションの名前を、`properties` には取得したいプロパティのリストを指定します。 + +スキーマには `JeopardyQuestion` クラスがあり、`question`、`answer`、`points` のプロパティを持っています。 + +したがって、`JeopardyQuestion` クラスのオブジェクトを取得するクエリでは、`question`、`answer`、`points` のいずれのプロパティも指定できます。 + +:::note 演習 +上記のクエリを再度実行し、次の変更を試してください。 +- `points` プロパティも取得できますか? +- プロパティを指定しないとどうなりますか? +::: + +:::info 複数のクラスを同時に検索できますか? +いいえ、1 度に検索できるのは 1 クラスのみです。 +


+ +各クラスは 1 つの `vector space` を構成しているためです。複数のオブジェクトコレクションを検索したい場合は、複数回検索するか、1 つのクラスにまとめてフィルターで区別する方法をご検討ください。 +


+ +このトピックについては、各クラスが独立した `vector space` を構成する意味や、 Weaviate でスキーマ設計を考える際のポイントを後のユニットで詳しく扱います。 +::: + +## `Get` と `additional` プロパティ + +スキーマで定義されていない追加プロパティを取得できます。これらのプロパティはオブジェクトに固有であったり、実行したクエリに関連している場合があります。 + +### 例 + +この例では、前の例を基に `.with_additional` メソッドを追加しています。 + +import GetWithAdditional from './_snippets/academy.queries.get.with.additional.mdx'; + + + +再度、レスポンスがどのようになるかを考えてみましょう。レスポンスのどこが変わるでしょうか。 + +では実際に試してみてください。クエリは次のような結果を返すはずです。 + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.1791926, + "id": "b1645a32-0c22-5814-8f35-58f142eadf7e" + }, + "answer": "escaping the Earth's gravity (and go off into outer space, on your way to the moon, for instance)", + "question": "It takes approximately 24,840 MPH to achieve this" + }, + { + "_additional": { + "distance": 0.18123823, + "id": "ef263438-b152-5540-97f7-99f4076bd124" + }, + "answer": "the Milky Way", + "question": "This is the name of our own galaxy" + } + ] + } + } +} +``` + +
+ +### Weaviate からのレスポンスオブジェクト + +このレスポンスでは、`_additional` フィールドが追加され、その下に `distance` と `id` が入っていることがわかります。 + +
+ クエリの解説 + +ここで `distance` と `id` プロパティには、それぞれクエリとの距離とオブジェクトの一意な ID が格納されています。 + +
+ +### `_additional` プロパティ + +名前が示すとおり、`_additional` プロパティはクラスプロパティとして明示的に作成されたものとは別物です。 + +上記のクエリでは `_additional` フィールドに `distance` プロパティを含めました。これは入力ベクトルとオブジェクトのベクトルとの類似度(この場合は *非類似度*)を表します。 + +:::info `_additional` で取得できるベクトル + +オブジェクトのベクトルも、サブフィールドに `vector` を指定することで `_additional` フィールドから取得できます。 + +返されるベクトルは多くの場合、非常に長い数値のリストになる点に注意してください。 + +::: + +:::note 演習 +上記のクエリを以下の変更を加えて再度試してみましょう。 +- `vector` プロパティも取得できますか? +- 以前は `.get()` メソッドでメインプロパティに空のリストを渡すとエラーになりました。追加プロパティをリクエストした状態で再度実行するとどうなりますか? +::: + +## 復習 + +### 復習演習 + +本文中のインライン演習をご覧ください。 + +### 主要ポイント + +- `'Get'` 関数を使用して Weaviate からオブジェクトを取得できます。 +- `'Get'` 関数の構文では、クラス、プロパティ、および検索条件に関連する追加引数を指定する必要があります。 +- Weaviate のレスポンスは JSON 形式です。 +- クラスとプロパティのフィールドは、Weaviate スキーマで定義したオブジェクトとプロパティに対応している必要があります。 +- `'Get'` クエリでは、スキーマで定義されていない追加プロパティを取得できます。これらはオブジェクトに固有であったり、実行したクエリに関連する場合があります。 +- `_additional` プロパティには `distance`、`id`、`vector` などが含まれ、取得したオブジェクトに関するさらなる文脈と情報を提供します。 + +import Quiz from '/src/components/Academy/quiz.js' +export const nearText = [{ + questionText: 'questionText', + answerOptions: [ + { + answerText: 'answerOne', + isCorrect: false, + feedback: 'feedbackOne', + }, + { + answerText: 'answerTwo', + isCorrect: false, + feedback: 'feedbackTwo', + }, + { + answerText: 'answerThree', + isCorrect: false, + feedback: 'feedbackThree', + }, + ] +}]; + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/20_vector_parameters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/20_vector_parameters.mdx new file mode 100644 index 000000000..d7c223c51 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/20_vector_parameters.mdx @@ -0,0 +1,297 @@ +--- +title: 検索オペレーター +description: Weaviate でデータ検索を最適化するために ベクトル パラメーターを調整する方法を学びます。 +--- + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +Weaviate では複数の ベクトル 検索「オペレーター」を提供しており、それらを使って ベクトル 検索を実行できます。一般的にユーザーは `nearVector`、`nearObject`、または `near`(例: `nearText`)のいずれかを使用します。本章ではこれらのメソッドを順に確認します。 + +## `nearVector` + +`nearVector` オペレーターは、明示的に指定した ベクトル に最も類似したオブジェクトを検索する際に使用します。 + +以下のように `vector` 引数で ベクトル 値を渡します。 + +### 例 + +:::note Vector truncated for brevity +以下の ベクトル は省略表示されています。セルを実行したい場合は、下記に完全な ベクトル を確認できます。 +::: + +
+ 完全な ベクトル を表示 + +[0.023932384327054024, -0.014095712453126907, 0.013304559513926506, -0.01155742909759283, -0.01147831417620182, 0.015321999788284302, -0.025013625621795654, -0.04198386147618294, 0.0006061387248337269, -0.008940030820667744, ... 省略 ...] +
+ +import NearVectorSimple from './_snippets/academy.queries.nearVector.simple.mdx'; + + + +レスポンスを確認したりクエリを実行したりする前に、次の点を考えてみてください。 +- レスポンスには何件のオブジェクトが含まれると予想しますか? +- 各オブジェクトにはどのプロパティが含まれると思いますか? +- この ベクトル が何を表しているか分かりますか? + +
+ JSON レスポンスを見る + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "answer": "escaping the Earth's gravity (and go off into outer space, on your way to the moon, for instance)", + "question": "It takes approximately 24,840 MPH to achieve this" + }, + { + "answer": "the Milky Way", + "question": "This is the name of our own galaxy" + } + ] + } + } +} +``` + +
+ +
+ このクエリの説明 + +- `limit` を 2 に設定したため、結果には最大 2 件のオブジェクトが含まれます。 +- 各オブジェクトには `Get` 関数で指定した `question` と `answer` プロパティが含まれます。 +- ベクトル は外部から提供されたため、それが何を表すかを判断する方法はありません。(結果から宇宙に関連する内容だと推測はできます。) + +
+ +## `nearObject` + +`nearObject` オペレーターは、既存の Weaviate オブジェクトに最も類似したオブジェクトを検索する際に使用します。 + +対象オブジェクトの識別子は、以下のように `id` 引数で渡します。 + +### 例 + +import NearObjectSimple from './_snippets/academy.queries.nearObject.simple.mdx'; + + + +レスポンスを確認したりクエリを実行したりする前に、次の点を考えてみてください。 +- ここでは ベクトル を提供していません。 ベクトル はどこから来るのでしょうか? + +
+ JSON レスポンスを見る + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "answer": "escaping the Earth's gravity (and go off into outer space, on your way to the moon, for instance)", + "question": "It takes approximately 24,840 MPH to achieve this" + }, + { + "answer": "66,000", + "question": "Of 6,000, 66,000 or 666,000 MPH, the closest to the speed of the Earth around the sun" + } + ] + } + } +} +``` + +
+ +
+ このクエリの説明 + +- `nearObject` クエリでは、指定したオブジェクト自身の ベクトル がクエリ ベクトル として使用されます。 + +
+ +## `nearText` + +`nearText` オペレーターは、テキスト入力に最も類似したオブジェクトを検索する際に使用します。 + +以下のように `concept` 引数でテキストを渡します。 + +### 例 + +import NearTextSimple from './_snippets/academy.queries.nearText.simple.mdx'; + + + +レスポンスを確認したりクエリを実行したりする前に、次の点を考えてみてください。 +- ここでも ベクトル を提供していません。今回は ベクトル はどこから来るのでしょうか? + +
+ JSON レスポンスを見る + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "answer": "escaping the Earth's gravity (and go off into outer space, on your way to the moon, for instance)", + "question": "It takes approximately 24,840 MPH to achieve this" + }, + { + "answer": "the Milky Way", + "question": "This is the name of our own galaxy" + } + ] + } + } +} +``` + +
+ +
+ このクエリの説明 + +`nearText` では、入力されたテキストを Weaviate が ベクトル に変換します。 + +そのため `nearText` には、入力メディアを ベクトル に変換する仕組みが必要です。Weaviate ではこれを `vectorizer` と呼びます。 + +:::info ベクトライザーはどのように機能しますか? +Weaviate では、ベクトライザーはオプションの `modules` として追加されます。モジュールと ベクトライザー については後のユニットで学びます。 +::: + +
+### `near` + +`nearText` はテキストを扱うためにここで使用しました。画像用の `nearImage` など、他のメディア向けの演算子もあります。これらを総称して `near` 演算子と呼びます。 + +これらすべての演算子の原理は同じで、入力メディアに最も近い結果を取得します。 + +## 閾値の追加 + +ベクトル検索は類似度に基づいており、結果を自動的に除外することはありません。デフォルトでは、ベクトル検索はシステムで定義された最大件数の結果を返します。結果数を制限するには、閾値または limit を設定します。 + +### 距離の閾値 + +`distance` や `certainty` のような閾値は、オブジェクトを取得するために必要な最大距離(言い換えると最小類似度)を指定します。この例では、`distance` が結果を制限する `additional` パラメーターとして使われています。 + +import GetWithAdditional from './_snippets/academy.queries.get.with.additional.mdx'; + + + +これは返却例です。 + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.1791926, + "id": "b1645a32-0c22-5814-8f35-58f142eadf7e" + }, + "answer": "escaping the Earth's gravity (and go off into outer space, on your way to the moon, for instance)", + "question": "It takes approximately 24,840 MPH to achieve this" + }, + { + "_additional": { + "distance": 0.18123823, + "id": "ef263438-b152-5540-97f7-99f4076bd124" + }, + "answer": "the Milky Way", + "question": "This is the name of our own galaxy" + } + ] + } + } +} +``` + +
+ +:::tip Exercise: Threshold distances +次のいずれかを変更して試してみましょう +- `distance` ではなく `certainty` の閾値を使用する +- `distance` に加えて `certainty` も返す +期待どおりの動作になりましたか? +::: + +この文脈では、`distance` は差異の度合いを測定します。場合によっては `certainty` が使われることもあります。これは `distance` とは逆で、値が大きいほど意味の差が大きいことを示します。 + +これらの値が正確には何を意味し、どこから来るのかについては後ほど説明します。現時点では次の点を覚えておいてください。 + +- `distance` は非類似度の指標です(値が小さいほど類似しています) +- `certainty` は類似度の指標です(値が大きいほど類似しています) + +### `limit` 閾値 + +前述の例のいくつかでは `limit` 句を使用しています。`limit` を使うと、返されるオブジェクト数を制限できます。 + +この Python の例では、`with_limit()` が 2 件の応答に制限しています。 + +``` +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2) +``` + + +## おさらい + +### 復習問題 + + + +### 重要なポイント + +:::info `nearVector` / `nearObject` availability +`nearVector` と `nearObject` は常に Weaviate で利用可能ですが、`nearText` はベクトライザー モジュールが有効で使用されている場合にのみ利用できます。 +::: + +- ベクトル検索を実行するために複数の検索演算子が利用できます。 +- `nearVector` は入力ベクトルに最も近いオブジェクトを検索できます。 +- `nearObject` は既存の Weaviate オブジェクトに最も近いオブジェクトを検索できます。 +- `nearText` は入力テキストに最も近いオブジェクトを検索できます。 + - 他のオブジェクト型向けには、対応する `near` 演算子があります。 +- 独自のベクトライザーを使用する場合やすでにベクトルのライブラリを持っている場合は、`nearVector` クエリを使用することがあります。既存のオブジェクトに類似したオブジェクトを探したい場合には `nearObject` が便利です。 + +import Quiz from '/src/components/Academy/quiz.js' +export const nearVectorFunction = [{ + questionText: 'On what basis does the nearVector operator perform a search?', + answerOptions: [ + { + answerText: 'Similarity to a given text input', + isCorrect: false, + feedback: 'That would be nearText', + }, + { + answerText: 'Similarity to a provided vector', + isCorrect: true, + feedback: 'So if you have the query vector handy, nearVector is the operator to use.', + }, + { + answerText: 'Similarity to an existing Weaviate object', + isCorrect: false, + feedback: 'That would be nearObject', + }, + ] +}]; + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/40_aggregate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/40_aggregate.mdx new file mode 100644 index 000000000..74d8e7792 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/40_aggregate.mdx @@ -0,0 +1,357 @@ +--- +title: Aggregate{} による結果セットの集計 +description: Weaviate で aggregate クエリを用いてデータ インサイトを要約します。 +--- + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +`Get` で個別オブジェクトを取得する方法を確認したので、次は `Aggregate` を使って情報をまとめる方法を見ていきましょう。 + +`Aggregate` は複数オブジェクトから情報をまとめて単一の結果にする強力な機能で、結果の概要を素早く把握できます。 + +## `Aggregate` クエリについて + +### `Aggregate` 関数の構文 + +`Aggregate` クエリの全体構造は `Get` クエリに似ていますが、結果セット全体に対するクエリであるため重要な違いがあります。 + +`Aggregate` クエリの基本構文は次のとおりです。 + +import AggregateSyntax from './_snippets/academy.queries.aggregate.syntax.mdx'; + + + +`Get` クエリとは異なり、`Aggregate` で使用できるプロパティは、クエリ対象プロパティのデータ型によって異なります。 + +これはデータ型ごとに実行可能な操作が異なるためです。たとえば、`String` プロパティで利用できるプロパティは、`Integer` プロパティやクロスリファレンスの場合とは異なります。 + +それでは実際に `Aggregate` クエリを試してみましょう。 + +参考までに、オブジェクトには次のスキーマがあります。 + +
+ 関連スキーマを表示 + +import ShortSchema from './_snippets/academy.queries.schema.short.mdx'; + + + +
+ +## 単独の `Aggregate` クエリ + +### 例 1 + +次のクエリを見てください。 + +import AggregateStandalone from './_snippets/academy.queries.aggregate.standalone.mdx'; + + + +どのような結果が返ってくると予想しますか? + +では実際に試してみましょう。 + +クエリを実行すると、次のような結果が返ってくるはずです。 + +
+ JSON レスポンスを見る + +```json +{ + "data": { + "Aggregate": { + "JeopardyQuestion": [ + { + "meta": { + "count": 10000 + } + } + ] + } + } +} +``` + +
+ +### Weaviate からのレスポンス オブジェクト + +このレスポンスには、`JeopardyQuestion` クラスから要求された `meta` 情報を表すオブジェクトが含まれています。`meta` オブジェクトには `count` プロパティがあり、クラス内のオブジェクト総数を示します。 + +
+ このクエリの説明 + +このクエリは `JeopardyQuestion` クラスのオブジェクトを集計し、総数を取得します。絞り込みがないため、オブジェクトの総数 10,000 が返されます。 + +
+ +### `meta` プロパティ + +上記の `Aggregate` クエリでは、オブジェクト数を取得するために `meta` プロパティを指定しました。これはオブジェクト クラス自体の利用可能プロパティではない点に注意してください。ここが `Aggregate` と `Get` クエリの大きな違いです。 + +`Get` クエリは個々の結果セットを取得するため、各結果に適用されるプロパティ(例: `id` やデータ固有の `answer` など)を選択できます。 + +一方 `Aggregate` クエリは結果の集計を返すため、結果セット全体に適用されるサブプロパティを指定する必要があります。 + +`meta` プロパティはその一例です。すべてのデータ型で利用でき、`count` サブプロパティと組み合わせて取得オブジェクト数を返せます。 + +### 例 2 + +次のクエリを見てください。 + +import AggregateStandalone2 from './_snippets/academy.queries.aggregate.standalone.2.mdx'; + + + +結果にはどのフィールドが返ってくると予想しますか? + +では実際に試してみましょう。 + +クエリを実行すると、次のような結果が返ってくるはずです。 + +
+ JSON レスポンスを見る + +```json +{ + "data": { + "Aggregate": { + "JeopardyQuestion": [ + { + "answer": { + "count": 10000, + "topOccurrences": [ + { + "occurs": 19, + "value": "Australia" + }, + { + "occurs": 18, + "value": "Hawaii" + }, + { + "occurs": 16, + "value": "Boston" + }, + { + "occurs": 15, + "value": "French" + }, + { + "occurs": 15, + "value": "India" + } + ] + } + } + ] + } + } +} +``` +
+ +
+ このクエリの説明 + +このレスポンスには、`JeopardyQuestion` クラスの `answer` プロパティに対する集計結果が含まれています。テキスト情報を含むプロパティのため、`value`(トークン)や `occurs`(出現回数)といった `topOccurrences` 情報を集計できます。 + +
+ +:::tip 利用可能なプロパティ +利用可能なプロパティの一覧は、ドキュメントの [こちらのページ](/weaviate/api/graphql/aggregate.md) でご確認いただけます。 +::: + +## 検索オペレーターを用いた `Aggregate` + +`Get` クエリと同様に、`Aggregate` クエリでも `nearText` などの検索オペレーターを使用できます。以下をご覧ください。 + +### 例(`nearText` 使用) + +たとえば、個々の質問ではなく回答全体を俯瞰したいとします。たとえば、このクエリに関連する質問が何件あるのか知りたい場合です。 + +import AggregateWithNearText from './_snippets/academy.queries.aggregate.with.neartext.mdx'; + + + +レスポンスを確認したりクエリを実行したりする前に、次の点を考えてみてください。 +- 何件の結果が返されると予想しますか? +- `distance` パラメーターを大きくすると、結果数がどのように変化するか予想できますか? + +さて、実際に試してみましょう。このクエリは次のような結果を返すはずです: + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Aggregate": { + "JeopardyQuestion": [ + { + "meta": { + "count": 9 + } + } + ] + } + } +} +``` + +
+ +
+ このクエリを解説 + +このクエリは、`distance` 引数によって制限された結果を集計しています。この引数はしきい値となり、入力に関連する結果だけを返します。これがなければ、検索結果にはクラス全体が含まれる可能性があります。 + +これを「検索空間を制限する」と呼びます。 + +
+ +### 検索空間の制限 + +ベクトル 検索で意味のある集計を行うには、検索空間を制限する必要があります。 + +これは、リレーショナル データベースでの集計とは異なります。リレーショナル データベースでは、`groupby` と SUM、AVG、MIN、MAX などの関数を組み合わせてデータをグループ化または集計できます。この方法では、まず結果セットを取得し、その後で結果を集計します。 + +しかし、ベクトル 検索は本質的に結果を除外しません。ベクトル 検索は類似度の度合いに基づいて結果を取得するためです。 + +したがって、関連する結果だけが集計に含まれるように検索空間を制限しなければなりません。そのためには、クエリで明示的な `limit` を設定するか、`distance` または `certainty` といったしきい値を指定します。 + +## `groupBy` を用いた `Aggregate` + +これまで、`Aggregate` クエリを使って 1 つの結果セットに関する情報を集約する方法を見てきました。`groupBy` 引数を追加すると、複数のサブセットから情報をまとめることができます。 + +### 例 + +たとえば、各 `value` プロパティにつき質問が何件あるかを知りたいとします。その場合は、クエリに `groupBy` 引数を追加します: + +import AggregateGroupby from './_snippets/academy.queries.aggregate.groupby.mdx'; + + + +ここではどのような結果になると予想しますか?`groupBy` 引数を追加したことで結果はどのように変わるでしょうか?さらにクエリの他の変更点に気付きましたか? + +では実際に試してみましょう。クエリは次のような結果を返すはずです: + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Aggregate": { + "JeopardyQuestion": [ + { + "groupedBy": { + "path": [ + "round" + ], + "value": "Double Jeopardy!" + }, + "meta": { + "count": 5 + } + }, + { + "groupedBy": { + "path": [ + "round" + ], + "value": "Jeopardy!" + }, + "meta": { + "count": 3 + } + }, + { + "groupedBy": { + "path": [ + "round" + ], + "value": "Final Jeopardy!" + }, + "meta": { + "count": 1 + } + } + ] + } + } +} +``` + +
+ +
+ このクエリを解説 + +このクエリでは追加で `groupedBy` 引数を指定しており、その結果、`round` ごとの件数が取得されます。また、`groupedBy` プロパティを要求しているため、各件数は `round` グループごとの `value` で識別できます。 + +
+ +### `groupBy` と `groupedBy` + +`Aggregate` クエリで取得した結果は、さらに `groupBy` 引数を使ってグループ化できます。この引数にはプロパティのリストを渡し、そのプロパティの値で結果をグループ化します。 + +これは、ベクトル 検索の結果サブセットの特徴を把握する際に特に有用なクエリ パターンです。 + +`groupBy` 引数を使用すると、追加で `groupedBy` プロパティが返されます。このプロパティとそのサブプロパティにより、各結果が属するグループを判別できます。 + +:::note 演習 +上記のクエリを再度試し、次の変更を加えてみましょう。 +- `round` の代わりに `points` プロパティでグループ化してみてください。 +- `distance` の代わりに、メソッドチェーンに `.with_object_limit(9)` を追加してみてください。結果は同じでしょうか? +::: + +## 復習 + +### 復習問題 + +上記の `nearText` クエリを次の変更を加えて再度試してみてください。 +- `distance` を 0.1、0.19、0.21、0.25 など別の値に変更してみましょう。結果はどのように変わりますか?予想どおりでしょうか? + +### 重要ポイント + +- `Aggregate` 関数は複数のオブジェクトから情報をまとめ、概要を提供します。 +- `nearText` などの検索オペレーターは `Aggregate` クエリでも使用できます。 + - 意味のある集計を得るには、クエリで明示的な `limit` またはしきい値(`distance` や `certainty`)を設定して検索空間を制限する必要があります。 +- `groupBy` 引数を使用すると、結果の複数サブセットから情報をまとめて集計をより細かくできます。 +- `groupBy` 引数を使用すると追加の `groupedBy` プロパティが利用でき、各結果が属するグループを識別できます。 + +import Quiz from '/src/components/Academy/quiz.js' +export const varName = [{ + questionText: 'questionText', + answerOptions: [ + { + answerText: 'answerOne', + isCorrect: false, + feedback: 'feedbackOne', + }, + { + answerText: 'answerTwo', + isCorrect: false, + feedback: 'feedbackTwo', + }, + { + answerText: 'answerThree', + isCorrect: false, + feedback: 'feedbackThree', + }, + ] +}]; + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/50_filters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/50_filters.mdx new file mode 100644 index 000000000..3caedf0de --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/50_filters.mdx @@ -0,0 +1,363 @@ +--- +title: フィルター +description: Weaviate でフィルターを適用して検索結果を精密に絞り込みます。 +--- + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +## 利用可能な演算子 + +これまでに、`Get` や `Aggregate` といったクエリ関数、`nearVector`、`nearObject`、`nearText` といった検索オペレーターを見てきました。 +では、フィルターについて見ていきましょう。 + +フィルターとは、結果に対して追加の条件を指定する方法です。Weaviate には複数のフィルターが用意されています。 + +### 利用可能なフィルター + +利用可能なフィルターは多数ありますが、今はすべてを扱う必要はありません。ここでは、よく使われるフィルターをいくつか紹介します。 + +- `where`: ブール条件を適用してデータをフィルターします。 +- `limit`: 取得するオブジェクトの最大数を制限します。 +- `offset`: 検索結果のページネーションに使用します。 + +## `where` でのデータフィルター + +`where` フィルターは、 SQL の `WHERE` 句に相当します。 SQL の `WHERE` 句と同様に、`where` フィルターを使ってデータにブール条件を適用できます。 + +### 単一オペランドの例 + +以前に次のようなサンプルクエリを実行しました。 + +import GetWithAdditional from './_snippets/academy.queries.get.with.additional.mdx'; + + + +その結果、次のような回答が返ってきました。 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.1791926, + "id": "b1645a32-0c22-5814-8f35-58f142eadf7e" + }, + "answer": "escaping the Earth's gravity (and go off into outer space, on your way to the moon, for instance)", + "question": "It takes approximately 24,840 MPH to achieve this" + }, + { + "_additional": { + "distance": 0.18123823, + "id": "ef263438-b152-5540-97f7-99f4076bd124" + }, + "answer": "the Milky Way", + "question": "This is the name of our own galaxy" + } + ] + } + } +} +``` + +ここで、`Like` オペレーターを使った `where` 引数を追加してクエリを拡張してみましょう。 + +import FilterWhereLike from './_snippets/academy.queries.filter.where.like.mdx'; + + + +これにより、先ほどのレスポンスがどのように変化するか予想できますか。 + +実際のレスポンスはこちらです。 + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.18400955, + "id": "ddcc3f06-5410-5944-85c4-3cb56ab27088" + }, + "answer": "space shuttles", + "question": "These transports, first sent up in 1981, lift off like a rocket & land like a plane" + }, + { + "_additional": { + "distance": 0.2267003, + "id": "36ffe6ca-9b73-5a54-80eb-a93f01822956" + }, + "answer": "Robert Goddard", + "question": "He's been called the \"Father of Modern Rocketry\"" + } + ] + } + } +} +``` + +
+ +
+ このクエリの解説 + +結果が変化していることがわかります。先ほどの結果は、`question` プロパティに `rocket` という文字列が含まれていないため除外されました。 + +このように ベクトル 検索とフィルターを組み合わせる方法は、入力に類似しているだけでなく、追加の条件も満たすオブジェクトを見つける強力な手段です。フィルターによって、クエリ ベクトル に対して「より近い」オブジェクトが除外される場合もありますが、誤検出を排除して本当に関連性の高いオブジェクトを得る有効な戦略となります。 + +
+ +クエリを使えばデータをさまざまな方法でフィルターできます。例として次のクエリを見てください。 + +import FilterWhereGreater from './_snippets/academy.queries.filter.where.greater.mdx'; + + + +このクエリは先ほどのクエリとどのように異なる結果を返すと予想しますか。 + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.18251508, + "id": "15f06117-012c-506d-b5c5-24df2e750f35" + }, + "answer": "the Milky Way", + "points": 400, + "question": "Into the 20th Century it was thought the universe was one big galaxy--this one" + }, + { + "_additional": { + "distance": 0.19289112, + "id": "584a6c68-0ebe-561f-b32a-3a735eadf02e" + }, + "answer": "Asteroid", + "points": 400, + "question": "A 1991 photo of Gaspra taken by the Galileo probe was the first close-up of one of these minor planets" + } + ] + } + } +} +``` + +
+ +
+ このクエリの解説 + +このクエリは、`points` 値が 200 より大きい `JeopardyQuestion` オブジェクトのみを返すように変更されています。 +そのため、返されるデータセットは大きく異なります。 + +
+ +:::note Exercise +`JeopardyQuestion` オブジェクトを以下の条件でフィルタリングしてみてください: +- `points` 値が 200 と等しい +- `points` 値が 600 以上 + +利用できる演算子の一覧は [こちらのページ](/weaviate/api/graphql/filters#filter-structure) にあります。 +::: + +### 複数オペランドの例 + +クエリ構文は、単一のオペランドを超えて複数の条件を扱うこともできます。 + +import FilterMultipleOperands from './_snippets/academy.queries.filter.multiple.operands.mdx'; + + + +`where` 引数(つまり `.with_where`)に注目してください。結果にはどのような制限がかかると予想されますか。 + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.2267003, + "id": "a488fbe5-c2c6-50ad-8938-4b9f20dc56d1" + }, + "answer": "Robert Goddard", + "points": 400, + "question": "He's been called the \"Father of Modern Rocketry\"" + }, + { + "_additional": { + "distance": 0.24946856, + "id": "c00decd4-4cf1-5b03-a789-a57077e082fb" + }, + "answer": "Huntsville", + "points": 1000, + "question": "A campus for the University of Alabama is here, nicknamed \"Rocket City, U.S.A.\"" + } + ] + } + } +} +``` + +
+ +
+ このクエリの解説 + +このクエリは、`points` 値が 400 より大きく、かつ `question` フィールドに `rocket` が含まれている `JeopardyQuestion` オブジェクトのみを返すように変更されています。 + +
+ +これらのフィルターは `Aggregate` クエリにも適用できます。ぜひ試してみてください。 + +:::note Exercise +次を試してみましょう: +- 上記のパターンに従って、`Aggregation` クエリに `where` フィルターを追加する。 +::: + +## `offset` を使った結果のページネーション + +データをクエリするときは、`offset` 演算子を使用して指定した件数の結果をスキップできます。これは 1 ページあたりに表示する件数を制御したいページネーションに便利です。 + +`offset` 演算子は既存の `limit` 演算子と組み合わせて使用し、`offset+1` から `offset+1+limit` までの結果を取得します。 + +たとえば最初の 10 件を取得するには `limit`: 10 を指定します。その後「2 ページ目の 10 件」を表示するには `offset`: 10、`limit`: 10 と指定します。以降も同様です。 + +`offset` を使用する構文は次のとおりです: + +import FilterPaginationNeartext from './_snippets/academy.queries.filter.pagination.nearText.mdx'; + + + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "answer": "the Milky Way", + "question": "Into the 20th Century it was thought the universe was one big galaxy--this one" + }, + { + "answer": "space shuttles", + "question": "These transports, first sent up in 1981, lift off like a rocket & land like a plane" + } + ] + } + } +} +``` + +
+ +
+ このクエリの説明 + +このクエリは、最初の 2 件 (`offset`: 2) の後の次の 2 件 (`limit`: 2) を取得します。 + +結果制限が異なる 2 つのクエリを比較することでこれを確認できます。以下のクエリは上位 4 件を取得します。そのクエリの最後の 2 件は、ページネーション付きで `limit` を使ったクエリの結果と同じです。 + +```graphql +{ + Get { + JeopardyQuestion(limit: 4) { + answer + question + } + } +} +``` + +import FilterPaginationRelated from './_snippets/academy.queries.filter.pagination.related.mdx'; + + + +
+ +:::tip +したがって、`n` ページ目では `offset`: `n*m`、`limit`: `m` と指定します。ここで `m` は 1 ページあたりの結果数です。 +::: + +`offset` 演算子は、`Get` や `Aggregate` を含むすべての ベクトル 検索関数で利用できます。 + +## レビュー + + + + + +### 重要なポイント + +- フィルターは結果に追加の条件を適用するために使用します。よく使われるフィルターには `where`、`limit`、`offset` などがあります。 +- `where` フィルターは、クエリ対象データにブール条件を適用できます。`Like`、`Greater`、`Equal` などさまざまな演算子と組み合わせて使用できます。 +- `where` フィルター内で複数の条件を組み合わせて、クエリ結果をさらに絞り込むことができます。 +- `offset` 演算子は `limit` と組み合わせることで、結果をスキップしてページネーションを構築できます。 + +import Quiz from '/src/components/Academy/quiz.js' +export const whereUsage = [{ + questionText: 'Which filter is used to apply a boolean condition to the data in Weaviate?', + answerOptions: [ + { + answerText: 'limit', + isCorrect: false, + feedback: 'This is used to set the maximum number of objects to retrieve.', + }, + { + answerText: 'offset', + isCorrect: false, + feedback: 'This is used to skip a number of results.', + }, + { + answerText: 'where', + isCorrect: true, + feedback: 'It is similar to the WHERE clause in SQL.', + }, + ] +}]; +export const offsetExample = [{ + questionText: 'How can you combine the offset and limit operators to display the second page of results with 10 results per page?', + answerOptions: [ + { + answerText: 'Set offset: 10 and limit: 10', + isCorrect: true, + feedback: 'This would get results 11-20.', + }, + { + answerText: 'Set offset: 20 and limit: 10', + isCorrect: false, + feedback: 'This would get results 21-30.', + }, + { + answerText: 'Set offset: 10 and limit: 20', + isCorrect: false, + feedback: 'This would get results 11-30', + }, + ] +}]; + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/80_inside_queries_1.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/80_inside_queries_1.mdx new file mode 100644 index 000000000..6492423e4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/80_inside_queries_1.mdx @@ -0,0 +1,221 @@ +--- +title: クエリ内部の詳細 +description: より良いデータ取得のために Weaviate の高度なクエリ手法を理解する。 +--- + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +このユニットでは、さまざまな方法でベクトル検索を構築する方法を見てきました。 + +まず、 `Get` と `Aggregate` のベクトル検索関数の使い方を学び、 `nearVector`、 `nearObject`、 `nearText` などの検索オペレーターを追加し、最後に `where`、 `limit`、 `offset` などの各種フィルターで締めくくりました。 + +ここで一旦立ち止まり、これらの検索が実際にどのように実行されているのかを見てみましょう。まずはベクトル検索プロセスからです。 +## ベクトル検索プロセス + +### ベクトル検索の舞台裏 + +名前が示すとおり、ベクトル検索はベクトルを用いて処理を行います。Weaviate でベクトル検索を実行するときは、 `nearVector`、 `nearObject`、 `nearText` のいずれを使う場合でも、入力はベクトルへと変換されます。 + +入力ベクトルは Weaviate に保存されているベクトルと比較され、最も関連性の高いオブジェクトが返されます。 + +`nearVector` オペレーターを使ったクエリでは、Weaviate は提供されたベクトルをそのまま使用してベクトル検索を行います。 + +`nearObject` や `nearText` のようにベクトルが直接提供されないクエリの場合、Weaviate は適切な方法でベクトルを取得します。 + +#### `nearObject` + +`nearObject` オペレーターが使用される場合、Weaviate はそのオブジェクトに紐づくベクトルを取得し、これを入力ベクトルとして使用します。 + +これを確認するために、 `nearObject` オペレーターを用いたベクトル検索を実行し、同等の `nearVector` オペレーターで再現してみましょう。 + +以下が `nearObject` クエリです。 + +import NearobjectExample from './_snippets/academy.queries.nearobject.example.mdx'; + + + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 3.5762787e-07, + "id": "d53fd7ea-35c1-5f8d-a35a-e53511db1a2a" + }, + "answer": "meerkats", + "question": "Group of mammals seen here: [like Timon in The Lion King]" + }, + { + "_additional": { + "distance": 0.12663543, + "id": "9eaf38fe-e7f0-5da3-b703-6b44c49faf7d" + }, + "answer": "hyena", + "question": "It's the amused African mammal heard here" + } + ] + } + } +} +``` + +
+ +次に、この `nearVector` クエリを実行して結果を比較してみてください。 + +import NearobjectEquivalentNearvector from './_snippets/academy.queries.nearobject.equivalent.nearvector.mdx'; + + + +
+ `meerkat_vector` 全体を表示 + +import MeerkatsVector from './_snippets/meerkats.vector.mdx'; + + + +
+ +
+ このクエリの解説 + +2 本目の( `nearVector` )クエリを実行すると、 `nearObject` クエリと同じ結果が返されることがわかります。距離も同一です。これは、 `nearObject` クエリで使用されるオブジェクトのベクトルと、 `nearVector` クエリで指定したベクトルがまったく同じだからです。 + +
+ +#### `nearText` + +`nearText` オペレーターが使用される場合、Weaviate は入力テキストをベクトルへ変換して入力として使用します。具体的な方法は、該当クラスに適用されるベクトライザーの設定によって異なります。設定によっては `text2vec-openai` モジュールや `text2vec-transformers` モジュールが使用されます。 + +:::info Vectorizer setting +ベクトライザーの設定方法については次のセクションで扱います。 +::: + +import NeartextExample from './_snippets/academy.queries.neartext.example.mdx'; + + + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.1800943, + "id": "92710bd6-de3c-5220-a60a-d386b2748e28" + }, + "answer": "Two Guys and a Girl", + "question": "In 1999 an ABC sitcom dropped \"a Pizza Place\" from its name, which changed to this" + }, + { + "_additional": { + "distance": 0.18657643, + "id": "7e7a6572-02bd-529f-8943-38ccd4a2a90b" + }, + "answer": "Beavis & Butthead of the Class", + "question": "2 MTV cartoon teens join Howard Heh-Heh-Hesseman's honors program on '80's TV" + } + ] + } + } +} +``` + +
+ +次に、この `nearVector` クエリを実行して結果を比較してみてください。 + +import NeartextEquivalentNearvector from './_snippets/academy.queries.neartext.equivalent.nearvector.mdx'; + + + +
+ `popular_90s_comedy_vector` 全体を表示 + +import Popular90sComedyVector from './_snippets/popular.90s.comedy.vector.mdx'; + + + +
+ +
+ このクエリの解説 + +2 本目の( `nearVector` )クエリを実行すると、 `nearText` クエリと同じオブジェクトおよび距離が返されることが再び確認できます。 + +この場合、Weaviate は `text2vec-openai` モジュールを使用して入力テキストをベクトル化します。このモジュールは OpenAI 推論 API を利用して入力をベクトルへ変換します。ベクトル化プロセスは決定論的であり、同じ入力テキストは常に同じベクトルになります。 `nearVector` クエリでは、OpenAI API を直接用いてベクトルを生成し、入力ベクトルとして使用したため、同じ結果が得られました。 + +
+ +### フィルタリング + +結果をさらに絞り込むために、ベクトル検索プロセスにフィルターを適用できます。 + +内部的には、Weaviate は「事前フィルタリング」を実装しています。これは、データベース全体にフィルターを適用して「許可リスト」を作成し、そのリストからベクトル検索結果を返すという仕組みです。 + +これに加えて効率的なフィルタリング手法を組み合わせることで、大規模データベースに厳しいフィルターを適用した場合でも、Weaviate は適切な件数の結果を容易に返すことができます。 +### 概念図 (フィルタリング + ベクトル検索) + +以下の概念図は、ベクトル検索プロセスがどのように機能するかを示しています。 +フィルターと検索オペレーターを含む入力が渡されると、 Weaviate はまず事前フィルタリングを実行してオブジェクトの「allow list」を取得します。 + +入力は入力ベクトルを決定するために使用されます。その際、`nearObject` でオブジェクトのベクトルを取得したり、`nearText` で入力テキストをベクトル化したりする追加ステップが含まれる場合があります。次に、その入力ベクトルと比較を行ってベクトル検索を実行し、 allow list から最も関連性の高いオブジェクトが返されます。 + +import SearchConceptualImg from './images/search-conceptual-dark.png'; + +検索がどのように機能するかの概念図 + +## レビュー + +### レビュー演習 + +- `nearVector` クエリを使用して `nearObject` クエリを再現します。 +- `nearVector` クエリを使用して `nearText` クエリを再現します。 + +### 重要なポイント + +- `nearObject` オペレーターはオブジェクトに関連付けられたベクトルを取得し、`nearText` は指定された ベクトライザー に基づいて入力テキストをベクトルに変換します。 +- `nearObject` や `nearText` クエリと同等の `nearVector` クエリを作成する方法を学びました。 +- Weaviate は「事前フィルタリング」を採用しており、ベクトル検索を実行する前にデータベース全体にフィルターが適用されます。 + +import Quiz from '/src/components/Academy/quiz.js' +export const varName = [{ + questionText: 'questionText', + answerOptions: [ + { + answerText: 'answerOne', + isCorrect: false, + feedback: 'feedbackOne', + }, + { + answerText: 'answerTwo', + isCorrect: false, + feedback: 'feedbackTwo', + }, + { + answerText: 'answerThree', + isCorrect: false, + feedback: 'feedbackThree', + }, + ] +}]; + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/90_wrap_up.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/90_wrap_up.mdx new file mode 100644 index 000000000..30fddcc9d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/90_wrap_up.mdx @@ -0,0 +1,27 @@ +--- +title: まとめ +description: クエリのまとめ - パート 1 +--- + +## ユニットレビュー + +このユニットでは、 Weaviate をクエリして適切なオブジェクトを取得したり、集約情報を効率的に取得したりするための貴重な知識を学びました。 Weaviate で利用できるさまざまな検索オペレーター、 `nearVector` 、 `nearObject` 、 `nearText` などや、検索結果を特定の条件に絞り込むフィルターについて深く掘り下げ、より正確で関連性の高い情報を取り出せるようになりました。 + +また、 Weaviate がこれらのオペレーターを使って検索を実行する際の主要な原則についても学びました。特定の検索オペレーターの使い方やフィルタリングの仕組みを理解しました。 + +これで Weaviate へのクエリ方法を習得したので、次のモジュールではスキーマ作成からデータインポートまで、 Weaviate インスタンスを構築する方法を学びます。 + +### 学習成果 + +Now, you should be able to: +- 関連するオブジェクトと必要なプロパティを取得する 'Get' クエリを構築できる。 +- 関連するオブジェクトに関する集約プロパティを取得する 'Aggregate' クエリを構築できる。 +- 距離や上限のしきい値を伴う `nearVector` 、 `nearObject` 、 `nearText` など、適切な検索オペレーターとフィルターを区別して適用できる。 +- クエリにフィルターを追加できる。 +- Weaviate が検索オペレーターとフィルターを使って検索を実行する仕組みを説明できる。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/10_get.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/10_get.py new file mode 100644 index 000000000..5e68f0000 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/10_get.py @@ -0,0 +1,40 @@ +# ===== Instantiate to edu-demo with OpenAI ===== +import weaviate + +client = weaviate.Client( + url="https://edu-demo.weaviate.network", + auth_client_secret=weaviate.auth.AuthApiKey(api_key="learn-weaviate"), # A read-only API Key for the Weaviate instance + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", # Replace this with YOUR OpenAI API key + } +) +# ===== END Instantiate to edu-demo with OpenAI ===== + +# ===== GET STANDALONE PYTHON ===== +import json +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).do() + +print(json.dumps(response, indent=2)) +# ===== END GET STANDALONE PYTHON ===== + +graphql_query = """ +# ===== GET STANDALONE GRAPHQL ===== +{ + Get { + JeopardyQuestion ( + limit: 2 + ) { + question + answer + } + } +} +# ===== END GET STANDALONE GRAPHQL ===== +""" + +response = client.query.raw(graphql_query) + +print(json.dumps(response, indent=2)) diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.groupby.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.groupby.mdx new file mode 100644 index 000000000..2ba6a110b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.groupby.mdx @@ -0,0 +1,47 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.aggregate( + "JeopardyQuestion", +).with_group_by_filter( + "round" +).with_fields( + "groupedBy {path value}" +).with_near_text( + {"concepts": ["Intergalactic travel"], "distance": 0.2} +).with_meta_count().do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Aggregate { + JeopardyQuestion ( + nearText: { + concepts: ["Intergalactic travel"], + distance: 0.2 + } + groupBy: ["round"] + ) { + groupedBy { + path + value + } + meta { + count + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.standalone.2.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.standalone.2.mdx new file mode 100644 index 000000000..3c31fb84b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.standalone.2.mdx @@ -0,0 +1,36 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.aggregate( + "JeopardyQuestion" +).with_fields("answer {count topOccurrences {value occurs}}").do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Aggregate { + JeopardyQuestion { + answer { + count + topOccurrences + { + value + occurs + } + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.standalone.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.standalone.mdx new file mode 100644 index 000000000..09b187be1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.standalone.mdx @@ -0,0 +1,31 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.aggregate( + "JeopardyQuestion", +).with_meta_count().do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Aggregate { + JeopardyQuestion { + meta { + count + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.syntax.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.syntax.mdx new file mode 100644 index 000000000..c686ce821 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.syntax.mdx @@ -0,0 +1,31 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.aggregate( + , +).with_fields( + +)..do() +``` + + + + +```graphql +{ + Aggregate { + ( + + ) { + + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.with.neartext.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.with.neartext.mdx new file mode 100644 index 000000000..850a2e0b6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.aggregate.with.neartext.mdx @@ -0,0 +1,38 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.aggregate( + "JeopardyQuestion", +).with_near_text( + {"concepts": ["Intergalactic travel"], "distance": 0.2} +).with_meta_count().do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Aggregate { + JeopardyQuestion ( + nearText: { + concepts: ["Intergalactic travel"], + distance: 0.2 + } + ) { + meta { + count + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.multiple.operands.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.multiple.operands.mdx new file mode 100644 index 000000000..44ceba284 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.multiple.operands.mdx @@ -0,0 +1,75 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer", "points"] +).with_limit(2).with_near_text( + {"concepts": "Intergalactic travel"} +).with_additional( + ["distance", "id"] +).with_where({ + "operator": "And", + "operands": [ + { + "path": ["question"], + "operator": "Like", + "valueText": "*rocket*" + }, + { + "path": ["points"], + "operator": "GreaterThan", + "valueInt": 200 + } + ] +}).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearText: { + concepts: ["Intergalactic travel"], + } + where: { + operator: And, + operands: [ + { + path: ["question"], + operator: Like, + valueText: "*rocket*" + } + { + path: ["points"], + operator: GreaterThan, + valueInt: 400 + }, + ] + + } + ) { + question + answer + points + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.pagination.nearText.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.pagination.nearText.mdx new file mode 100644 index 000000000..ae519939e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.pagination.nearText.mdx @@ -0,0 +1,39 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_offset(2).with_near_text( + {"concepts": "Intergalactic travel"} +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2, + offset: 2, + nearText: { + concepts: ["Intergalactic travel"], + } + ) { + question + answer + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.pagination.related.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.pagination.related.mdx new file mode 100644 index 000000000..f01fc4dfb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.pagination.related.mdx @@ -0,0 +1,38 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(4).with_near_text( + {"concepts": "Intergalactic travel"} +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 4 + nearText: { + concepts: ["Intergalactic travel"], + } + ) { + question + answer + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.where.greater.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.where.greater.mdx new file mode 100644 index 000000000..26e5c3bbc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.where.greater.mdx @@ -0,0 +1,54 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer", "points"] +).with_limit(2).with_near_text( + {"concepts": "Intergalactic travel"} +).with_additional( + ["distance", "id"] +).with_where({ + "path": ["points"], + "operator": "GreaterThan", + "valueInt": 200 +}).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearText: { + concepts: ["Intergalactic travel"], + } + where: { + path: ["points"], + operator: GreaterThan, + valueInt: 200 + } + ) { + question + answer + points + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.where.like.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.where.like.mdx new file mode 100644 index 000000000..86f1a562a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.filter.where.like.mdx @@ -0,0 +1,53 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_text( + {"concepts": "Intergalactic travel"} +).with_additional( + ["distance", "id"] +).with_where({ + "path": ["question"], + "operator": "Like", + "valueText": "*rocket*" +}).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearText: { + concepts: ["Intergalactic travel"], + } + where: { + path: ["question"], + operator: Like, + valueText: "*rocket*" + } + ) { + question + answer + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.standalone.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.standalone.mdx new file mode 100644 index 000000000..e69de29bb diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.syntax.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.syntax.mdx new file mode 100644 index 000000000..8b87ae81f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.syntax.mdx @@ -0,0 +1,30 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + , + [] +)..do() +``` + + + + +```graphql +{ + Get { + ( + + ) { + + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.with.additional.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.with.additional.mdx new file mode 100644 index 000000000..8e72efbe6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.get.with.additional.mdx @@ -0,0 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_text( + {"concepts": "Intergalactic travel"} +).with_additional( + ["distance", "id"] +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearText: { + concepts: ["Intergalactic travel"], + } + ) { + question + answer + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearObject.simple.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearObject.simple.mdx new file mode 100644 index 000000000..57baecea7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearObject.simple.mdx @@ -0,0 +1,38 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_object( + {"id": "c8f8176c-6f9b-5461-8ab3-f3c7ce8c2f5c"} +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearObject: { + id: "c8f8176c-6f9b-5461-8ab3-f3c7ce8c2f5c" + } + ) { + question + answer + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearText.simple.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearText.simple.mdx new file mode 100644 index 000000000..56b16cc08 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearText.simple.mdx @@ -0,0 +1,38 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_text( + {"concepts": "Intergalactic travel"} +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearText: { + concepts: ["Intergalactic travel"], + } + ) { + question + answer + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearVector.simple.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearVector.simple.mdx new file mode 100644 index 000000000..bea5b33ab --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearVector.simple.mdx @@ -0,0 +1,40 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +vector_input = [0.023932384327054024, -0.014095712453126907, ..., -0.0357337519526481] + +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_vector( + {"vector": vector_input} +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearVector: { + vector: [0.023932384327054024, -0.014095712453126907, ..., -0.0357337519526481] + } + ) { + question + answer + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearVector.simple.vector.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearVector.simple.vector.mdx new file mode 100644 index 000000000..46ad7938e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearVector.simple.vector.mdx @@ -0,0 +1 @@ +[0.023932384327054024, -0.014095712453126907, 0.013304559513926506, -0.01155742909759283, -0.01147831417620182, 0.015321999788284302, -0.025013625621795654, -0.04198386147618294, 0.0006061387248337269, -0.008940030820667744, 0.013475975953042507, 0.0021558923181146383, 0.008148877881467342, -0.0022696207743138075, 0.014623147435486317, 0.0010969009017571807, 0.032199934124946594, -0.016746075823903084, 0.007700557820498943, 0.014293501153588295, -0.004793069791048765, 0.009223527275025845, 0.01840749755501747, -0.007628035265952349, -0.0017108687898144126, -0.001233704504556954, 0.01867121458053589, -0.030696744099259377, 0.012150794267654419, -0.003728309413418174, 0.030512141063809395, -0.004667803645133972, -0.005402917042374611, -0.013779250904917717, -0.013344116508960724, -0.026727791875600815, 0.020596355199813843, -0.008043390698730946, -0.0035865609534084797, -0.007120378781110048, 0.0073379455134272575, 0.031145064160227776, -0.009137819521129131, -0.00028988346457481384, -0.009823485277593136, 0.007482990622520447, 0.0011644785990938544, -0.012856239452958107, 0.001305402722209692, 0.007911532185971737, 0.011432163417339325, 0.033914100378751755, -0.0353645458817482, -0.013845180161297321, -0.009896007366478443, -0.009717998094856739, -0.022824769839644432, 0.008280736394226551, 0.029299039393663406, -0.02130839228630066, 0.008485117927193642, 0.004756808280944824, -0.021071046590805054, 0.03462613746523857, -0.021756712347269058, 0.0076082563027739525, 0.0020471089519560337, -0.013205665163695812, 0.00041803380008786917, 0.0013144679833203554, 0.019475553184747696, 0.0022762136068195105, -0.001709220465272665, -0.0005315560265444219, 0.0039063189178705215, -0.027110181748867035, 0.008676312863826752, -0.009843263775110245, -0.02209954522550106, 0.012394732795655727, 0.016772447153925896, -0.016179082915186882, -0.012078272178769112, 0.018684400245547295, 0.02439389005303383, 0.021321577951312065, -0.012282652780413628, 0.013726507313549519, -0.030169308185577393, -0.007898345589637756, 0.0166669599711895, 0.0005167219205759466, -0.0011076144874095917, 0.028085937723517418, -0.004760105162858963, 0.0016292810905724764, -0.0074698044918477535, 0.02565973438322544, 0.0024525749031454325, -0.036393046379089355, -0.01155742909759283, 0.013937481679022312, -0.025527875870466232, -0.023549992591142654, -0.014201199635863304, -0.005650152452290058, 0.011267339810729027, 0.022152289748191833, 0.025686105713248253, -0.01213101577013731, 0.011418977752327919, 0.021743526682257652, -6.031512748450041e-05, -0.010172910988330841, -0.010120167396962643, -0.026450887322425842, 0.020042547956109047, 0.006981926970183849, -0.012295839376747608, -0.04338156431913376, 0.023958755657076836, 0.014675891026854515, 0.022442378103733063, -0.00022127565171103925, 0.012427697889506817, 0.03164612874388695, -0.020464494824409485, -0.01867121458053589, 0.0167856328189373, -0.02187538519501686, 0.009632290340960026, 0.022297333925962448, 0.007318167015910149, -0.0076148491352796555, -0.01660103164613247, 0.018499799072742462, -0.004489794373512268, 0.007779672741889954, -0.0037349022459238768, -0.022112730890512466, 0.0036524904426187277, 0.012691415846347809, -0.015638461336493492, 0.0141352703794837, -0.017220767214894295, 0.035944726318120956, 0.01574394851922989, 0.005607298109680414, 0.009625696577131748, -0.021611668169498444, 0.013581463135778904, -0.004196408204734325, 0.013541905209422112, -0.007113785482943058, 0.0005550433997996151, 0.012889203615486622, -0.010060830973088741, 0.02295662835240364, -0.0015551104443147779, -0.007786266040056944, -0.003810721216723323, 0.003098683198913932, -0.0011685991194099188, -0.01275075227022171, 0.02200724370777607, 0.03061762824654579, 0.0014512715861201286, -0.004245855379849672, -0.01964697055518627, -0.01104977261275053, -0.018104221671819687, 0.006741284392774105, -0.038871992379426956, 0.011122294701635838, -0.017181210219860077, 0.0328855998814106, 7.489171548513696e-05, 0.004971079062670469, -0.031303294003009796, -0.023906011134386063, -0.005834754556417465, 0.003945876378566027, 0.0012196945026516914, 0.009137819521129131, -0.01106955111026764, -0.028666116297245026, 0.008768614381551743, -0.0029849549755454063, 0.010153132490813732, -0.015308814123272896, -0.0037085304502397776, -0.002592674922198057, -0.010252026841044426, 0.0013853422133252025, -0.6903074979782104, -0.03264825418591499, 0.00757529167458415, -0.021769898012280464, 0.005010636989027262, 0.013528719544410706, 0.006810510065406561, 0.008940030820667744, -0.009856450371444225, -0.00023652183881495148, -0.02009529061615467, 0.023906011134386063, -0.023958755657076836, -0.005762232467532158, -0.011689288541674614, -0.014504474587738514, 0.007080820854753256, -0.018051479011774063, 0.014385801739990711, 0.012856239452958107, -0.02067546918988228, 0.02763761766254902, 0.005946834571659565, 0.020345821976661682, 0.015335185453295708, 0.00432497076690197, 0.03797535225749016, -0.013284780085086823, -0.012803495861589909, -0.00042730511631816626, -0.007094006985425949, 0.015651647001504898, -0.012645265087485313, -0.001946566510014236, 0.05511700361967087, -0.005521589890122414, -0.003125054994598031, 0.019225021824240685, 0.009071889333426952, 0.023009371012449265, -0.008300515823066235, -0.0010746497428044677, 0.021954501047730446, 0.010100388899445534, -0.016970235854387283, 0.008485117927193642, 0.04230032488703728, -0.019541483372449875, -0.009038925170898438, -0.030643999576568604, 0.0005055963410995901, 0.03618207201361656, -0.004559020046144724, 0.014807750470936298, 0.009329014457762241, 0.019000861793756485, 0.020279893651604652, 0.019501926377415657, 0.0006320984102785587, 0.0028465031646192074, -0.000699264055583626, 0.028797974810004234, -0.02056998200714588, 0.001127393334172666, -0.014794564805924892, 0.020464494824409485, -0.0181305930018425, 0.020016174763441086, -0.016653774306178093, -0.01939643919467926, 0.029773730784654617, 0.021071046590805054, -0.013845180161297321, 0.030643999576568604, 0.014952794648706913, 0.026543188840150833, 0.025198228657245636, -0.007535734213888645, -0.017827318981289864, 0.022086359560489655, 0.0005212545511312783, -0.0073313526809215546, -0.04918335750699043, -0.024090614169836044, 0.03494259715080261, -0.004084328189492226, -0.028507886454463005, 0.009137819521129131, 0.022152289748191833, 0.009203748777508736, 0.0019432699773460627, 0.027558501809835434, -0.023760966956615448, -0.02416973002254963, 0.00514249550178647, -0.03014293685555458, -0.018486613407731056, -0.007304980885237455, 0.005656745284795761, -0.008827950805425644, 0.008623569272458553, -0.016587844118475914, 0.028929835185408592, 0.01545385830104351, -0.004028288181871176, -0.012849646620452404, 0.004885370843112469, 0.017576785758137703, 0.012988097965717316, -0.021638039499521255, -0.009553174488246441, -0.008227992802858353, -0.00912463292479515, 0.020583167672157288, -0.0167856328189373, -0.02674097754061222, 0.007858788594603539, -0.014174827374517918, 0.017352625727653503, -0.017154838889837265, 0.04003234952688217, -0.007852194830775261, 0.01170247420668602, 0.004951300099492073, -0.005396323744207621, -0.005828161723911762, 0.007970868609845638, -0.03336029127240181, -0.016930678859353065, -0.0029025431722402573, -0.0031563714146614075, 0.019739272072911263, 0.009797113947570324, -0.0014908292796462774, 0.004908446222543716, 0.008274143561720848, 0.014504474587738514, -0.019409624859690666, -0.022982999682426453, -0.021980872377753258, -0.03172524273395538, -0.0033986622001975775, -0.0009329014574177563, -0.0034052550327032804, -0.008544454351067543, -0.006929183378815651, 0.0042656343430280685, 0.0009007608750835061, -0.006569867953658104, -0.029562756419181824, -0.0016894417349249125, 0.006151216104626656, -0.0074698044918477535, 0.013528719544410706, 0.011966192163527012, -0.018776701763272285, -0.003073959844186902, -0.027743104845285416, -0.02500043995678425, -0.017339440062642097, 0.023892825469374657, 0.0060753971338272095, -0.008775207214057446, -0.0004223604337312281, -0.007219272665679455, -0.010252026841044426, -0.016640588641166687, 0.015124212019145489, -0.007713743485510349, -0.010014680214226246, 0.0026569559704512358, -0.007041263394057751, -0.014913237653672695, 0.018565727397799492, -0.017405370250344276, -0.0010021273046731949, 0.0036030435003340244, 0.00573915708810091, -0.0007532437448389828, -3.229512003599666e-05, -0.010898134671151638, -0.007839009165763855, 0.001443030429072678, 0.004476608242839575, 0.015137397684156895, 0.01714165136218071, 0.03380861133337021, 0.016113152727484703, -0.009447687305510044, 0.022020429372787476, -0.005152385216206312, 0.03586561232805252, 0.006688540801405907, -0.002876171376556158, -0.012816681526601315, -0.0023124748840928078, -0.001210629241541028, -0.020978745073080063, 0.0031217585783451796, 0.018750330433249474, 0.009487245231866837, -0.022152289748191833, 0.007806044537574053, -0.02025352045893669, 0.004793069791048765, -0.016139524057507515, -0.019950246438384056, -0.029773730784654617, 0.01933050900697708, -0.012955132871866226, 0.008115912787616253, 0.0029651762451976538, 0.002904191380366683, 0.012928761541843414, 0.034837111830711365, 0.019198650494217873, -0.017919618636369705, 0.010977250523865223, -0.02038538083434105, -0.005564444232732058, -0.023892825469374657, 0.01181455422192812, 0.01020587608218193, -0.007812637835741043, -0.008181842043995857, 0.02079414203763008, -0.01039707101881504, -0.011564021930098534, 0.002449278486892581, -0.038212697952985764, 0.0007363493205048144, 0.003395365783944726, -0.00129963387735188, 0.027083810418844223, 0.029615500941872597, 0.024631235748529434, -0.008794985711574554, -0.006915997248142958, 0.029167180880904198, 0.007529140915721655, -0.0042854128405451775, 0.005640262737870216, 0.029905589297413826, -0.006101768929511309, -0.004753511864691973, 0.011267339810729027, 0.01545385830104351, -0.004868888296186924, -0.012388139963150024, 0.0011809609131887555, -0.04034881293773651, -0.010627823881804943, -0.026503631845116615, 0.00977733451873064, 0.012394732795655727, -0.0054820324294269085, -0.01822289451956749, 0.006319336127489805, 0.02391919679939747, 0.024723537266254425, 0.005158978048712015, -0.0021575407590717077, 0.007456618826836348, 0.0139111103489995, 0.007502769120037556, -0.008834543637931347, -0.0024707054253667593, 0.01596810854971409, 0.002129520522430539, 0.015823064371943474, 0.00874224305152893, -0.032991088926792145, 0.011155259795486927, -0.012183759361505508, 0.020279893651604652, 0.004845813382416964, -0.0030442913994193077, -0.0077335224486887455, 0.01327818725258112, 0.006016060709953308, 0.0021047971677035093, -0.03892473503947258, 0.007212679833173752, 0.014517661184072495, -0.014082526788115501, -0.027690360322594643, 0.0006259175133891404, 0.02604212611913681, -0.0019498629262670875, 0.0015748892910778522, -0.02111060358583927, 0.001626808661967516, 0.0029388044495135546, -0.020055733621120453, -0.008794985711574554, -0.017102094367146492, 0.008485117927193642, -0.012295839376747608, 0.017985548824071884, 0.011735438369214535, -0.0017636122647672892, 0.020055733621120453, -0.0020108476746827364, -0.0040579563938081264, 0.03449427708983421, 0.020055733621120453, -0.013416639529168606, -0.016930678859353065, 0.006180884316563606, -0.009427908807992935, 0.0046381354331970215, 0.0022531382273882627, -0.013977039605379105, -0.013113363645970821, 0.0014776433818042278, -0.004338156431913376, -0.02455211989581585, -0.02500043995678425, 0.021928129717707634, -0.005890794564038515, -0.00726542342454195, -0.014174827374517918, -0.02203361690044403, -0.018842631950974464, 0.06730076670646667, -0.010416850447654724, -0.008636755868792534, 0.021044675260782242, 0.008320294320583344, -0.004657914396375418, -0.012869425117969513, -0.013871552422642708, -0.008590605109930038, -0.004275523591786623, 0.006902811583131552, 0.003566782223060727, -0.0010655844816938043, 0.005353469867259264, 0.0153747433796525, 0.019185464829206467, 0.010172910988330841, -0.011155259795486927, 0.018869003280997276, -0.014069341123104095, 0.005894090980291367, -0.027584875002503395, 0.01314632873982191, 0.018644843250513077, 0.016047224402427673, -0.029272668063640594, 0.01675926148891449, -0.000627565779723227, -0.005386434495449066, -0.03278011456131935, -0.0004099986399523914, 0.008715870790183544, -0.008214807137846947, -0.007759894244372845, 0.002576192608103156, -0.007581884507089853, 0.001857561757788062, 0.008300515823066235, 0.005468846298754215, -0.027004694566130638, 0.014412174001336098, 0.014623147435486317, -0.0011933227069675922, -0.02038538083434105, 0.0038634645752608776, -0.006042432505637407, -0.019792014732956886, 0.021980872377753258, -0.010489372536540031, -0.0018839335534721613, 0.026991508901119232, 0.009783927351236343, 0.001620215829461813, -0.03183072805404663, 0.006981926970183849, 0.0184734258800745, 0.016099967062473297, -0.0034085516817867756, -0.01962059922516346, -0.03262188285589218, -0.01043003611266613, -0.024130171164870262, 0.02410379983484745, 0.016179082915186882, -0.02067546918988228, -0.03557552024722099, -0.0009081779280677438, -0.008373037911951542, -0.0137396939098835, 0.008986181579530239, -0.008669720031321049, -0.030327538028359413, -0.004924928303807974, -0.019449181854724884, 0.007792858872562647, 0.005449067335575819, 0.02101830206811428, -0.02079414203763008, 0.019805200397968292, 0.0044172718189656734, -0.0031992257572710514, -0.0012485386105254292, 0.004555723629891872, -0.009164190851151943, -0.0008335952297784388, 0.021638039499521255, 0.0077401152811944485, 0.0009032331872731447, -0.0077401152811944485, 0.0019877722952514887, 0.014280314557254314, -0.005017229821532965, 0.007515955250710249, -0.0070148915983736515, 0.015361557714641094, 0.02041175216436386, 0.01213101577013731, -0.0013721563154831529, 0.0015946681378409266, 0.02387963980436325, 0.0044172718189656734, -0.015664832666516304, -0.002815186744555831, -0.0028184831608086824, 0.003744791727513075, 0.01179477572441101, -0.01685156300663948, 0.008946623653173447, -0.010799241252243519, -0.017497671768069267, 0.009216934442520142, -0.02919355221092701, 0.003922800999134779, -0.01774820312857628, 0.0009922379394993186, 0.008234585635364056, 0.0011100867995992303, 0.01084539107978344, -0.010528930462896824, -0.03185710310935974, -0.007311573717743158, -0.02969461679458618, 0.0046315426006913185, 0.03750066086649895, 0.006006170995533466, -0.008267550729215145, -0.009058703668415546, -0.0047699944116175175, 0.0002550644858274609, 0.0018460240680724382, -0.002813538536429405, 0.012335396371781826, -0.009520210325717926, 0.0054523637518286705, -0.03122417815029621, -0.007107192650437355, -0.007080820854753256, -0.0042788200080394745, -0.0025069667026400566, -0.007186308037489653, -0.02092600241303444, 0.0075950706377625465, 0.01189366914331913, -0.015585717745125294, -0.006797324400395155, -0.019515112042427063, -0.0021839123219251633, 0.0021377617958933115, -0.025580618530511856, 0.03014293685555458, 0.00684347515925765, 0.0008265902288258076, -0.019515112042427063, -0.028481515124440193, -0.03541729226708412, -0.0385291613638401, -0.027400271967053413, -0.026622304692864418, 0.033281177282333374, 0.02610805444419384, 0.022152289748191833, -0.017959177494049072, 0.03349215164780617, -0.0019729381892830133, 0.005725970957428217, 0.003622822230681777, 0.022666538134217262, -0.008794985711574554, -0.024288402870297432, 0.010819019749760628, 0.005656745284795761, 0.001946566510014236, 0.010759683325886726, 0.003340973984450102, 0.0007503593224100769, 0.029905589297413826, -0.016482356935739517, 0.002592674922198057, 0.0033063609153032303, -0.027769476175308228, -0.011517872102558613, 0.0021328171715140343, -0.007542327046394348, -0.0033162503968924284, -0.012249688617885113, -0.01758997142314911, 0.03354489430785179, 0.025738850235939026, -0.005623780656605959, -0.0001497834309702739, 0.0182492658495903, -0.011735438369214535, 0.041772887110710144, -0.012506812810897827, 0.02153255231678486, -0.008834543637931347, -0.0038239071145653725, -0.002765739569440484, 0.011616765521466732, -0.0022383041214197874, 0.015823064371943474, 0.002080073580145836, 0.0016836728900671005, 0.02219184674322605, 0.0013350709341466427, 0.0074698044918477535, 0.0013152922037988901, 0.011854112148284912, 0.004334860015660524, -0.022125916555523872, -0.006457787938416004, -0.021888570860028267, -0.00907848309725523, -0.03889836370944977, -0.01592855155467987, -0.011715659871697426, 0.009731183759868145, 0.038397300988435745, -0.03934668377041817, -0.011339861899614334, 0.011821147054433823, -0.011102516204118729, 0.021123789250850677, 0.0019317322876304388, 0.02385326847434044, 0.032068073749542236, -0.011801368556916714, -0.014267128892242908, -0.02254786528646946, -0.017022978514432907, -0.005297429859638214, 0.014346243813633919, 0.013581463135778904, -0.0009889415232464671, -0.024209287017583847, -0.0007462387438863516, 0.0018921747105196118, -0.02705743908882141, -0.022244589403271675, 0.0153747433796525, 0.004483201541006565, 0.025910265743732452, -0.0155989034101367, -0.008373037911951542, -0.008168656378984451, 0.021123789250850677, 0.016231825575232506, -0.00213446537964046, -0.01660103164613247, -0.017128465697169304, -0.01694386452436447, 0.014952794648706913, 0.0010252026841044426, 0.010997029021382332, 0.008623569272458553, -0.006438008975237608, 0.0176822729408741, 0.004687582608312368, 0.009487245231866837, 0.0012749104062095284, -0.012572742998600006, 0.03132966533303261, 0.006352300755679607, 0.03148789703845978, 0.007957682013511658, 0.0002802000963129103, 0.01022565457969904, -0.00923671294003725, 0.0007136861095204949, 0.02903532236814499, -0.015387929044663906, -0.010680567473173141, 0.010515743866562843, 0.0028943021316081285, 0.0184734258800745, -0.005538072437047958, -0.0017174617387354374, 0.015229698270559311, -0.00958613958209753, 0.0035634858068078756, 0.01669333130121231, 0.0015963163459673524, -0.0008438967051915824, -0.019225021824240685, -0.004601874388754368, 0.009467466734349728, -0.025105927139520645, -0.010278398171067238, 0.01583625003695488, -0.026701420545578003, -0.020490868017077446, -0.010074017569422722, 0.0018114111153408885, 0.008584012277424335, -0.02572566457092762, 0.00958613958209753, -0.0032272457610815763, 0.025606991723179817, -0.03539091721177101, 0.016271384432911873, 0.018077850341796875, 0.022297333925962448, -0.020016174763441086, 0.004430457949638367, 0.0136869503185153, -0.011768403463065624, 0.015783505514264107, -0.011867297813296318, -0.0135155338793993, -0.0057028960436582565, -0.012566149234771729, 0.010884949006140232, -0.008748835884034634, -0.005126013420522213, -0.02086007222533226, 0.029404526576399803, -0.0021641335915774107, -0.028217796236276627, -0.012170572765171528, 0.0013952315784990788, 0.007667592726647854, 0.014860494062304497, 0.02108423225581646, -0.039610400795936584, 0.016337312757968903, -0.022442378103733063, 0.011959598399698734, 0.003134944476187229, -0.022112730890512466, 0.01984475925564766, -0.014623147435486317, 0.0172339528799057, 0.0005542192957364023, -0.02216547541320324, -0.0029503421392291784, -0.003777756355702877, -0.014161641709506512, 0.006381968967616558, -0.016904305666685104, 0.006606128998100758, 0.0135155338793993, 0.02887709066271782, 0.025606991723179817, 0.009401536546647549, 0.005946834571659565, 0.0014356133760884404, -9.935771231539547e-05, 0.0010936044855043292, -0.012684823013842106, -0.0027574985288083553, 0.020332636311650276, 0.021967686712741852, 0.014398987405002117, -0.020965559408068657, -0.010469594039022923, 0.001205684500746429, -0.018658028915524483, -0.02998470515012741, 0.0014298445312306285, -0.00483262725174427, 0.010245434008538723, 0.009197155945003033, -0.005307319108396769, 0.02536964602768421, -0.0022926959209144115, 0.01035092119127512, 0.0026800313498824835, -0.009012552909553051, 0.04053341597318649, -0.0031547232065349817, -0.006902811583131552, -0.003113517304882407, -0.031145064160227776, -0.012473848648369312, 0.010522337630391121, 0.002930563176050782, 0.011623358353972435, -0.0023306054063141346, 0.013126550242304802, 0.02718929760158062, -6.428119377233088e-05, -0.015190141275525093, -0.006711616180837154, 0.01685156300663948, 0.008438967168331146, -0.030670370906591415, -0.0014825881225988269, 0.002033923054113984, -0.007278609089553356, 0.0038964294362813234, -0.005923759192228317, 0.019805200397968292, 0.0051227170042693615, 0.004282116424292326, 0.015427486971020699, -0.034230560064315796, 0.017471298575401306, -0.040849875658750534, 0.0021542441099882126, 0.002892653690651059, 0.015321999788284302, -0.0010029515251517296, 0.010080610401928425, -0.00695555517449975, 0.01894811913371086, 0.0034645916894078255, 0.011412384919822216, -0.005719378124922514, -0.004397492855787277, 0.002235007705166936, -0.0046249497681856155, -0.011412384919822216, -0.008656534366309643, -0.00885432306677103, 0.008715870790183544, -0.014029783196747303, 0.012632079422473907, -0.007707150653004646, 0.01650873012840748, 0.023365391418337822, -0.006589646451175213, -0.022982999682426453, -0.0005290837143547833, -0.008709277957677841, -0.015704389661550522, -0.0062962607480585575, 0.0015468692872673273, -0.005379841662943363, 0.00585123710334301, -0.001642466988414526, -0.0037744599394500256, -0.010548708960413933, -0.00768737168982625, 0.008808172307908535, 0.016970235854387283, 0.023826897144317627, 0.22004607319831848, -0.025303715839982033, -0.015018724836409092, 0.03336029127240181, -0.014517661184072495, 0.018895374611020088, 0.02387963980436325, -0.004390900023281574, 0.006002874579280615, 0.014794564805924892, -0.017695458605885506, 0.027110181748867035, 0.004262337926775217, -0.00915759801864624, -0.005735860671848059, 0.0004409030661918223, -0.01917227916419506, -0.013950667344033718, 0.0026338808238506317, -0.01136623416095972, 0.007792858872562647, -0.0023685148917138577, -0.011972784996032715, -0.013192479498684406, 0.009711405262351036, -0.012730972841382027, -0.0030822008848190308, 0.0018278934294357896, 0.019027233123779297, 0.01020587608218193, 0.011155259795486927, -0.014201199635863304, -0.009902600198984146, -0.000843484653159976, 0.017563600093126297, 0.011623358353972435, 0.021387508139014244, -0.012440883554518223, 0.0011603579623624682, 0.009197155945003033, -0.022745653986930847, 0.006935776211321354, -0.009137819521129131, -0.0063094464130699635, -0.004460126161575317, -0.0011661268072202802, -0.01901404745876789, 0.010667381808161736, 0.011939819902181625, 0.009737776592373848, -0.034520652145147324, -0.014504474587738514, 0.010515743866562843, 0.04034881293773651, -0.029483642429113388, -0.0035371140111237764, 0.018750330433249474, 0.008234585635364056, -0.013752879574894905, 0.007370910607278347, 0.0017322958447039127, 0.016640588641166687, -0.016205454245209694, -0.0019531594589352608, 0.002096555894240737, 0.020266707986593246, -0.018842631950974464, -0.017669087275862694, 0.028613373637199402, 0.01806466467678547, 0.01203871425241232, 0.0010144890984520316, -0.03011656366288662, -0.0017850393196567893, -0.024538934230804443, -0.0027921113651245832, 0.011603579856455326, 0.0057984935119748116, 0.008096134290099144, 0.018262453377246857, -0.005514997057616711, -0.004799662623554468, -0.002014144090935588, -0.023760966956615448, 0.0232285558283329, 0.014813636362552643,  ... \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearobject.equivalent.nearvector.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearobject.equivalent.nearvector.mdx new file mode 100644 index 000000000..cb07a4c8c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearobject.equivalent.nearvector.mdx @@ -0,0 +1,58 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +`nearVector` クエリを実行するには、完全な ベクトル を指定する必要があります。下記で完全な ベクトル を閲覧してコピーできます。 + +```python + +# Shortened for clarity + +meerkat_vector = [-0.024790961, -0.01860295, ..., -0.008665809,-0.02698336] + +``` + +こちらがクエリです。 + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_vector( + {"vector": meerkat_vector} +).with_additional( + ["distance", "id"] +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +`nearVector` クエリを実行するには、まず `` を完全な ベクトル に置き換えてください。下記で完全な ベクトル を閲覧してコピーできます。 + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearVector: { + vector: + } + ) { + question + answer + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearobject.example.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearobject.example.mdx new file mode 100644 index 000000000..28dc435a2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.nearobject.example.mdx @@ -0,0 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_object( + {"id": "d53fd7ea-35c1-5f8d-a35a-e53511db1a2a"} +).with_additional( + ["distance", "id"] +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearObject: { + id: "d53fd7ea-35c1-5f8d-a35a-e53511db1a2a" + } + ) { + question + answer + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.neartext.equivalent.nearvector.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.neartext.equivalent.nearvector.mdx new file mode 100644 index 000000000..33bd4968c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.neartext.equivalent.nearvector.mdx @@ -0,0 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_vector( + {"vector": popular_90s_comedy_vector} +).with_additional( + ["distance", "id"] +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearVector: { + vector: + } + ) { + question + answer + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.neartext.example.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.neartext.example.mdx new file mode 100644 index 000000000..3794bb274 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.neartext.example.mdx @@ -0,0 +1,44 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(2).with_near_text( + {"concepts": ["popular 90s comedy"]} +).with_additional( + ["distance", "id"] +).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearText: { + concepts: ["popular 90s comedy"] + } + ) { + question + answer + _additional { + distance + id + } + } + } +} +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.schema.short.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.schema.short.mdx new file mode 100644 index 000000000..084430c59 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/academy.queries.schema.short.mdx @@ -0,0 +1,28 @@ +```json +{ + "classes": [ + { + "class": "JeopardyQuestion", + "properties": [ + { + "dataType": ["text"], + "name": "question", + ... // Truncated + }, + { + "dataType": ["text"], + "name": "answer", + ... // Truncated + }, + { + "dataType": ["int"], + "name": "points" + ... // Truncated + }, + ... // Truncated + ], + ... // Truncated + } + ] +} +``` \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/meerkats.vector.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/meerkats.vector.mdx new file mode 100644 index 000000000..2425e69e6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/meerkats.vector.mdx @@ -0,0 +1 @@ +[-0.024790961,-0.01860295,-0.006920972,-0.042420954,-0.002649688,0.037932377,0.011636574,-0.018356469,-0.014788956,-0.017591074,0.017629992,-0.0016345689,0.015424622,-0.017435402,-0.0010686318,0.0056236954,0.019536989,0.013880863,0.030953025,-0.006188011,-0.0024226645,0.003998856,-0.008944724,-0.02750227,0.021820197,-0.011383604,0.014347882,-0.023805032,-0.015165167,0.015619214,-0.0012648449,-0.02000401,0.006333954,-0.020925077,-0.015735969,-0.009204179,0.011150095,-0.03832156,0.024959607,-0.007861498,-0.017201891,0.007783661,0.0070312405,-0.015281921,-0.009327421,0.0050723525,0.018992133,-0.01574894,-0.02089913,0.026438503,0.018577006,0.0120517025,-0.02482988,-0.000100589634,0.0076733925,0.0010516051,-0.003969667,-0.006074499,-0.006901513,-0.025737973,0.009736063,0.0026091482,-0.025919592,-0.0035869705,-0.013828971,-0.010443079,-0.019381316,0.007790148,0.0070247543,-0.009405257,0.03442973,0.006175038,0.006525303,0.00085620274,0.020276438,-0.01447761,-0.009710117,0.013478707,0.005724234,-0.007135023,0.025050417,-0.012434399,-0.014088427,0.027139032,0.013647352,-0.0011489008,0.012447371,0.027294705,0.011273336,0.017357565,-0.0002450637,0.027190924,0.004777222,0.011026854,0.0056690997,0.018615924,0.0022880721,0.01377708,-0.018071067,-0.01869376,-0.0029334673,0.002320504,0.011448468,-0.0044820914,-0.005030191,0.015204085,-0.019355372,-0.0061912537,0.026620122,-0.024142323,-0.02169047,0.043303102,0.030096823,-0.049348414,0.0056139654,-0.02750227,0.033340015,-0.008575,0.020938048,-0.016125152,0.03069357,0.023415847,0.018551059,-0.012395481,0.016708925,0.031549774,0.0062334156,-0.008918779,0.0009559309,-0.016890544,0.035208095,0.011253877,0.020938048,0.015359758,-0.007679879,0.029240621,-0.013141415,0.023454767,0.015268949,-0.030953025,0.007323128,0.012946824,0.009995518,0.009152289,-0.012148998,0.0377767,0.021443987,0.0073036687,-0.00943769,-0.0075177196,0.018447278,0.008464731,0.0034572429,-0.013128442,0.028021181,-0.002339963,-0.012693854,-0.001610245,-0.030200606,-0.020561839,0.018045122,0.028617928,0.021651551,0.0064831413,0.024596369,0.03092708,0.024713125,-0.0052572144,0.009781468,-0.002750227,-0.0019815904,0.00036506183,-0.00055904523,0.03655726,-0.013764108,0.03134221,-0.01555435,0.004705872,-0.0048680315,-0.036064297,-0.0319649,0.019018078,-0.0016815951,0.03058979,-0.020756429,-0.020016981,0.029655749,-0.0069923224,0.024661234,0.0015267327,0.02262451,0.015852723,-0.0046474943,-0.010300378,-0.661715,-0.00803663,-0.003030763,0.008626891,0.009359852,0.020886159,0.0054064016,0.0024032055,-0.013212765,0.02323423,-0.0142570725,-0.0065544914,0.01447761,-0.001958888,-0.031238427,-0.0124603445,0.0054031583,-0.0024502317,-0.016670007,-0.005789098,-0.0403972,0.005380456,0.008056089,0.0050139753,-0.010546861,0.010773884,0.011182527,-0.029551968,0.0024518534,0.05925961,-0.035727005,0.022832073,0.011558737,0.00023715843,0.043640394,-0.0015997045,-0.015593268,0.039151818,0.0052896463,0.025686081,-0.013686271,-0.007926362,0.016501362,-0.0064701685,5.5438315e-05,-0.00974255,0.020821294,0.015761914,-0.008497164,-0.007725284,-0.038555067,5.787071e-05,-0.012752231,0.0041934475,0.00742691,-0.0003295894,0.012090621,-0.02351963,0.00742691,0.036323752,-0.009314448,0.010280919,-0.009969573,0.014399773,-0.034455676,0.011759815,0.0018534843,0.005633425,0.022040734,-0.026464447,0.024142323,0.018615924,-0.023869894,0.0038107508,0.0135824885,0.010371729,0.0042875,-0.027606051,-0.013764108,-0.011883056,0.011831165,-0.0056269383,-0.0075501516,-0.013893835,0.026127156,-0.010293892,-0.01663109,0.004015072,0.019277534,0.017318645,0.0023659086,0.029162785,-0.0016556496,-0.010605238,-0.009431203,-0.010670102,-0.008490677,-0.0030015744,-0.0010978206,-0.028825492,-0.02445367,-0.021612633,0.01897916,-0.020159682,0.0044626324,-0.006599896,-0.017111082,0.014866793,0.03186112,-0.0117663015,-0.013880863,-0.012992227,0.0074852877,-0.016514335,0.009392285,-0.024661234,0.022481808,0.016319742,0.0085814865,-0.012752231,0.0036323753,-0.0033048128,0.023117473,-0.005620452,0.022416944,0.019316453,-0.012804123,-0.022715319,-0.03040817,0.009891736,0.0105209155,0.015567322,0.008412841,-0.0077706883,0.012265753,0.013147901,0.0092560705,-0.0096647125,0.0311087,-0.009502553,-0.0073620463,-0.0074852877,-0.0027923884,-0.021560742,-0.0005683694,-0.026697958,-0.0026399584,-0.0016751088,-0.020639675,-0.008133926,-0.023999622,-0.00628855,-0.0064961137,0.012382507,0.025621219,-0.004404255,-0.025128253,-0.0170073,0.010151192,0.004381553,0.014283018,-0.00048647882,-0.043510668,-0.008750132,-0.0050853253,-0.023441793,0.013984645,0.004381553,-0.014075454,-0.045560364,-0.007439883,-0.0070052953,-0.00092998537,-0.0016013262,-0.009937141,0.007375019,-0.003163734,-0.017642966,-0.03564917,-0.016838653,0.021586686,0.010391188,-0.0015940289,-0.013530598,0.035026476,-0.008918779,0.04685764,0.024518533,0.00077309593,0.03912587,-0.013245197,0.018356469,-0.014321936,0.0055750473,-0.0053934287,-0.013083037,0.023363957,0.0066744895,0.01363438,0.0421615,-0.0033275152,-0.025712028,0.015294895,-0.048933282,0.019718608,-0.028799547,0.00028073884,-0.026529312,-0.003950208,0.014179236,0.01897916,0.0069793495,-0.004388039,-0.027580107,0.0037588598,0.015139221,-0.0112149585,-0.0046183057,-0.017733775,-0.01377708,0.010572807,0.00035654844,0.009813899,0.01096199,-0.016384607,0.014192209,0.008017171,0.048466265,-0.020354275,-0.025621219,-0.01262899,-0.0072323186,-0.002091859,0.010183623,0.012966283,0.0001900308,0.012583585,-0.014218154,0.024907716,-0.008996615,-0.007829066,0.01790242,0.021236422,-0.026697958,0.006311252,-0.010812803,0.004692899,0.006901513,0.005698289,0.008166358,0.005448563,0.001866457,-0.013854917,0.0044820914,-0.0020983454,-0.024375832,0.016734872,0.001694568,0.025932565,0.017124055,0.0130311465,-0.010209569,-0.0008780943,-0.015891641,0.01117604,0.01616407,0.010936044,0.0023432064,0.017733775,-0.012706827,-0.005824773,-0.009152289,-0.0070442134,-0.015684078,0.034144327,0.0012121431,-0.01860295,0.0089706695,0.017772693,0.013854917,-0.01616407,-0.046546295,0.002521582,-0.006823676,-0.018161876,-0.02866982,-0.017227838,-0.0035675114,-0.023675302,0.034896746,0.012564126,0.037854537,-0.0073490734,0.00012050486,-1.2972769e-05,-0.017513238,0.03144599,-0.009729576,0.03500053,-0.0031248156,-0.017072164,0.0028880627,0.0024859067,0.00061134173,0.029240621,-0.0029334673,-0.0032091388,-0.033755146,-0.011707923,0.0030502223,-0.02455745,-0.01302466,-0.012635477,-0.0036161593,-0.04091611,0.0040864223,-0.005455049,-0.012583585,0.020587783,0.01340087,-0.014399773,-0.024518533,-0.011630087,0.015294895,0.06782164,-0.0027356327,0.007167455,0.007913389,-0.011111177,0.011467927,0.01799323,-0.041902043,0.012687367,-0.010916585,-0.015294895,-0.003428054,0.035363767,-0.0061847675,0.022611536,-0.002244289,-0.033132453,0.02244289,0.01785053,0.00051728915,0.018823488,-0.003183193,0.0170073,0.022403972,-0.012376022,-0.022559645,0.014308964,0.035052422,0.004436687,-0.044289034,-0.0069988086,-0.02140507,-0.014698147,0.011513332,-0.001324844,-0.025569327,-0.016138125,0.020354275,0.024726097,-0.012382507,-0.012045216,0.03645348,-0.0012632234,-0.013958699,0.0017918637,-0.004488578,-0.0057080183,0.025789864,-0.003312921,0.0010864694,0.036583208,-0.006531789,0.0066939485,0.0021129397,0.004235609,0.0038366963,-0.024077458,-0.01140955,-0.009917682,-0.012142511,-0.008613919,0.00042120958,0.005665857,-0.005231269,-0.009171748,-0.024401778,-0.012661423,-0.02778767,-0.04366634,-0.0053577535,-0.0012883581,-0.03551944,0.00735556,-0.012583585,0.011059285,0.010540375,0.017876476,-0.016060287,-8.467772e-05,0.018680787,0.012654936,0.007491774,-0.0121944025,-0.040604766,0.0016264609,0.006155579,0.012168457,0.010903612,-0.013193306,-0.0052864035,0.008821483,-0.0006980971,0.018356469,-0.002862117,0.013083037,-0.0116236005,-0.010845235,0.006327468,-0.0032010307,-0.01508733,0.027372543,-0.024207186,-0.015152194,-0.0013629515,0.008866888,-0.014568419,0.017266756,0.012025757,-0.03603835,-0.01040416,0.0028750899,-0.01817485,0.004018315,0.0037556165,0.011273336,-0.011163067,0.0040345313,0.022520727,0.0032188683,-0.026204992,0.012161971,-0.009729576,0.0037750758,0.02389584,-0.02089913,0.041824207,-0.003087519,-0.025517436,-0.010663616,-0.022339107,0.008043117,0.018447278,-0.00060769316,-0.035960514,-0.021015886,0.0069988086,-0.002111318,0.02455745,-0.023856921,0.0025475274,-0.013841944,-0.0030842759,0.011026854,0.0049523544,-0.0072517777,-0.023727193,-0.01255764,0.015632186,-0.013336007,0.0014456529,-0.021197503,0.008756619,0.004018315,-0.014192209,-0.002083751,-0.036998335,-0.023999622,0.015567322,0.027294705,0.038918305,0.00628855,-0.0065771937,0.023312066,-0.010462538,0.009755522,0.011111177,-0.005328565,-0.0030858973,-0.015359758,0.0141014,-0.0032496785,-0.014127345,0.017111082,0.04127935,0.023701249,0.018317549,0.013530598,-0.0058799074,-0.012868986,-0.01593056,0.0061912537,0.0064182775,-0.005536129,-0.022040734,-0.014231128,-0.032821104,0.040111803,0.0051923506,-0.0099501135,-0.010254974,0.0251542,-0.011221445,0.03180923,-0.025465544,0.011493873,-0.03250976,0.00398264,-0.021431014,0.0059285555,0.0007698527,0.002746984,0.0047674924,-0.00060850393,0.001469166,0.013841944,0.011513332,-0.010793343,-0.00773177,0.017175946,-0.0047285743,-0.028929275,-0.03725779,-0.021768305,-0.025413655,-0.0013799783,0.026308775,-0.022806127,0.0054615354,-0.010014977,-0.013906808,0.008724187,-0.011902516,0.03967073,0.0022394243,0.024661234,0.013141415,0.010767398,-0.013374925,0.02497258,0.007900416,0.010131733,0.030719517,0.031835176,-0.009969573,-0.02052292,0.015126248,0.0064766547,-0.032405976,-0.04021558,0.02866982,0.0008780943,0.003106978,-0.017422428,0.0033242719,-0.0021891547,0.0036842662,-0.0014245722,-0.02361044,-0.0007864741,-0.01625488,-0.0287736,0.025335817,-0.011111177,0.0013556543,-0.008866888,-0.006625842,-0.0007179617,-0.007945821,-0.021988843,0.012168457,0.005176135,-0.0025605003,-0.016384607,0.0057631526,0.011474414,-0.01756513,0.001830782,-0.011331714,-0.014075454,0.03302867,-0.01785053,0.004164259,-0.011934947,0.011675492,-0.018940242,-0.0031264373,-0.0046377648,-0.014283018,-0.0120711615,0.00017452428,0.041383132,0.016916491,-0.000810798,-0.008140412,-0.015061384,0.017720802,-0.00628855,-0.015139221,-3.8639595e-05,-0.029733585,-0.008685268,0.0064507094,-0.003376163,0.008237708,0.0046961424,-0.027476324,0.019329425,0.026075264,0.0041610156,0.019446181,-0.036894556,0.007465828,-0.03134221,-0.010540375,0.018421331,-0.023805032,0.017435402,-0.014763011,-0.045223072,-0.0014553824,0.0047869515,0.023999622,-0.027476324,0.0026594177,0.030849244,0.0066744895,0.021625606,-0.0071804277,0.003541566,0.018148903,-0.008023658,-0.007407451,0.0064571956,-0.025530409,0.007809607,-0.034170274,-0.0058669345,0.010300378,-0.032924887,-0.028099017,-0.008192304,0.030849244,-0.015100303,-0.012525208,-0.0340146,-0.020717511,-0.018239712,0.029785477,0.0015672726,-0.0050204615,0.0021210476,0.03476702,-0.004300473,0.012233321,-0.015735969,-0.023363957,0.016786763,-0.01087118,-0.038581014,-0.007173941,-0.019524017,0.034222163,-0.01004741,0.006544762,-0.030018987,0.02009482,-0.04156475,-0.018473223,0.021988843,0.019277534,0.026438503,0.0012899797,0.009191207,0.02323423,0.013556544,0.0026610391,-0.028228745,-0.02581581,-0.0023869895,0.006823676,0.021249395,0.0039437218,-0.023636384,0.0061717946,0.030252496,-0.012940337,0.0046150624,0.012914391,-0.03157572,-0.025050417,-0.029500077,0.02497258,0.0072906963,0.0075501516,0.0027032008,0.0043296614,-0.024868798,0.015165167,0.0022653698,-0.0113576595,0.0073490734,-0.00089349947,-0.013699244,0.043873902,-0.015735969,0.008652837,0.0043588504,-0.012233321,0.016293798,0.0015494351,-0.011390091,0.026775794,-0.006314495,-0.030356279,-0.014153291,0.01836944,-0.0060680127,0.009119856,0.012551154,0.001730243,0.033755146,-0.008685268,0.015904615,-0.036323752,0.009139315,0.001830782,0.005720991,-0.021638578,0.020730484,-0.0069988086,0.010060382,0.016825682,-0.005169648,0.019939145,0.003424811,-0.012388994,-0.0020415895,0.0031621123,0.013037632,0.016786763,-0.016215961,-0.0049199224,-0.016008396,-0.008120953,-0.032354087,0.008977156,0.18224145,-0.00071431306,0.026905522,0.018953215,-0.008133926,-0.005922069,0.039151818,-0.0013799783,-0.007835552,0.02351963,-0.010430106,0.018628895,-0.004190204,0.013225738,0.03227625,-0.020250492,0.0053253216,0.0058669345,-0.009294989,-0.040163692,-0.009035533,0.0026513096,-0.0034021086,-0.0013572759,0.0311087,0.00528316,-0.010339296,-0.009450662,0.0103976745,0.018551059,0.0069404314,-0.018213768,-0.022494782,0.011487387,-0.010696048,0.004268041,-0.0282028,0.02333801,0.025076361,0.01705919,0.0014870036,0.014788956,0.0012616018,0.009282016,-0.004057233,0.040163692,-0.006466925,-0.012635477,-0.020860212,0.011740356,-0.021820197,0.021716414,0.034351893,0.011221445,-0.0030080609,-0.017305674,-0.009171748,-0.007109077,-0.010689561,0.014763011,-0.0052053235,0.025750946,-0.0046442514,0.022092625,-0.026127156,0.031783283,-0.029370349,0.01302466,-0.002674012,-0.006256118,-0.016436499,-0.03948911,0.005247485,-0.006463682,0.011163067,-0.008172845,0.01227224,0.007530692,0.010371729,0.01164306,-0.00047472227,-0.012875473,-0.024323942,0.030460062,-0.012804123,-0.014775984,0.040319365,0.0055101835,0.01564516,-0.012966283,-0.019511044,-0.015541377,-3.729671e-05,-0.02272829,0.01164306,0.010488483,0.0025961753,0.022066679,-0.022313163,-0.031705447,-0.010696048,-0.006625842,0.02872171,0.015450568,-0.012012783,-0.012453858,-0.011111177,0.024726097,-0.004242095,-0.025283927,-0.0066420576,-0.020665621,0.015204085,-0.024090432,0.014218154,0.017642966,-0.0036907527,-0.0131543875,0.018330522,-0.004336148,-0.015684078,-0.007394478,0.017604047,0.004452903,-0.00887986,-0.032250304,-0.011993324,0.008056089,0.0033340016,-0.029759532,-0.00086187833,-0.02361044,0.012161971,-0.015619214,0.009567417,0.0033340016,0.010631184,-0.031238427,0.0103976745,0.0062009837,0.013880863,0.007446369,0.012116566,0.013374925,0.013141415,-0.027528215,0.015528404,0.011675492,-0.015671104,-0.019316453,-0.027216868,-0.005633425,0.016241906,-0.031316265,0.029526021,-0.00374913,-0.016916491,-0.0343,-0.002584824,-0.0050561368,-0.0064766547,-0.011772787,0.0194851,-0.016877573,-0.009197693,0.020393193,-0.16439092,-0.00895121,0.027891453,0.004501551,0.012129539,0.0046669533,0.02202776,-0.017824585,-0.0006263415,-0.00032614352,0.015230031,-0.002617256,-0.03323623,-0.021898033,0.0049004634,-0.0016994327,0.009431203,-0.0028799546,0.015074357,0.0016337581,0.039437216,-0.018330522,0.016890544,-0.00046053328,0.00644098,0.024803935,-0.002581581,-0.0016670008,0.012596559,-0.031601664,-0.014801929,0.0025005012,-0.0019248346,-0.00040175044,-0.011701438,0.003661564,0.0016734871,-0.010812803,-0.016708925,0.0046377648,0.018265659,0.0076020425,0.027917398,-0.017098108,0.008458246,0.004096152,0.005380456,-0.00077471754,0.0055815335,-0.032431923,0.0069339448,-0.038217776,0.024609342,0.0053123487,0.018654842,0.015917588,0.007945821,-0.009593363,0.0029934663,-0.022131544,-0.015528404,-0.031264372,0.008146899,-0.019627798,0.008322031,-0.005335051,-0.027424432,0.030018987,-0.01939429,-0.007783661,-0.016319742,-0.024297995,0.03411838,-0.027580107,0.0039891265,0.010287406,-0.0068625947,0.0045177666,-0.017487293,-0.007141509,-0.014775984,0.050048944,-0.017785667,0.012920878,0.027424432,0.001790242,0.004540469,-0.016644062,0.023571521,0.0013102497,0.015022466,-0.011227931,-0.022390999,0.0058993665,0.026620122,0.009262557,-0.025543382,-0.00010895099,-0.004705872,-0.01288196,0.012453858,-0.031056808,-0.012453858,0.010371729,0.017591074,0.012395481,0.006411791,0.0058604483,0.02263748,-0.0028815763,0.015048412,-0.014438692,0.017124055,0.0003391163,-0.020665621,0.0040215584,0.018927269,-0.036271863,0.032042738,-0.0008772835,0.02394773,-0.007764202,-0.01056632,-0.012304671,-0.0015243003,-0.015074357,-0.10315946,-0.0019248346,0.0076539335,0.0130311465,-0.021962898,0.019575909,0.0073815053,0.013608434,0.010683075,0.015476513,0.012226835,-0.00674584,0.0006271523,-0.010812803,0.008328518,-0.0023610438,-0.009158774,-0.010689561,-0.0073815053,-0.0065707075,0.005604236,-0.016670007,0.0055491016,-0.00848419,0.0020367247,0.034896746,-0.015761914,0.012473317,0.02708714,0.015995424,0.0029172513,-0.018538086,-0.0019248346,-0.02656823,-0.0055977497,-0.015917588,-0.009625794,-0.012350076,0.026620122,-0.0251542,-0.015372731,0.0036810231,-0.005909096,-0.042420954,-0.006732867,-0.009723091,-0.014049509,0.010741453,0.0040604766,-0.02534879,-0.0020578054,-0.010825776,-0.042524736,-0.020328328,0.040085856,-0.0074852877,0.0010394431,0.02361044,-0.008030144,0.004044261,0.0052215396,-0.001156198,0.025621219,0.030096823,0.016371634,0.005941528,-0.005584777,0.008944724,0.03256165,-0.012058188,0.007978253,0.03186112,-0.01569705,-0.008665809,-0.031056808,0.020159682,-0.008283113,-0.016734872,0.019238615,-0.009288503,-0.015761914,-0.023013692,-0.007744743,-0.0028394149,-0.0027356327,0.013997617,0.0145424735,-0.0043296614,0.006058283,-0.003693996,0.009067966,0.012187916,-0.0040345313,-0.0026529313,-0.004469119,0.0061166603,0.009087425,0.0011902516,0.015943533,0.020068873,-0.023869894,-0.021703443,-0.053344026,0.017681884,0.00019134834,-0.015126248,0.028617928,-0.013530598,0.009917682,-0.018823488,0.011720897,0.0228191,-0.041590698,0.013044119,-0.0228191,0.0145813925,-0.02052292,0.011448468,0.008944724,0.00051607296,0.033340015,0.027761726,-0.001100253,0.008451759,0.03795832,0.013128442,-0.006447466,0.02220938,-0.021469932,0.01930348,-0.020419138,0.0061134174,0.021962898,-0.028150909,-0.013284115,0.021119667,-0.008892833,-0.006243145,0.0051210006,0.024168268,-0.023805032,0.01836944,-0.011681979,-0.00013753162,3.896898e-05,-0.02131426,0.006616112,0.0013264656,-0.0050139753,0.018667813,0.012239807,-0.011240904,0.03655726,0.007530692,-0.026101211,-0.010125246,-0.016721899,-0.017500265,0.03500053,0.008380408,0.013245197,-0.022092625,0.034844857,0.0033242719,0.017500265,-0.019614827,-0.007842039,0.0067393533,-0.022313163,0.016592171,0.017837558,-0.025102308,-0.029214675,0.003914533,0.0057015317,-0.0041804747,0.014983548,-0.019991037,-0.0140105905,-0.00911337,-0.028617928,0.01433491,0.0030129256,-0.0143868,-0.016423525,-0.0007483666,0.04057882,-0.019926174,-0.014179236,0.0152559765,-0.0050918115,0.0025669867,-0.019640772,0.015735969,-0.012213862,0.008568514,-0.008458246,0.021301286,-0.0028718468,0.008030144,-0.00080714945,0.023701249,-0.00035289986,0.007018268,-0.019614827,-0.018551059,-0.023805032,-0.012434399,-0.010592266,-0.041175567,-0.019666718,0.013323033,0.010897126,-0.004057233,-0.0012916013,-0.0014059239,-0.01248629,0.032120574,-0.003411838,-0.0026691472,-0.0225337,0.005633425,0.002497258,0.0033631902,0.03969667,-0.01377708,0.0011886299,0.0037394005,0.03308056,-0.02201479,0.009995518,-0.0010426863,-0.0022572617,0.0030988702,-0.006256118,-0.018304577,-0.019044025,-0.007679879,0.019848336,0.009690658,-0.02010779,0.034689184,0.0029075218,0.0011829543,0.034559455,-0.023779085,0.019173753,0.02412935,0.03250976,-0.020159682,0.012200889,-0.00233672,-0.020691566,0.01949807,-0.014347882,-0.01827863,0.020081846,-0.0015307867,-0.01738351,0.004540469,-0.024713125,0.019199697,-0.0015591646,0.021521823,0.0013353843,-0.017941339,-0.009528499,0.0199132,-0.014062481,-0.009217152,-0.017811611,0.01227224,0.011039826,-0.034741074,-0.013880863,0.005753423,-0.023727193,0.0048485724,0.005030191,0.024207186,-0.008490677,-0.023986649,-0.020406166,-0.018914297,-0.002481042,0.00064580067,0.012466831,-0.026931468,-0.008665809,-0.02698336] \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/popular.90s.comedy.vector.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/popular.90s.comedy.vector.mdx new file mode 100644 index 000000000..67ad48d4c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/_snippets/popular.90s.comedy.vector.mdx @@ -0,0 +1 @@ +[0.011615951545536518,-0.041561901569366455,-0.007776559796184301,-0.017821554094552994,-0.019294733181595802,0.02404019609093666,-0.020011767745018005,-0.029985059052705765,-0.009738625958561897,-0.019777102395892143,0.011420396156609058,0.011381285265088081,0.02126331813633442,0.0006441083969548345,-0.00040923902997747064,0.003252727212384343,0.03358326479792595,-0.010207957588136196,0.012528539635241032,-0.028029512614011765,-0.002819247543811798,0.0020549544133245945,-0.01788673922419548,-0.022514868527650833,0.01934688165783882,0.009816847741603851,0.022697385400533676,-0.018251774832606316,-0.010566473938524723,-0.010149290785193443,0.01877325400710106,-0.004126205109059811,-0.00828500185161829,-0.005051830783486366,-0.019829250872135162,-0.010410030372440815,-0.016257116571068764,0.0006098863086663187,0.026621518656611443,0.007385450415313244,-0.0030881352722644806,-0.022228054702281952,-0.009340997785329819,-0.014562309719622135,-0.030480464920401573,0.006016567349433899,0.013806164264678955,-0.016739485785365105,-0.009862476959824562,0.009706033393740654,0.018121404573321342,-0.012671946547925472,-0.018434293568134308,-0.014979492872953415,0.01627015322446823,0.007848263718187809,-0.0029773209244012833,-0.004012131132185459,0.01617889478802681,-0.0035590962506830692,-0.01808229461312294,-0.010951065458357334,-0.022175906226038933,0.019868360832333565,-0.014275495894253254,0.026308629661798477,0.012763205915689468,-0.017169706523418427,0.01797799952328205,-0.012104838155210018,0.02184998244047165,0.001570956315845251,0.003663392039015889,0.01199402380734682,-0.00033468377660028636,-0.017182743176817894,-0.002327101305127144,0.012163504958152771,-0.01229387428611517,0.00793952215462923,0.033557191491127014,-0.02727336622774601,0.001487845554947853,-0.0004795165150426328,0.010455659590661526,-0.0013110315194353461,-0.020024804398417473,0.02434004656970501,-0.016987187787890434,-0.008154632523655891,0.00921062845736742,0.019073104485869408,0.04265700653195381,0.018786290660500526,-0.01969888061285019,0.02829025126993656,-0.011915802024304867,0.012052690610289574,0.006078492850065231,-0.008910777047276497,0.01067728828638792,-0.007672264240682125,-0.02985468879342079,-0.02032465487718582,0.02174568735063076,-0.007561449892818928,-0.006088270805776119,0.010553437285125256,0.014523197896778584,0.011902764439582825,-0.0010103661334142089,0.024300934746861458,0.016635188832879066,-0.034965187311172485,-0.0123916519805789,-0.01603548787534237,0.018681995570659637,-0.00523108895868063,-0.02810773439705372,-0.02727336622774601,0.011818024329841137,-0.003754650941118598,0.035851702094078064,-0.005879679229110479,0.02834239974617958,0.006049159914255142,-0.01842125691473484,-0.024613821879029274,0.013362906873226166,0.011055361479520798,0.042500562965869904,-0.012228689156472683,0.024744192138314247,-0.00845448300242424,-0.03801583871245384,0.01804318279027939,-0.0005760716740041971,0.018238738179206848,-0.011661580763757229,-0.01119224913418293,0.019490288570523262,0.04466470330953598,-0.015696527436375618,-0.004611832555383444,-0.011166175827383995,0.017560815438628197,0.019516361877322197,0.005459236446768045,0.00791996717453003,-0.004644425120204687,0.027351589873433113,-0.0021250280551612377,0.00931492354720831,0.02199338935315609,-0.01035788282752037,0.01852555200457573,-0.00765922712162137,0.008949887938797474,-0.01954243704676628,-0.020311618223786354,0.002983839251101017,0.011022768914699554,0.027586255222558975,-0.022319313138723373,-0.028811730444431305,0.02364908531308174,0.044299665838479996,0.007985151372849941,0.006094789132475853,-0.010755510069429874,0.012502466328442097,0.020063916221261024,-0.043569594621658325,0.017808517441153526,0.0009932550601661205,0.016922002658247948,-0.018316959962248802,0.015096825547516346,-0.0012108096852898598,-0.004862794186919928,0.019033994525671005,0.02149798348546028,0.01464053150266409,0.04393463209271431,-0.014431939460337162,0.011446470394730568,0.013291203416883945,-0.023636048659682274,-0.007913447916507721,-0.007809152361005545,0.020168211311101913,0.025917520746588707,0.008637000806629658,-0.025813225656747818,-0.6378734707832336,-0.014353717677295208,-0.006000271067023277,-0.0254221148788929,0.025630706921219826,-0.000653071328997612,-0.013949571177363396,-0.006593453697860241,-0.01813444308936596,-0.009490923024713993,0.006208862643688917,0.011270470917224884,0.030324021354317665,-0.0015571045223623514,-0.022997237741947174,-0.011094472371041775,0.02169353887438774,-0.011244397610425949,0.0050779045559465885,-0.007326784078031778,-0.03029794618487358,0.016061563044786453,-0.0065804170444607735,-0.017678147181868553,0.021758724004030228,0.02439219318330288,0.015852971002459526,-0.018121404573321342,-0.008734778501093388,0.0032282827887684107,-0.025200486183166504,0.04409107565879822,-0.01295224204659462,-0.0017583629814907908,0.0620560348033905,-0.004879090469330549,-0.009080258198082447,0.031888458877801895,0.004005612805485725,0.03402652218937874,-0.010866324417293072,-0.009093294851481915,-0.0010959213832393289,0.0012735502095893025,0.0009679959621280432,0.0068183415569365025,0.0057493094354867935,-0.005625457968562841,-0.009471368044614792,-0.014992529526352882,0.028811730444431305,0.005648272577673197,0.019998731091618538,0.002716581104323268,0.011974467895925045,0.0035982071422040462,0.012593724764883518,0.0030946535989642143,0.01316735241562128,0.0011545877205207944,-0.003885020734742284,0.015096825547516346,-0.015996377915143967,0.0022065092343837023,-0.005462495610117912,0.022462720051407814,0.015474897809326649,0.006968267261981964,0.02018124796450138,-0.030584760010242462,0.01046217791736126,0.006384862121194601,-0.0280555859208107,0.0009606626117601991,-0.007835226133465767,0.014927344396710396,0.013310759328305721,-0.0005911456537432969,-0.00889774039387703,0.018264811486005783,0.007535375654697418,0.006146937143057585,-0.015227195806801319,-0.006309899501502514,0.02888995222747326,-0.01817355304956436,-0.01475786417722702,0.014405865222215652,0.01808229461312294,0.0027882845606654882,0.02082006074488163,0.0020859171636402607,-0.017274001613259315,-0.027820920571684837,-0.0026008780114352703,-0.018590737134218216,-0.026751887053251266,0.010123216547071934,0.033948302268981934,-0.04443003609776497,0.028081659227609634,-0.02302331104874611,0.02263220213353634,-0.001355031388811767,-0.018004072830080986,0.012372096069157124,0.0030995425768196583,0.027638401836156845,0.02145887352526188,-0.009803811088204384,0.012847946025431156,-0.012763205915689468,-0.008337150327861309,-0.044690776616334915,-0.005928567610681057,-0.019281696528196335,0.010305734351277351,0.02003784105181694,0.010996694676578045,-0.000906070286873728,0.00887166615575552,-0.036868587136268616,-0.014875196851789951,0.007548412773758173,-0.006401158403605223,0.014471050351858139,0.019047031179070473,0.008187225088477135,-0.009797291830182076,-0.0036959846038371325,-0.006544565316289663,0.004536869935691357,0.022905977442860603,-0.005478791892528534,-0.010031958110630512,0.030271872878074646,0.010488252155482769,-0.02823810465633869,0.002866506576538086,-0.008610926568508148,-0.0014226606581360102,-0.005309311207383871,-0.021758724004030228,-0.007053007371723652,-0.0036731697618961334,-0.03358326479792595,0.008304557763040066,0.006225158926099539,-0.018356071785092354,-0.0018724366091191769,-0.01014277245849371,-0.012639353983104229,-0.006665157154202461,-0.00048807202256284654,0.01018840167671442,-0.009999365545809269,-0.006837897468358278,-0.022449683398008347,-0.004536869935691357,-0.015566157177090645,0.02144583687186241,0.01573563739657402,-0.021145984530448914,-0.0022423609625548124,0.01744348183274269,-0.008056854829192162,-0.009275812655687332,0.016922002658247948,-0.013219499960541725,-0.018395181745290756,0.007346339523792267,0.011818024329841137,-0.00828500185161829,0.0021625093650072813,-0.007952558808028698,0.0424223393201828,0.008213299326598644,-0.013428092002868652,0.023922862485051155,-0.0058210124261677265,0.0014259199379011989,-0.015018603764474392,-0.020311618223786354,-0.026021817699074745,0.03629495948553085,-0.025682855397462845,0.033348601311445236,0.02169353887438774,-0.020780950784683228,0.008102484978735447,-0.009295368567109108,0.014810011722147465,-0.01799103617668152,-0.03402652218937874,0.01730007492005825,-0.01651785708963871,0.02149798348546028,0.016061563044786453,0.026360778138041496,0.004680276848375797,0.018095331266522408,-0.003523244522511959,0.01681770756840706,-0.020455025136470795,0.014275495894253254,-0.032566383481025696,-0.006759675219655037,-0.03778117522597313,0.0037742063868790865,0.030324021354317665,0.007652708794921637,0.014705715700984001,0.0021543612238019705,-0.02072880230844021,-0.004611832555383444,0.028550991788506508,-0.03230564296245575,0.027038700878620148,-0.01434068102389574,-0.0051561263389885426,-0.02014213800430298,-0.015722600743174553,0.022215018048882484,0.017365260049700737,0.0008555519743822515,0.013519350439310074,-0.005403829272836447,-0.016882892698049545,-0.003640577429905534,-0.023244939744472504,-0.004748720675706863,0.027090849354863167,0.0045401290990412235,0.039997462183237076,-0.0019180660601705313,-0.03812013566493988,0.021771760657429695,-0.012750168330967426,0.03001113422214985,-0.0055374582298099995,-0.023766418918967247,0.024548638612031937,0.012274319306015968,-0.011498618870973587,0.008474038913846016,-0.0012678465573117137,0.012658909894526005,0.002385767875239253,-0.009047665633261204,0.022905977442860603,-0.01735222339630127,-0.017730295658111572,-0.002615544479340315,0.005866642110049725,0.018551625311374664,-0.0225279051810503,0.028863878920674324,-0.002630211180076003,0.010423067025840282,0.03251423314213753,-0.007522339001297951,-0.03274890035390854,0.020833097398281097,-0.010194920003414154,0.0028599880170077085,1.3049713743384928e-05,-0.0012458466226235032,-0.022358424961566925,-0.03113231435418129,0.019868360832333565,-0.006681453436613083,-0.022658275440335274,0.004276130348443985,-0.014119052328169346,-0.004898645915091038,-0.0029463579412549734,-0.04059716314077377,0.03522592782974243,-0.01473178993910551,-0.017091484740376472,-0.01563134230673313,-0.044795069843530655,0.02512226440012455,0.0069030821323394775,-0.007854782044887543,-0.00035607258905656636,-0.001487845554947853,-0.020246433094143867,-0.00619582599028945,0.01832999661564827,-0.020207323133945465,0.019333845004439354,-0.02101561613380909,0.0261000394821167,-0.0031712460331618786,0.003614503424614668,0.01563134230673313,0.0031924310605973005,0.007215969730168581,0.005446199327707291,-1.573604458826594e-05,0.008363224565982819,-0.04135330766439438,-0.03420904278755188,0.013375943526625633,-0.015970302745699883,-0.005279977805912495,-0.028577065095305443,0.0039045761805027723,-0.00017212890088558197,0.00024444342125207186,-0.005211533512920141,-0.02800343744456768,0.007933003827929497,-0.018004072830080986,-0.005586347077041864,-0.006671675946563482,-0.016504820436239243,0.018238738179206848,-0.020194286480545998,0.0011171064106747508,-0.03199275583028793,-0.023049384355545044,-0.0031223571859300137,0.11921016871929169,0.008304557763040066,0.02507011778652668,0.0156443789601326,-0.015566157177090645,-0.01754777878522873,-0.015540082938969135,0.0002884432324208319,0.014158163219690323,-0.008337150327861309,0.03175808861851692,-0.005899234674870968,0.01975102908909321,-0.006909600459039211,0.011720247566699982,0.005625457968562841,-0.009829884395003319,0.002861617598682642,0.03108016587793827,-0.013714905828237534,-0.028264177963137627,-0.0026790997944772243,0.0072355251759290695,0.014418902806937695,0.0024395452346652746,-0.03577347844839096,0.019033994525671005,0.031106239184737206,0.018538588657975197,-0.01935991831123829,-0.03337467461824417,0.008434928022325039,-0.021628353744745255,0.002825765870511532,0.03689466044306755,0.00887166615575552,0.016152821481227875,-0.0015913266688585281,0.018199628219008446,-0.008617444895207882,0.015109862200915813,0.0030213205609470606,0.007985151372849941,-0.019138289615511894,0.025278707966208458,-0.027742698788642883,-0.012007060460746288,0.027142997831106186,0.004618350882083178,-0.021380651742219925,0.03342682123184204,-0.010058032348752022,-0.013962607830762863,0.02111991122364998,0.01774333231151104,0.004918201360851526,-0.008226335979998112,-0.013245574198663235,-0.026230407878756523,0.007887374609708786,-0.008441446349024773,-0.020415915176272392,0.025474263355135918,-0.004357611294835806,-0.01084676943719387,-0.02394893579185009,-0.003927391022443771,-0.0007162191905081272,-0.0016817707801237702,-0.012932686135172844,-0.014796975068747997,-0.01131610106676817,-0.021145984530448914,0.021667465567588806,0.011648544110357761,-0.004087093751877546,0.013649720698595047,-0.005543976556509733,-0.00789389293640852,0.012756687588989735,-0.002947987522929907,-0.01969888061285019,-0.003251097397878766,-0.04575980827212334,0.011466026306152344,0.010396993719041348,0.00845448300242424,0.00018628625548444688,-0.029098544269800186,0.0032722826581448317,0.03240993991494179,-0.005710198078304529,-0.007887374609708786,0.015657415613532066,0.005983974784612656,-0.004315241239964962,0.0359559990465641,0.03327037766575813,0.027351589873433113,0.003950205631554127,-0.0009557737503200769,-0.03895450383424759,-0.007691819686442614,0.0019962878432124853,-0.03214919939637184,-0.006844415795058012,-0.00896944385021925,0.0248224139213562,-0.019633695483207703,-0.0016271783970296383,0.028994249179959297,0.008832555264234543,0.005035534501075745,-0.01170720998197794,0.021132947877049446,0.030167577788233757,-0.001693178084678948,0.034287262707948685,-0.023049384355545044,0.008813000284135342,0.016974151134490967,-0.04080575332045555,0.016530893743038177,0.017143631353974342,-0.0006881082081235945,-0.0005108867189846933,0.014679642394185066,-0.03274890035390854,-0.0017029558075591922,-0.00023690641683060676,-0.0034059116151183844,0.04091005027294159,-0.0018919920548796654,-0.026856184005737305,-0.03475659340620041,-0.010931509546935558,0.01375401671975851,0.02238449826836586,0.00921062845736742,-0.034287262707948685,-0.04466470330953598,0.012372096069157124,0.015657415613532066,-0.009471368044614792,-0.0029105062130838633,-0.018264811486005783,-0.004830202087759972,-0.02359693869948387,0.003614503424614668,0.00557330995798111,-0.013832238502800465,0.004210945218801498,0.005658050533384085,0.0009492552489973605,-0.010527363047003746,-0.03598207235336304,-0.0010478474432602525,-0.002965913387015462,0.005658050533384085,0.02003784105181694,0.01817355304956436,-0.008767371065914631,0.01053388137370348,-0.005335384979844093,0.013871349394321442,-0.000724367331713438,0.001041329000145197,-0.008760851807892323,-0.013089130632579327,0.012919649481773376,0.012737131677567959,-0.008219817653298378,-0.006290344055742025,0.03924131765961647,-0.01329772174358368,0.010390475392341614,0.011172694154083729,-0.008839073590934277,-0.00872825924307108,-0.022371461614966393,0.004184871446341276,-0.006877008359879255,-0.015266306698322296,0.00654782447963953,-0.0010665880981832743,0.0034776150714606047,0.01084676943719387,0.022201981395483017,-0.012671946547925472,0.008910777047276497,0.03287927061319351,0.007222488056868315,0.023244939744472504,0.008161150850355625,-0.012730613350868225,-0.01114661991596222,-0.018786290660500526,-0.0038524281699210405,-0.001970214070752263,0.006202344316989183,0.017912814393639565,0.02091131918132305,0.0018414737423881888,0.007998188957571983,0.007092118263244629,0.038094062358140945,-0.014575346373021603,-0.05141785740852356,-0.006798786111176014,-0.0205723587423563,-0.01959458366036415,-0.03645140305161476,-0.013597572222352028,-0.03822443261742592,0.008780407719314098,0.00033325786353088915,0.016087636351585388,0.0109445471316576,0.0036568734794855118,0.005977456457912922,-0.0024411750491708517,-0.010696844197809696,0.01911221630871296,0.007372413296252489,0.034182969480752945,-0.011127064004540443,-0.025057079270482063,-0.005051830783486366,0.016348375007510185,-0.004611832555383444,0.011309581808745861,0.0041229454800486565,0.022736497223377228,0.028577065095305443,-0.005850345827639103,0.012632835656404495,-0.017873702570796013,-0.03436548635363579,-0.04208337888121605,0.029385358095169067,0.003907835576683283,-0.0011228100629523396,-0.027977364137768745,-0.01587904430925846,-0.008298039436340332,0.013454166240990162,0.010735955089330673,-0.0018561403267085552,0.008584853261709213,-0.005563532002270222,-0.0027442846912890673,0.01920347474515438,-0.003119098022580147,-0.017078446224331856,-0.032383862882852554,-0.008082929067313671,0.0054559772834181786,-0.025787150487303734,0.003233171533793211,0.018994882702827454,-0.006632564589381218,0.028655286878347397,-0.004510795697569847,-0.002770358696579933,0.011459507048130035,-0.0005630346713587642,-0.010690325871109962,0.014744826592504978,0.008461001329123974,0.02267131209373474,0.007346339523792267,0.0010649585165083408,0.008447964675724506,-0.016504820436239243,0.032227419316768646,-0.007854782044887543,0.001358290552161634,-0.03371363505721092,-0.004699832294136286,-0.002092435723170638,0.022788645699620247,0.012593724764883518,-0.002015843288972974,0.018734144046902657,-0.004514055326581001,0.03063690848648548,-0.021915167570114136,-0.034678373485803604,-0.004145760554820299,-0.018981846049427986,-0.0012523650657385588,-0.005638495087623596,0.021471910178661346,-0.0011716987937688828,0.0038263543974608183,-0.002449322957545519,0.016100673004984856,-0.006567379925400019,-0.010247068479657173,0.005847086664289236,-0.01612674631178379,0.018316959962248802,-0.006877008359879255,0.008148114196956158,0.007496264763176441,-0.03152342513203621,0.0384330227971077,0.003979539033025503,-0.008519668132066727,-0.014705715700984001,-0.0016703633591532707,-0.0019816213753074408,-0.0012784390710294247,-0.010566473938524723,0.012958760373294353,0.03152342513203621,-0.009477886371314526,-0.04456040635704994,-0.02092435583472252,0.032331716269254684,-0.01133565604686737,0.013532388024032116,0.013336832635104656,0.016452671959996223,0.02570892870426178,-0.011537729762494564,-0.0022276942618191242,0.000284980284050107,-0.02458774857223034,-0.010696844197809696,-0.00967344082891941,0.01993354596197605,0.023779455572366714,-0.021823909133672714,-0.023766418918967247,-0.0031451720278710127,-0.003624281147494912,0.043230634182691574,-0.0015155491419136524,0.04171834513545036,0.001864288467913866,0.05376451462507248,-0.004386944696307182,0.03650354966521263,-0.0003338689566589892,-0.03040224313735962,-0.0006962563493289053,-0.015435786917805672,0.002428137930110097,0.011511655524373055,0.004253315273672342,0.019020957872271538,0.0035427999682724476,-0.01647874526679516,-0.0312887579202652,-0.014458013698458672,-0.024887599050998688,-0.013082611374557018,-0.018747180700302124,0.015096825547516346,0.032175272703170776,0.006189307197928429,-0.004149019718170166,-0.012215652503073215,0.007906929589807987,0.016283191740512848,-0.03676429018378258,0.008043818175792694,0.010025439783930779,0.0159833412617445,0.012828391045331955,-0.001454438315704465,0.012117874808609486,-0.011863653548061848,0.03147127479314804,0.015396676026284695,0.00791996717453003,0.004699832294136286,-0.009803811088204384,-0.0016752522205933928,-0.01464053150266409,0.0011032546171918511,-0.005423384718596935,-0.006759675219655037,0.0030865054577589035,-0.02355782687664032,-0.0004734054091386497,-0.020207323133945465,0.010207957588136196,-0.00012823093857150525,-0.0010486622340977192,0.01194839458912611,0.02423574961721897,0.00786781869828701,0.011889727786183357,-0.01503164041787386,-0.025721965357661247,-0.003627540310844779,-0.0006730342283844948,-0.011531210504472256,0.004126205109059811,0.010742473416030407,-0.0052506448701024055,-0.012482910417020321,-0.0024916932452470064,-0.012313430197536945,-0.0008058484527282417,-0.02649114839732647,0.014823049306869507,-0.014327643439173698,0.0020631025545299053,-0.010924991220235825,0.02888995222747326,-0.034965187311172485,0.0060817524790763855,0.005407088436186314,0.0011912542395293713,-0.013727942481637001,0.006463083904236555,0.017912814393639565,-0.005804716609418392,0.013375943526625633,0.0037122806534171104,0.003225023625418544,-0.014523197896778584,-0.010807658545672894,-0.0026236926205456257,-0.037598658353090286,-0.010866324417293072,-0.004592277109622955,-0.010827213525772095,-0.011074916459619999,-0.003937168512493372,0.0018414737423881888,-0.00284043257124722,0.018160516396164894,0.2244446873664856,-0.004338055849075317,-0.009217146784067154,0.03201882913708687,0.014927344396710396,0.017026299610733986,0.008858629502356052,0.008702185936272144,0.014875196851789951,0.022984199225902557,-0.030715130269527435,0.011413877829909325,-0.011231360025703907,0.0019245845032855868,-0.008369742892682552,-0.013558461330831051,-0.019829250872135162,-0.03293141722679138,-0.04372603818774223,-0.027012627571821213,0.003549318527802825,-0.0012042912421748042,-0.018290886655449867,-0.004279389511793852,0.015292380005121231,0.014875196851789951,-0.007039970252662897,-0.020989540964365005,0.027690550312399864,0.02761232852935791,0.0012898464919999242,-0.024509526789188385,0.007600560784339905,-0.004100130870938301,-0.014653568156063557,-0.005589606240391731,-0.01578778587281704,-0.025187449529767036,-0.0036438365932554007,0.009008554741740227,-0.006270788609981537,-0.003588429419323802,0.016348375007510185,-0.01278276089578867,-0.004386944696307182,0.008819518610835075,0.008975962176918983,0.019073104485869408,-0.008878185413777828,0.018264811486005783,-0.012033134698867798,-0.00619582599028945,0.016087636351585388,0.045081883668899536,-0.0114334337413311,-0.0028078400064259768,0.016152821481227875,-0.0070790816098451614,-0.02967217192053795,0.014940381981432438,0.019959619268774986,0.03908487409353256,-0.021576205268502235,0.003591688582673669,0.0017991035711020231,0.016687337309122086,-0.031497348099946976,-0.0014055497013032436,0.010507808066904545,-0.011589877307415009,0.007365894969552755,-0.0036568734794855118,-0.02766447700560093,0.002648137044161558,-0.0053712367080152035,-0.02727336622774601,0.02844669483602047,0.0280555859208107,-0.002059843158349395,0.022462720051407814,-0.015396676026284695,-0.00175021484028548,-0.012143949046730995,0.017274001613259315,-0.025787150487303734,-0.0248224139213562,0.014092978090047836,-0.0024444342125207186,-0.003114209044724703,-0.008402335457503796,0.0060752336867153645,-0.02946357987821102,0.005873160436749458,0.012332985177636147,0.016152821481227875,0.023440495133399963,-0.02677796222269535,0.019764065742492676,-0.010553437285125256,0.005397310480475426,-0.030141502618789673,-0.03433941304683685,0.021250281482934952,-0.02810773439705372,-0.009692996740341187,-0.02316671796143055,0.009354034438729286,0.015748674049973488,0.014092978090047836,-0.003692725207656622,-0.006071974523365498,-0.017678147181868553,0.011648544110357761,0.012548095546662807,0.01715666800737381,0.01920347474515438,0.008975962176918983,-0.010273141786456108,-0.002178805647417903,-0.027846993878483772,-0.03134090453386307,-0.030949795618653297,0.0030571722891181707,0.009719070047140121,-0.016948077827692032,0.005006201099604368,-0.007724412251263857,0.015005567111074924,-0.007131229154765606,-0.016113709658384323,0.018264811486005783,0.0017404371174052358,-0.0005227015353739262,-0.012678464874625206,0.0020076953805983067,0.014692679047584534,0.01063165906816721,-0.013988682068884373,-0.012235207483172417,-0.006837897468358278,0.005234348587691784,0.0029219137504696846,-0.016674300655722618,-0.008187225088477135,0.0024786563590168953,-0.04521225392818451,0.005628717131912708,0.00019402695761527866,0.005899234674870968,7.363857730524614e-05,-0.008930332958698273,-0.016987187787890434,-0.004527091979980469,0.010625140741467476,0.005162645131349564,-0.047871798276901245,-0.018434293568134308,-0.032383862882852554,-0.014275495894253254,0.04315241053700447,-0.01969888061285019,0.007750486023724079,0.016113709658384323,6.951359682716429e-05,-0.02184998244047165,-0.005527680739760399,-0.1651003509759903,0.02165442705154419,0.005504865664988756,-0.019333845004439354,0.008369742892682552,-0.00133466103579849,0.014810011722147465,-0.0008274409919977188,0.0036470957566052675,-0.007111673709005117,0.0032902085222303867,0.011250915937125683,-0.031210536137223244,-0.021589241921901703,0.007509301882237196,-0.00026888775755651295,-0.014079940505325794,-2.4332941848115297e-06,-0.01119224913418293,0.007574486546218395,-0.0026188038755208254,0.015292380005121231,0.022371461614966393,0.012593724764883518,0.013636683113873005,0.016987187787890434,-0.003940428141504526,0.027742698788642883,-0.011576840654015541,0.00325598637573421,-0.011322619393467903,-0.03314000740647316,0.017026299610733986,0.009764700196683407,0.026034854352474213,0.004162056837230921,0.0009565885993652046,0.0018170294351875782,-0.0005198496510274708,-0.003933909349143505,0.019620658829808235,0.027846993878483772,0.01548793539404869,-0.007300710305571556,-0.0042467969469726086,0.033296454697847366,0.01877325400710106,-0.01226780004799366,0.0039045761805027723,-0.00477805407717824,-0.005599383730441332,-0.027403736487030983,0.04184871166944504,-0.0074506355449557304,0.0038263543974608183,0.008741296827793121,-0.012737131677567959,0.0248224139213562,0.008350186981260777,-0.01657000370323658,-0.005553754512220621,-0.023675160482525826,0.009158479981124401,-0.019568510353565216,-0.023101532831788063,-0.030897649005055428,-0.039945315569639206,0.0041685751639306545,-0.00957566313445568,0.0028730249032378197,-0.01187669113278389,-0.020793987438082695,0.016869856044650078,-0.030376167967915535,0.02888995222747326,0.0017534741200506687,-0.03632103279232979,0.028212029486894608,0.013402017764747143,0.012522021308541298,0.015970302745699883,0.04784572497010231,0.006049159914255142,0.016309265047311783,0.007209451403468847,0.009327961131930351,-0.008936851285398006,-0.002477026544511318,-0.014158163219690323,-0.015579193830490112,0.0021478428971022367,-0.019920509308576584,-0.0039013170171529055,-0.009745144285261631,-0.014405865222215652,0.024639897048473358,0.006498935632407665,0.030819425359368324,0.016309265047311783,-0.01444497611373663,-0.01299787126481533,-0.010755510069429874,-0.015096825547516346,0.02263220213353634,0.020050879567861557,0.014119052328169346,0.015722600743174553,0.007144266273826361,0.0029512469191104174,-0.011074916459619999,0.009966772980988026,-0.0064467876218259335,0.010540400631725788,0.011407359503209591,-0.00011865690612467006,0.002752432832494378,0.020259469747543335,-0.012287355959415436,0.0009500700980424881,-0.0012637724867090583,0.05222615227103233,0.0004167760198470205,-0.030871573835611343,-0.02268434874713421,0.006759675219655037,-0.005814494099467993,-0.07816974818706512,-0.0018268071580678225,0.005237607751041651,0.030506538227200508,-0.012743650004267693,0.041327234357595444,0.004406500142067671,0.023349234834313393,-0.027377663180232048,0.04500366374850273,-0.00960173737257719,-0.025630706921219826,-0.005511384457349777,-0.02473115548491478,0.020311618223786354,-0.01647874526679516,-0.02053324691951275,-0.026308629661798477,-0.013988682068884373,0.01671341061592102,0.0067857494577765465,-0.003286949126049876,-0.009745144285261631,-0.006368565838783979,-0.04422144591808319,-0.02126331813633442,-0.019959619268774986,0.027064776048064232,0.009764700196683407,0.002232583239674568,0.0004811461258213967,-0.019086143001914024,0.0014601419679820538,-0.02585233561694622,-0.002486804500222206,0.01876021735370159,-0.017221853137016296,-0.010370919480919838,0.01112054567784071,-0.044247519224882126,0.007255080621689558,0.018551625311374664,-0.0006151826237328351,-0.023636048659682274,0.0008987369947135448,-0.03832872956991196,-0.01065773330628872,0.013193425722420216,0.007326784078031778,-0.004266352392733097,-0.020611468702554703,-0.0018789550522342324,-0.021863019093871117,-0.00502249738201499,0.013141278177499771,-0.012378614395856857,0.03822443261742592,-0.007385450415313244,-0.0016736226389184594,-0.007202932611107826,-0.006606490816920996,-0.006599972490221262,-0.013949571177363396,0.02668670378625393,0.0052506448701024055,-0.03191453218460083,-0.009855958633124828,-0.02111991122364998,0.005227829795330763,-0.02933320961892605,-0.015813859179615974,0.010129734873771667,-0.033113934099674225,0.003198949620127678,0.012130912393331528,0.006626046262681484,0.0005447014118544757,-0.000984292128123343,0.02370123378932476,-0.0261391494423151,-0.012319948524236679,-0.021054726094007492,-0.01847340352833271,-0.01478393841534853,0.026073964312672615,0.018825402483344078,0.01866895891726017,-0.010983658023178577,-0.0016377709107473493,-0.023779455572366714,0.01975102908909321,0.02815988101065159,0.011798469349741936,0.014601420611143112,-0.009288850240409374,-0.0011179212015122175,-0.012482910417020321,-0.007737448904663324,0.022371461614966393,0.02282775565981865,-0.011909283697605133,-0.005478791892528534,-0.0751451626420021,0.004823683295398951,0.02131546661257744,-0.010025439783930779,0.010031958110630512,-0.034182969480752945,-0.0036959846038371325,-0.012724095024168491,0.025057079270482063,-0.007300710305571556,-0.031549498438835144,0.0192556232213974,-0.010344845242798328,0.0028730249032378197,-0.019242586567997932,-0.01559223048388958,0.00758752366527915,-0.00280458084307611,0.018681995570659637,0.004210945218801498,0.02096346765756607,0.002835543593391776,0.002139694755896926,0.0280555859208107,0.006890045013278723,-0.0032266532070934772,-0.00779611524194479,0.02590448409318924,-0.009979809634387493,-0.016596078872680664,0.025721965357661247,-0.029489653185009956,-0.009543071500957012,0.014914307743310928,0.019724953919649124,-0.023127606138586998,-0.023349234834313393,0.018838439136743546,0.010566473938524723,-0.006714046001434326,-0.02012910135090351,-0.017730295658111572,0.03592992201447487,-0.030324021354317665,-0.006156715098768473,-0.011961431242525578,-0.024861525744199753,0.009471368044614792,0.021589241921901703,-0.02076791226863861,0.01881236582994461,-0.0036470957566052675,-0.028029512614011765,-0.014810011722147465,-0.01302394550293684,-0.012991352938115597,0.003627540310844779,0.021954277530312538,-0.0036862066481262445,-0.012717576697468758,0.03074120357632637,0.01671341061592102,0.013102167285978794,-0.0014055497013032436,0.00045996104017831385,-0.01715666800737381,-0.018851475790143013,-0.00034690595930442214,0.008441446349024773,-0.025278707966208458,-0.010781584307551384,0.0015880673890933394,0.01514897309243679,0.03645140305161476,0.003461318789049983,-0.007672264240682125,-0.014510161243379116,-0.002375989919528365,-0.016439635306596756,0.005055089946836233,0.025539448484778404,0.0074506355449557304,-0.021915167570114136,0.03175808861851692,0.0170002244412899,0.03793761879205704,-0.027012627571821213,-0.017873702570796013,0.0034939113538712263,0.008734778501093388,-0.0069291559047997,-0.005087682511657476,0.018486440181732178,-0.0026367297396063805,0.01285446435213089,0.02800343744456768,-0.02101561613380909,0.009158479981124401,-0.0007418858003802598,0.004344574175775051,-0.0028713953215628862,-0.013845275156199932,-0.028707435354590416,-0.00852618645876646,0.0076070791110396385,0.005159385967999697,-0.008741296827793121,-0.0029545060824602842,-0.019659768790006638,0.012261281721293926,0.009367072023451328,-0.0056156800128519535,-0.0074897464364767075,0.0257610771805048,-0.004765016958117485,0.010853287763893604,-0.012078763917088509,-0.02238449826836586,-0.0047845724038779736,-0.010807658545672894,0.02085917256772518,-0.00658367620781064,0.04197908192873001,-8.484223508276045e-05,0.01808229461312294,0.027925215661525726,0.002375989919528365,-0.016869856044650078,0.0019278437830507755,-0.006127381697297096,-0.003298356430605054,-0.014353717677295208,-0.022006426006555557,0.0035427999682724476,0.029307136312127113,-0.016087636351585388,-0.004279389511793852,0.05616331845521927,-0.02400108426809311,0.06210818514227867,0.0059937527403235435,-0.01173328422009945,0.0053223478607833385,-0.005935086403042078,0.019320808351039886,-0.002861617598682642,-0.006961748469620943,-0.01063165906816721,-0.008180706761777401,-0.002651396207511425,-0.011818024329841137,0.009908106178045273,-0.0004110723384656012,0.019920509308576584,-0.005002941936254501,-0.003303245408460498,0.001389253418892622,0.014392828568816185,-0.014862160198390484,0.012652391567826271,-0.009217146784067154,0.019633695483207703,-0.008115521632134914,-0.0043836855329573154,-0.01520112156867981,0.011831061914563179,-0.012352541089057922,-0.021641390398144722,-0.033348601311445236,0.006065456196665764,-0.03259245678782463,-0.002398804761469364,-0.014418902806937695,0.01939903013408184,-0.0234665684401989,-0.009679959155619144,-0.006714046001434326,0.001711103948764503,0.016348375007510185,-0.005882938392460346,0.008669593371450901,-0.014314606785774231,-0.02380552887916565,0.0397888720035553,0.00478783156722784,0.003950205631554127,-0.008298039436340332,-0.020063916221261024] \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/images/search-conceptual-dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/images/search-conceptual-dark.png new file mode 100644 index 000000000..0145b4ea7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/images/search-conceptual-dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/index.mdx new file mode 100644 index 000000000..a0231a8c2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/102_queries_1/index.mdx @@ -0,0 +1,48 @@ +--- +title: P3_102 クエリ 1 (Python) +description: 基本的な検索とフィルター手法で Weaviate へのクエリを開始します。 +sidebar_position: 102 +--- + +import ZeroToMvpDeprecationNote from '/docs/academy/py/zero_to_mvp/_snippets/deprecation.md'; + + + +## ユニット概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +このユニットでは、 Weaviate から関連オブジェクトや集約情報を効率的に取得する方法を学びます。 + +すでに ベクトル検索 の例をいくつか見てきました。本セクションでは、`nearVector`、`nearObject`、`nearText` といった Weaviate で利用可能なさまざまな ベクトル検索 メソッドを詳しく見ていきます。 + +ベクトル検索 メソッドに加え、検索オペレーターと組み合わせて使用できるフィルターも紹介します。たとえば、特定の条件を除外してデータオブジェクトを検索する方法を学びます。 + +これらの機能を確認しながら、同時に Weaviate の内部動作についても理解を深めていきます。 + +このユニットを修了すると、目的の結果を得るために Weaviate へ効果的にクエリを実行する方法と、その背後にあるメカニズムを十分に理解できます。 + +### 前提条件 + +- (**Required**) `weaviate-client` がインストールされた Python (3) 環境 +- (**Required**) [101A Weaviate Academy Preparation](../setup.mdx) を完了 +- (*Recommended*) [Hello, Weaviate](../101_hello_weaviate/index.mdx) を完了 + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/05_preparation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/05_preparation.mdx new file mode 100644 index 000000000..a6b5f2a12 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/05_preparation.mdx @@ -0,0 +1,108 @@ +--- +title: 準備 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/05_create_instance.py'; + +## Weaviate インスタンスの作成 + +このユニットでは、独自の Weaviate インスタンスが必要です。 + +まだお持ちでない場合は、[Weaviate Cloud (WCD)](https://console.weaviate.cloud/) にセットアップすることをおすすめします。**無料の Sandbox インスタンスで十分です。** + +[このページ](../101_hello_weaviate/40_set_up.mdx#--get-started-with-wcd) の「Get Started with WCD」セクションに従って設定し、戻ってきてください。 + +## Weaviate インスタンスへのアクセス + +以下の例に従って、Weaviate インスタンスにアクセスできることを確認しましょう。 + +:::tip Weaviate インスタンスのアドレスは? +Weaviate インスタンスのアドレスを把握しておきましょう。次のような形式です: +``` +https://your-instance-name.weaviate.network +``` +WCD ダッシュボードで確認できます。 +::: + +アクセス方法は、認証が有効か無効かによって異なります。わからない場合は WCD ダッシュボードで「Authentication」の表示を確認してください。 + +### API キー認証あり (推奨) + +認証が有効な場合は、以下のようにクライアントを初期化します。 + + + + + + + +### 認証なし + +インスタンスで認証が無効になっている場合、認証パラメーターは不要です。 + + + + + + + +## アクセスの確認 + +クライアントを初期化したら、次のコードを実行して Weaviate インスタンスへ書き込みが可能か確認します。 + + + + + + + +画面に `"59340403-4bcd-479f-ae9c-de5da039ac0e"` のような長い英数字の文字列が表示されれば成功です。 + +表示されたら、Weaviate インスタンスへアクセスでき、書き込み権限があることが確認できました。これで次に進む準備が整いました。 + +ただし、先に進む前にもうひとつだけ、先ほど作成したテストデータをクリーンアップしておきましょう。 + + + + + + + +次のセクションでお会いしましょう。 + +## 復習 + +### 重要なポイント + +- このユニットでは、WCD などで Weaviate インスタンスを作成する必要があります。 +- Weaviate インスタンスへは、設定に応じて API キー認証あり、または認証なしでアクセスします。 +- 提供されたコードスニペットを実行し、Weaviate インスタンスへアクセスできることを確認します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/10_data_structure.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/10_data_structure.mdx new file mode 100644 index 000000000..564a64be3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/10_data_structure.mdx @@ -0,0 +1,310 @@ +--- +title: Weaviate におけるデータ構造 +description: データを効率的に整理・検索するための Weaviate のデータ構造を確立します。 +--- + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +ここまでで、 Weaviate が実現する強力なクエリの一部をご覧いただきました。では、 Weaviate は実際にどのようにデータを保存し、これらのクエリをサポートしているのでしょうか? + +このセクションでは、 Weaviate が高速にクエリを実行できるようにする主要コンポーネントを見ていきます。特に、 Weaviate のデータ構造の中核であるインデックスと、データの設計図となるスキーマについて説明します。 + +## インデックス + +インデックスとは、データを効率的に検索できるようにするデータ構造です。 Weaviate には、転置インデックスとベクトルインデックスという 2 つの主要なインデックスがあります。 + +**転置インデックス** は、すでに馴染みのあるタイプのインデックスかもしれません。例えば、ある用語をすばやく検索し、その用語を含むオブジェクトを見つける参照テーブルのようなものだと考えてください。 + +**ベクトルインデックス** は、類似度に基づいてベクトルを効率的に検索できるインデックスです。これにより、 Weaviate はベクトル検索を高速に実行できます。もう少し詳しく見ていきましょう。 + +### 転置インデックス + +転置インデックスは、テキストを構成要素となる用語に分解し、ハッシュテーブルのようなデータ構造に保存します。たとえば、「Conference (Chicago, IL)」というテキストを含むデータオブジェクトを考えてみましょう。 + +ユーザーは「conference」「Chicago」「IL」など、含まれる任意の用語でこのオブジェクトを検索したいかもしれません。転置インデックスを使用すると、 Weaviate はその用語を含むオブジェクトの ID をすばやく取得できます。 + +これは、オブジェクト ID を「トークン」にマッピングすることで実現します。トークンとは、テキストから抽出された用語のことです。デフォルトでは、 Weaviate は `word` トークナイゼーションを使用し、英数字のみを保持して小文字に変換し、空白で区切ってトークンに分割します。 + +したがって、入力テキスト `Conference (Chicago, IL)` は 3 つのトークン `conference`、`chicago`、`il` でインデックス化されます。 + +利用可能なトークナイゼーション方法については後ほど詳しく説明します。 + +### ベクトルインデックス + +Weaviate の各オブジェクトにはベクトルを関連付けることができます。これらのベクトルが、前述の類似度検索を可能にします。しかし前述のとおり、総当たりによる類似度検索は計算コストが高く、データセットのサイズに線形に比例して増加します。 + +この問題を解決するために、 Weaviate は Approximate Nearest Neighbor (ANN) アルゴリズムを利用したベクトルインデックスを使用します。 ANN アルゴリズムにより、各ベクトルインデックスはベクトルの集合を組織化し、クエリに類似したベクトルを超高速で取得できます。 Weaviate では現在、 HNSW ベースの ANN インデックスを採用しています。 + +import HNSWLayersImg from '/docs/weaviate/concepts/img/hnsw-layers.svg'; + + + +各ベクトルの集合は「ベクトル空間」に存在すると言われます。これは、複数次元の「空間」にベクトルが配置されていることを示しています。 + +## クラス + +### `class` とは? + +Weaviate におけるクラスは、同じタイプのオブジェクトの集合です。 Weaviate の各オブジェクトは必ず 1 つのクラスに属し、複数のクラスに属することはできません。 + +たとえば、クイズ番組 *Jeopardy!* の問題を Weaviate に保存するとします。各オブジェクトが 1 問を表し、解答、ラウンド、ポイント数、放送日などの属性を持たせると良い構造になります。 + +このデータを表現するには、`JeopardyQuestion` というクラスを作成し、そのクラス内に各問題をオブジェクトとして格納するのが適切でしょう。 + +:::note クラス名は慣例的に単数形 +これはクラスが個々のオブジェクトを指すためです。例: `JeopardyQuestion` オブジェクト。 +::: + +### クラスには何が含まれるか? + +先ほど述べたように、各 Jeopardy! の問題には、問題文、解答、ラウンド、ポイント数など、複数の関連するが異なる属性があります。これらは Weaviate の `class` オブジェクト内で `properties` として表現されます。たとえば、`question` プロパティ、`answer` プロパティなどです。 + +### オブジェクトあたりのベクトル数 + +各オブジェクトは 1 つのベクトルで表され、各クラスには 1 つのベクトルインデックスがあります。つまり、そのクラス内のすべてのオブジェクトは同じベクトルインデックスに関連付けられます。 + +言い換えると、クラス内のすべてのオブジェクトは同じベクトル空間に保存されます。これは Weaviate でスキーマを設計する際に重要なポイントです。ベクトル検索は単一のベクトル空間内でしか実行できません。ベクトルの長さが異なる場合や、同じ長さでも意味が異なる場合は比較できないためです。 + +以前の [色の例え](../101_hello_weaviate/15_overview_vectors.mdx#-how-do-numbers-represent-meaning) を思い出してください。 RGB 値と CMYK 値を比較することはできませんよね?テキストを表すベクトル埋め込みについても同じことが言えます。 + +したがって、 Weaviate ではベクトル検索は 1 度に 1 つのクラスのみ対象にできます。つまり、一緒に検索したいオブジェクトは同じクラスに入れるようスキーマを設計する必要があります。 + +## スキーマ + +Weaviate における `schema` は、データ構造を定義する設計図です。これは、同じタイプのオブジェクトの集合である各 `class` について定義されます。 + +以下にスキーマ構造の例を示します。 + +
+ スキーマ例 + +```json +{ + "classes": [ + { + "class": "Article", + "invertedIndexConfig": { + "bm25": { + "b": 0.75, + "k1": 1.2 + }, + "cleanupIntervalSeconds": 60, + "stopwords": { + "additions": null, + "preset": "en", + "removals": null + } + }, + "moduleConfig": { + "text2vec-openai": { + "model": "ada", + "modelVersion": "002", + "type": "text", + "vectorizeClassName": true + } + }, + "properties": [ + { + "dataType": [ + "text" + ], + "moduleConfig": { + "text2vec-openai": { + "skip": false, + "vectorizePropertyName": false + } + }, + "name": "title", + "tokenization": "word" + }, + { + "dataType": [ + "text" + ], + "moduleConfig": { + "text2vec-openai": { + "skip": false, + "vectorizePropertyName": false + } + }, + "name": "body", + "tokenization": "word" + } + ], + "replicationConfig": { + "factor": 1 + }, + "shardingConfig": { + "virtualPerPhysical": 128, + "desiredCount": 1, + "actualCount": 1, + "desiredVirtualCount": 128, + "actualVirtualCount": 128, + "key": "_id", + "strategy": "hash", + "function": "murmur3" + }, + "vectorIndexConfig": { + "skip": false, + "cleanupIntervalSeconds": 300, + "maxConnections": 32, + "efConstruction": 128, + "ef": -1, + "dynamicEfMin": 100, + "dynamicEfMax": 500, + "dynamicEfFactor": 8, + "vectorCacheMaxObjects": 1000000000000, + "flatSearchCutoff": 40000, + "distance": "cosine", + "pq": { + "enabled": false, + "segments": 0, + "centroids": 256, + "encoder": { + "type": "kmeans", + "distribution": "log-normal" + } + } + }, + "vectorIndexType": "hnsw", + "vectorizer": "text2vec-openai" + } + ] +} +``` + +
+ +情報量が多く、少し圧倒されるかもしれません。順を追って見ていきましょう。 + +まず、オブジェクトの最上位キーは `classes` で、クラスのリストが含まれています。この例では `Article` という 1 つのクラスだけがあります。 + +スキーマは各クラスについて次の内容を指定します。 +- 名前 (`class`) などのメタデータ +- データ `properties` +- `vectorizer` +- モジュール設定 (`moduleConfig`) +- インデックス設定(転置 `invertedIndexConfig` とベクトル `vectorIndexConfig`) +- など + +:::info 自動スキーマ +スキーマ定義に必要な情報が不足している場合、 Weaviate はデフォルト値とインポートされたデータに基づいて自動的に補完します。 +::: + +## 復習 + +### 復習問題 + + + + + + + + + +### 重要ポイント + +- Weaviate はデータを転置インデックスとベクトルインデックスの 2 つで管理します。 +- Weaviate のクラスは同じタイプのオブジェクトの集合を表し、各オブジェクトは必ず 1 つのクラスに属します。 +- スキーマは Weaviate のデータ構造を定義する設計図です。 +- ベクトル検索は単一のベクトル空間内でのみ実行できます。 + - そのため、一緒に検索したいオブジェクトは同じクラスに格納する必要があります。 +- スキーマ定義に必要な情報が不足している場合、 Weaviate がデフォルト値とインポートデータを基に自動補完します。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const invertedIndex = [ +{ +questionText: 'Weaviate における 転置インデックス の機能は何ですか?', +answerOptions: [ +{ +answerText: 'ベクトル を類似度に基づいて効率的に検索できます。', +isCorrect: false, +feedback: 'それは ベクトル インデックス の機能です。', +}, +{ +answerText: 'テキスト を構成語に分解して保存し、迅速に検索できるようにします。', +isCorrect: true, +feedback: 'これにより、その語を含むオブジェクトを素早く取得できます。', +}, +{ +answerText: 'データの設計図として機能します。', +isCorrect: false, +feedback: 'それは スキーマ の機能です。', +}, +] +}]; +export const vectorIndex = [ +{ +questionText: 'Weaviate の ベクトル インデックス は何を可能にしますか?', +answerOptions: [ +{ +answerText: '参照テーブルに基づいてデータを効率的に取得できます。', +isCorrect: false, +feedback: 'それは 転置インデックス の機能であり、 ベクトル インデックス の機能ではありません。', +}, +{ +answerText: '各オブジェクトに ベクトル を関連付けることで類似検索を可能にします。', +isCorrect: true, +feedback: '正解です! ベクトル インデックス は Approximate Nearest Neighbor (ANN) アルゴリズムを使用し、高速な類似検索を実現します。', +}, +{ +answerText: 'Weaviate のデータ構造を定義します。', +isCorrect: false, +feedback: 'それは スキーマ の機能であり、 ベクトル インデックス の機能ではありません。', +}, +] +}]; +export const classDefinition = [ +{ +questionText: 'Weaviate における クラス とは何ですか?', +answerOptions: [ +{ +answerText: '効率的なデータ取得に用いられるインデックスの一種です。', +isCorrect: false, +feedback: 'クラス はインデックスの種類ではありません。 Weaviate においては同じタイプのオブジェクトの集合です。', +}, +{ +answerText: '同じタイプのオブジェクトの集合です。', +isCorrect: true, +feedback: '正解です! Weaviate の クラス は同じタイプのオブジェクトの集合です。', +}, +{ +answerText: 'コレクション内の特定のオブジェクトです。', +isCorrect: false, +feedback: 'クラス は特定のオブジェクトではなく、同じタイプのオブジェクトの集合です。', +}, +] +}]; +export const schemaRole = [ +{ +questionText: 'Weaviate における スキーマ の機能は何ですか?', +answerOptions: [ +{ +answerText: 'ベクトル を類似度に基づいて効率的に取得できます。', +isCorrect: false, +feedback: 'それは ベクトル インデックス の機能であり、 スキーマ の機能ではありません。', +}, +{ +answerText: 'テキスト を構成語に分解してデータ構造に保存します。', +isCorrect: false, +feedback: 'それは 転置インデックス の機能であり、 スキーマ の機能ではありません。', +}, +{ +answerText: 'Weaviate のデータ構造を定義する設計図として機能します。', +isCorrect: true, +feedback: 'スキーマ は Weaviate における各 クラス のデータ構造を定義します。', +}, +] +}, +] \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/20_schema.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/20_schema.mdx new file mode 100644 index 000000000..afddbebe3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/20_schema.mdx @@ -0,0 +1,249 @@ +--- +title: スキーマの定義方法 +description: 構造化され最適化された検索機能のために Weaviate スキーマを設計します +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/20_schema.py'; + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +Weaviate における `schema` は、各 `class` のデータ構造を定義する設計図です。`class` とは、同じタイプのオブジェクトを集めたコレクションです。 + +このセクションでは、スキーマの定義方法と、その際に考慮すべき主なポイントについて学びます。 + +## スキーマの定義方法 + +すでに学んだとおり、スキーマ定義には多くの情報が含まれます。このセクションでは、次のプロパティを中心に説明します。 +- 名前(`class`)などのメタデータ +- データ `properties` +- `vectorizer` +- モジュール設定(`moduleConfig`) + +### メタデータ定義 + +各 class と property には、名前と説明を設定できます。 + +クラスの場合は次のとおりです。 +- `class`(必須) +- `description`(任意) + +プロパティの場合は次のとおりです。 +- `name`(必須) +- `description`(任意) + +クラスを定義する際に必須なのは `class` のみで、残りは Weaviate が推測できます。ただし、データ構造を自分や他の利用者が理解しやすくするために、各クラスおよびプロパティに説明を付けることを推奨します。 + +クラスは次の構文で定義できます。 + + + + + + + +### データ型を持つプロパティ + +各 `class` には 1 つ以上のプロパティが含まれ、それぞれにデータ型を指定する必要があります。データ型を指定しない場合、 Weaviate がデータに基づいて自動的に割り当てますが、予測可能な結果を得るためには可能な限りスキーマで明示的に指定することを推奨します。 + +現在、 Weaviate がサポートしているデータ型は次のとおりです。 + +import DataTypes from '/_includes/datatypes.mdx'; + +
+ Weaviate で利用可能なデータ型 + +
+ +ほとんどのデータ型は `text` や `text[]` のように、単一または配列のどちらでも指定できます。 + + + + + + + +:::tip エラーが発生しましたか? +最初に示したクラス作成コマンドを実行済みの状態でこのコマンドを実行すると、`Article` クラスがすでに存在するため、 Weaviate はエラーを返します。このセクションを進めるには、次のコマンドでクラスを削除してください。


+ +**クラスを削除するとそのクラス内のすべてのオブジェクトも削除されるため、クラスの削除は慎重に行ってください。** + + + + + + + +::: + +### ベクトライザーの設定 + +`vectorizer` パラメータは、そのクラスのベクトル埋め込みを生成するために使用する Weaviate モジュールを指定します。 + +テキストオブジェクトの場合は通常、`text2vec-cohere`、`text2vec-huggingface`、`text2vec-openai`、`text2vec-palm` のような `text2vec` モジュールのいずれかを選択します。 + +モジュールはインスタンスの設定で有効化します。以下のコマンドを実行すると、現在のインスタンスで利用可能なモジュールの一覧を確認できます。 + + + + + + + + + +:::info `module` とは? +ここまでで Weaviate の `modules` という言葉を何度か目にしたかと思います。モジュールとは、 Weaviate の機能を拡張・カスタマイズするための任意コンポーネントです。


+ +Weaviate Academy のユニットでは、モジュールがあらかじめ構成された WCD の利用を前提としています。ローカルインスタンスでのモジュール有効化方法は別のユニットで扱いますが、[Docker インストールガイド](/deploy/installation-guides/docker-installation.md) も参照できます。 +::: + +WCD インスタンスには複数のモジュールがプリセットされています。たとえば、以下のレスポンスから `text2vec-openai` モジュールが利用可能であることがわかるため、スキーマで使用できます。 + +
+ JSON レスポンスを表示 + +```json +{ + "generative-openai": { + "documentationHref": "https://beta.openai.com/docs/api-reference/completions", + "name": "Generative Search - OpenAI" + }, + "qna-openai": { + "documentationHref": "https://beta.openai.com/docs/api-reference/completions", + "name": "OpenAI Question & Answering Module" + }, + "ref2vec-centroid": {}, + "text2vec-cohere": { + "documentationHref": "https://docs.cohere.com/docs/embeddings", + "name": "Cohere Module" + }, + "text2vec-huggingface": { + "documentationHref": "https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task", + "name": "Hugging Face Module" + }, + "text2vec-openai": { + "documentationHref": "https://beta.openai.com/docs/guides/embeddings/what-are-embeddings", + "name": "OpenAI Module" + } +} +``` + +
+ + + + + + + + + +:::info ベクトライザーとユーザー提供ベクトル +インポート時に独自のベクトルだけを扱いたい場合は、`vectorizer` を `None` に設定できます。


+ +場合によっては、アップロード時にベクトルを渡しつつベクトライザーを使用することも可能です。この場合、互換性を保つために、使用するベクトライザー(例: `text2vec-cohere`)がベクトル生成に用いたモデルと同じであることを確認してください。 +::: + +### クラス レベル moduleConfig 設定 + +クラス レベルで `moduleConfig` パラメーターを設定すると、モジュールの動作に関するクラス全体の設定を行えます。たとえば、ベクトライザーでは使用するモデル(`model`)やクラス名をベクトル化するかどうか(`vectorizeClassName`)を指定できます。 + + + + + + + + + +### プロパティ レベル moduleConfig 設定 + +プロパティ レベルでも `moduleConfig` パラメーターを設定し、各プロパティごとのモジュール動作を制御できます。たとえば、プロパティ名をベクトル化するか(`vectorizePropertyName`)や、そのプロパティをまったくベクトル化しないか(`skip`)などを指定できます。 + +次の例では、`url` プロパティに対して `skip` パラメーターを `True` に設定しており、オブジェクトのベクトル埋め込みを生成する際に URL テキストをスキップします。 + + + + + + + + + +:::note 他のオプションは? +まだ触れていない設定もあります。たとえばインデックス設定や、レプリケーションに関連するクラスター設定などです。これらについては後のユニットで説明します。 +::: + +## オプションが多い理由 + +Weaviate やデータベースを初めて触る場合、これらのオプションは複雑に感じるかもしれません。しかし、これらの設定はデータの保存方法や、さまざまなクエリに対する応答に直接影響します。 + +次のセクションでは実際にデータを取り込み、これらのオプションがクエリ結果にどのように影響するかを確認します。 + +## 復習 + +### 復習 エクササイズ + +:::note 演習 +Weaviate に追加したいデータセットはありますか? + +ここで学んだ内容を基に、そのデータセットのスキーマを作成してみましょう。 +::: + +### 重要なポイント + +- Weaviate のスキーマは、各クラスのオブジェクトのデータ構造を定義する設計図として機能します。 +- クラスは同じタイプのオブジェクトの集合を表します。 +- スキーマ定義にはメタデータ、データプロパティ、ベクトライザー、モジュール設定が含まれます。 +- クラス内のデータプロパティには、`text` や `number` などの特定のデータ型を割り当てる必要があります。 +- vectorizer パラメーターは、クラスのベクトル埋め込みを生成する際にどの Weaviate モジュールを使用するかを決定します。 +- クラス レベルとプロパティ レベルのモジュール設定により、モジュールの動作をクラス全体または各プロパティごとにカスタマイズできます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/30_import.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/30_import.mdx new file mode 100644 index 000000000..ca1862276 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/30_import.mdx @@ -0,0 +1,188 @@ +--- +title: データのインポート方法 +description: Weaviate におけるデータインポート手法を学び、シームレスなデータ統合を実現します。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/30_import.py'; + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +これまでに、データは Weaviate ではオブジェクトとして表され、それらは `class` に属し、複数の `properties` を持つことを学習しました。前の `schema` セクションでは、この構造のための枠組みを作成する方法を学びました。 + +このセクションでは、 Weaviate へのデータインポート方法を、推奨されるベストプラクティスと重要な考慮事項とともに学びます。このセクションを終えると、スキーマとインポートについて学んだ内容を組み合わせ、実際のデータセットを Weaviate へインポートできるようになります。 + +## インポート : ハイレベルビュー + +### オブジェクト作成 + + Weaviate オブジェクトを作成するには、以下を行います。 + +- ソースデータを読み込む +- 必要なプロパティを含むデータオブジェクトを構築する +- Weaviate の目的のクラスに追加する + +必要に応じて、次も手動で指定できます。 + +- オブジェクト ID +- ベクトル + +:::info Optional properties + +- オブジェクト ID は必須です。そのため、指定しない場合は Weaviate が自動生成します。 +- ベクトルを指定しない場合、クラスにベクトライザーが設定されていれば Weaviate が生成します。 + +これらについては後ほど詳しく説明します。 +::: + +### バッチインポートを使用する + + Weaviate ではインポート速度を最大化するために「バッチインポート」プロセスを提供しています。以下の図はオブジェクト作成プロセスを示しています。 + +import ImportConceptualImg from './images/academy_103_import_process_conceptual.png'; + +Conceptual diagram of the import process + +図では、指定されたデータを基にオブジェクトを作成するリクエストが送信されています。 + +ベクトルが提供されず、かつベクトライザーが指定されている場合、 Weaviate (core) はベクトル埋め込みを取得するためにベクトライザーモジュールへリクエストを送信します。そのモジュールが `text2vec-cohere` のような推論 API ベースのモジュールである場合、さらに該当の推論 API へベクトルを要求する必要があります。 + +このような構成では、ネットワーク遅延が大規模データセットに対して大きな時間を要したり、ボトルネックになる可能性があります。 + +バッチインポートは 1 つのリクエストで複数のオブジェクトを処理することでネットワーク遅延の影響を大幅に低減し、クライアント(例 : Python クライアント)はさらに処理を並列化できます。特別な理由がない限りバッチインポートを使用することを推奨します。データ取り込み速度が大きく向上します。 + +### バッチインポート構文 + +以下に、いくつかのパラメータを含むバッチ構文を示します。 + + + + + + + +ここで各 `data_object` はクラスのプロパティに対応するキーを持つ Python の辞書である点に注意してください。 + +:::tip `data_object` の一部としてベクトルを指定 *しない* +ベクトルは別項目として指定してください。 Weaviate がそれを **オブジェクトのベクトル** と認識し、インデックス化できるようにするためです。ベクトルを指定する正しい構文は [下記](#-example-with-id--vector) を参照してください。 +::: + +### エラーハンドリング + +バッチインポートプロセスは、バッチレベルおよび個別オブジェクトレベルでエラーを処理するよう設定されています。 + +#### バッチレベルのエラー + +バッチレベルのエラーはバッチリクエストの HTTP レスポンスコードで示されます。 +- 200 レスポンスコード : バッチが正常に送信・接続・処理された +- 4xx ステータスコード : リクエストが不正 + +#### オブジェクトレベルのエラー + +バッチには複数のオブジェクトが含まれるため、リクエストが成功しても個々のオブジェクトでエラーが発生する場合があります。 + +そのため、オブジェクトレベルのエラーはバッチ作成リクエストのレスポンス内で返されます。 + +### エラーハンドリング構文 + +インポート中にオブジェクトレベルのエラーが発生した場合、それらは `batch.create_objects()` または `batch.create_references()` へのレスポンス内で確認できます。 + +レスポンスでは各オブジェクトの `result["result"]["errors"]` 値を調べることでエラーの有無を確認できます。 + +便利な方法として、コールバック関数を定義しバッチ初期化時に指定する方法があります。 + + + + + + + +このパターンを使うことで、インポート処理中に発生したオブジェクトレベルのエラーを捕捉して表示できます。 + +## オプションパラメータ +### ID + +Weaviate の各オブジェクトには一意の識別子があります。 この ID は [ UUID ](https://en.wikipedia.org/wiki/Universally_unique_identifier) である必要があり、ユーザーが指定することもできますが、指定しない場合は Weaviate がランダムな UUID を生成します。 + +Weaviate は重複オブジェクトが作成されているかどうかをチェックしません。 その結果、決定論的な UUID を使用すると、誤って重複オブジェクトを作成することを防げる場合があります。 + +### ベクトル + +Weaviate の各オブジェクトは、それを表すベクトル埋め込みを持つことができますが、必須ではありません。 + +- 作成時にベクトルを指定した場合、 Weaviate はそのベクトルをオブジェクトの表現として使用します。 +- ベクトルを指定しなかった場合、 Weaviate は関連クラスにベクトライザー設定が適用されるかどうかを確認します。 + - 適用される場合、 Weaviate はそのベクトライザーモジュールにベクトル埋め込みのリクエストを送信します。 + - 適用されない場合、オブジェクトはベクトル表現を持ちません。 + +:::info クラスのベクトライザーはどのように決まるのですか? +- スキーマでクラスにベクトライザーが設定されている場合、そのベクトライザーが使用されます。 +- 設定されていない場合、 Weaviate はそのインスタンスのデフォルトベクトライザー設定を確認します。 +::: + +:::note ベクトルをアップロードしてベクトライザーを使用する +独自のベクトルをアップロードしつつ、ベクトライザーも指定することが可能です。 例えば、大規模データセットをインポートする際に、 Weaviate でも利用可能なベクトライザーで事前にベクトル化している場合に便利です。 これにより、データセットの更新を Weaviate でベクトル化できるほか、クエリも必要に応じてベクトル化できます。 +::: + +これらのオプションについては別のユニットで詳しく説明します。 + +### id & ベクトルを指定した例 + +オブジェクトの ID とベクトルを手動で指定する場合、構文は以下のとおりです。 + + + + + + + +これらのパラメーターを使うことで、オブジェクトごとに ID とベクトルを手動で指定できます。 + +## 復習 + +### 復習課題 + +:::note 演習 +- バッチインポートプロセスを学習したあと、自分の言葉で説明してみましょう。 + - バッチインポートプロセスとは何か、なぜ使用するのか、そしてデータ取り込み速度をどのように向上させるのかを含めてください。 +- オブジェクト作成時にオプションだったパラメーターを思い出せますか? + - それらのパラメーターを指定したい場合、または指定したくない場合のシナリオを想像できますか? +::: + +### 重要なポイント + +- Weaviate オブジェクトを作成するには、プロパティを持つデータオブジェクトを構築し、目的のクラスに追加します。 +- インポート速度を最大化しネットワーク遅延を最小化するには、バッチインポートを使用します。バッチインポートは 1 リクエストで複数オブジェクトを処理でき、クライアント側で並列化も可能です。 +- インポート中のエラーハンドリングは、バッチ単位または個々のオブジェクト単位で行えます。 +- Weaviate では各オブジェクトに対して ID とベクトルを手動で指定できます。 + - ID を指定しない場合、 Weaviate が生成します。 + - ベクトルを指定しない場合、ベクトライザーが設定されていれば Weaviate が生成します。 + - ベクトライザー設定はスキーマ内で指定できます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/40_example.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/40_example.mdx new file mode 100644 index 000000000..50c1b3a1c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/40_example.mdx @@ -0,0 +1,288 @@ +--- +title: Weaviate インスタンスをデータで満たしましょう! +description: 効率的なデータ設定のための Weaviate スキーマ作成例をご覧ください。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/40_import_example_1.py'; + +## 概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ +ここまで学んだことを実践するときです!このセクションでは次を行います。 + +- 小さなデータセットをダウンロード +- データセットに対応するスキーマを構築 +- それをあなたの WCD インスタンスへインポート + +### 使用データセット + +今回は人気クイズ番組 *Jeopardy!* のデータを使用します。 + +元のデータセットは [Kaggle 上](https://www.kaggle.com/datasets/tunguz/200000-jeopardy-questions) にありますが、ここでは [100 行だけの小さなサブセット](https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/jeopardy_100.json) を利用します。 + +以下はデータの数行をプレビューしたものです。 + +| | 放送日 | ラウンド | 金額 | カテゴリ | 問題文 | 解答 | +|---:|:--------------|:--------------------|-------:|:-------------------|:------------------------------------------------------------------------------------------------------------------|:------------------------------------------| +| 0 | 2006-11-08 | Double Jeopardy! | 800 | AMERICAN HISTORY | Abraham Lincoln died across the street from this theatre on April 15, 1865 | Ford's Theatre (the Ford Theatre accepted)| +| 1 | 2005-11-18 | Jeopardy! | 200 | RHYME TIME | Any pigment on the wall so faded you can barely see it | faint paint | +| 2 | 1987-06-23 | Double Jeopardy! | 600 | AMERICAN HISTORY | After the original 13, this was the 1st state admitted to the union | Vermont | + +今回はシンプルに、`Round`、`Value`、`Question`、`Answer` 列のみを Weaviate に投入します。 + +:::note 演習 +次のステップは何だったか思い出せますか? +::: + +## スキーマの構築 + +次のステップはスキーマを作成し、データを Weaviate にどう表現するかを決定することです。 + +### クラス名とプロパティの追加 + +まずは名前が必要です。名前は各行(単数形)を表すので、`JeopardyQuestion` としました。次にプロパティと型を定義します。 + +先ほど述べたように、`Round`、`Value`、`Question`、`Answer` 列を Weaviate に投入します。Weaviate の `properties` 用の名前が必要ですが、GraphQL の慣例に従いクラスは大文字で、プロパティは小文字にするので、名前は `round`、`value`、`question`、`answer` になります。 + +次にデータ型を選択します。`round`、`question`、`answer` はすべてテキストなので `text` を選びます。`value` は数値ですが、*Jeopardy!* の金額は常に整数なので `int` を使用します。 + + + + + + + +### ベクトライザーの設定と構成 + +この例では、推論サービスを使用してオブジェクトベクトルを取得します。そのため、クラスの `vectorizer` を設定する必要があります。今回は `text2vec-openai` を使用し、モジュールの設定もクラスレベルで行います。 + + + + + + + +### プロパティをベクトル化から除外 + +ここでプロパティレベルのモジュール設定に気付いたかもしれません。 + + + + + + + +この設定により `round` プロパティはベクトル化対象から除外されます。では、なぜそうするのでしょうか? + +その理由は、問題が "Jeopardy!" ラウンドか "Double Jeopardy!" ラウンドかは、意味に大きな影響を与えないからです。ベクトライザーはオブジェクトのベクトル表現を作成します。テキストオブジェクトの場合、Weaviate は内部規則と設定に従ってテキストを結合し、その結合テキストをベクトル化します。 + +したがって `round` プロパティをベクトル化する場合と除外する場合では、例えば次のような違いになります。 + +```json +// If the property is vectorized +answer {answer_text} question {question_text} category {category_text} +``` + +対して: + +```json +// If the property is skipped +answer {answer_text} question {question_text} +``` + +より具体的には、次のような違いです。 + +```json +// If the property is vectorized +answer faint paint question any pigment on the wall so faded you can barely see it category double jeopardy! +``` + +対して: + +```json +// If the property is skipped +answer faint paint question any pigment on the wall so faded you can barely see it +``` + +追加情報はクイズ項目の意味を捉える上でそれほど重要ではありません。主要な情報は問題文と解答、場合によってはカテゴリにあるからです(カテゴリはまだ使用していません)。 + +:::tip ベクトル化をスキップしてもフィルタリングには影響なし +重要な点として、`round` 列をベクトル化から除外しても、`round` の値で結果をフィルタリングする能力には影響しません。たとえば `Double Jeopardy!` の問題だけを検索したい場合でも可能です。 +::: +### クラスの作成 + +これでスキーマにクラスを追加できます。 + + + + + + + +次に、そのクラスのスキーマを取得して、正常に作成されたかどうかを確認できます。 + + + + + + + +
+ スキーマレスポンス全文を表示 + + + +
+ +:::note 取得したスキーマはさらに長い! +ここで多くの詳細を定義しましたが、取得したスキーマはさらに長くなっています。追加されているのは、 ベクトル インデックス、 転置インデックス、シャーディング、トークン化に関する情報です。これらの多くについては後ほど説明します。 +::: + +例のレスポンスに近いスキーマが表示されたら、素晴らしいです。データのインポート準備が整いました。 + +## データのインポート + +ここでは、必要なデータをインポートする方法と、バッチを設定して使用する方法を説明します。 + +### データの読み込み + +データはオンラインで公開されていますので、次のように取得して読み込んでください。 + + + +### バッチ設定とデータのインポート + +続いて、バッチインポートプロセスを設定しましょう。前述のとおり、 Weaviate のバッチインポートプロセスではデータを一括かつ並列で送信できます。 + +Python では、次のようなコンテキストマネージャーを使用することをおすすめします。 + + + +ここで `batch_size` と `num_workers` パラメーターを使用している点に注目してください。`batch_size` は 1 バッチあたりに送信するオブジェクト数を、`num_workers` は並列化に使用するプロセス数を指定します。 + +次のステップはデータオブジェクトを作成し、それらをバッチプロセスに追加することです。対応する列のデータを適切な Weaviate プロパティに渡して、Python の辞書としてオブジェクトを構築し、送信タイミングはクライアントが処理します。 + + + +最後に、正しい数のオブジェクトがインポートされているか確認しましょう。 + + + +`True` が返れば、 Weaviate インスタンスへのデータ投入に成功しています。 + +### 再実行時の挙動 + +先へ進む前に質問です。上記のインポートスクリプトをもう一度実行するとどうなると思いますか? + +
+ 答えは… + +重複したアイテムが作成されてしまいます!


+ +Weaviate は、既に存在するものと同じプロパティを持つアイテムをアップロードしているかどうかをチェックしません。また、インポートスクリプトでは ID を指定していないため、 Weaviate は新しいランダムな ID を割り当て、新しいオブジェクトを作成します。 + +
+ +### オブジェクト UUID の指定 + +インポート時にオブジェクトの識別子として UUID を指定することもできます。たとえば、 Weaviate の Python クライアントには、オブジェクトに基づいて決定論的な UUID を生成する関数があります。次のように、これをインポートスクリプトに追加できます。 + + + +これにより、 UUID がオブジェクトのプロパティに基づいて生成されるオブジェクトが作成されます。したがって、オブジェクトのプロパティが同じであれば、 UUID も同じになります。 + +そのため、上記のスクリプトを複数回実行してもオブジェクト数は増えません。 + +:::tip 望ましい挙動は? +UUID がオブジェクトのプロパティに基づいているため、いずれかのプロパティが変更された場合には新しいオブジェクトが作成されます。そのため、インポートプロセスを設計する際には、どのプロパティが変更される可能性があるか、またその場合に Weaviate にどう動作してほしいかを検討してください。


+ +たとえば、ユニークなプロパティのサブセットを基に UUID を生成してオブジェクトを上書きさせたり、すべてのプロパティを基に UUID を生成して重複のみを防いだりといった設計が考えられます。 +::: + +### 完全なインポートスクリプト + +すべてを組み合わせると、次のインポートスクリプトになります。 + + + +## レビュー + +### 重要なポイント + +次のことを行いました。 +- `Jeopardy!` の問題と回答の小さなデータセットをダウンロードしました。 +- スキーマを構築し、データをインポートしました。 +- `Weaviate` 内のオブジェクト数を確認して、インポートが成功したことを検証しました。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/90_wrap_up.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/90_wrap_up.mdx new file mode 100644 index 000000000..77b1a9f27 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/90_wrap_up.mdx @@ -0,0 +1,25 @@ +--- +title: まとめ +description: スキーマとインポートのまとめ +--- + +## ユニットレビュー + +このユニットでは、データが Weaviate でどのように構造化されているかを学び、最初から最後まで自身の Weaviate インスタンスにデータを投入する実践を行いました。 + +クラス、プロパティ、データタイプ、ベクトル化設定を含むスキーマを定義・作成する方法を体験しました。また、このスキーマに従ってデータをインポートし、バッチインポートを使用してできる限り高速に取り込む方法も学びました。 + +これで、 Weaviate のインデックスとスキーマの概要と、それらが効率的で柔軟かつ強力な検索を実現するためにどのようにデータを保存するかについて、広く理解できたはずです。 + +### 学習成果 + +このユニットを終えたことで、次のことができるようになります。 +- スキーマとインデックスが Weaviate でのデータ保存方法にどのように関連しているかを説明できる。 +- クラスとプロパティがデータをどのように表現し、どのように定義するかを理解できる。 +- バッチインポートを使用して Weaviate にデータを投入できる。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/05_create_instance.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/05_create_instance.py new file mode 100644 index 000000000..75fc9ae28 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/05_create_instance.py @@ -0,0 +1,38 @@ +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your API Key for the Weaviate instance. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +client.is_ready() # This should return `True` +# ===== END Instantiate Weaviate client w/ auth config ===== +assert client.is_ready() # This should return `True` + +# ===== Instantiate Weaviate client w/o auth ===== +import weaviate + +client = weaviate.Client( + url="https://anon-endpoint.weaviate.network", # Replace with your Weaviate endpoint + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +client.is_ready() # This should return `True` +# ===== END Instantiate Weaviate client w/o auth ===== +assert client.is_ready() # This should return `True` + +# ===== Confirm that the client can access the instance ===== +response = client.data_object.create({"name": "dummy"}, "TestClass") +print(response) # This should be a UUID, like "59340403-4bcd-479f-ae9c-de5da039ac0e" +# ===== END Confirm that the client can access the instance ===== +assert response.count("-") == 4 # This should be a UUID, like "59340403-4bcd-479f-ae9c-de5da039ac0e" + +# ===== Delete our test object ===== +client.data_object.delete(response, class_name="TestClass") +# ===== END Delete our test object ===== diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/20_schema.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/20_schema.py new file mode 100644 index 000000000..845154b51 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/20_schema.py @@ -0,0 +1,258 @@ +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your API Key for the Weaviate instance. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +# ===== Create a class with metadata ===== +class_obj = { + "class": "Article", +} + +client.schema.create_class(class_obj) +# ===== END Create a class with metadata ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "Article" in classes + +# ===== Delete the class ===== +client.schema.delete_class("Article") +# ===== END Delete the class ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "Article" not in classes + +# ===== Create properties with datatypes ===== +class_obj = { + "class": "Article", + "properties": [ + { + "name": "title", + # highlight-start + "dataType": ["text"], + # highlight-end + }, + { + "name": "body", + # highlight-start + "dataType": ["text"], + # highlight-end + }, + { + "name": "url", + # highlight-start + "dataType": ["text"], + # highlight-end + }, + ], +} + +client.schema.create_class(class_obj) +# ===== END Create properties with datatypes ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +property_names = [c["name"] for c in client.schema.get("Article")["properties"]] +datatypes = [c["dataType"] for c in client.schema.get("Article")["properties"]] +assert "Article" in classes +for p in ["title", "body", "url"]: + assert p in property_names +assert datatypes == [["text"], ["text"], ["text"]] + +# ===== NOT SHOWN - Delete the class ===== +client.schema.delete_class("Article") +# ===== NOT SHOWN - Delete the class ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "Article" not in classes + +# ===== Get module list ===== +module_metadata = client.get_meta() +module_metadata['modules'] +# ===== END Get module list ===== + +assert 'text2vec-openai' in module_metadata['modules'].keys() + +# ===== Create a class with a vectorizer ===== +class_obj = { + "class": "Article", + "properties": [ + { + "name": "title", + "dataType": ["text"], + }, + { + "name": "body", + "dataType": ["text"], + }, + { + "name": "url", + "dataType": ["text"], + }, + ], + # highlight-start + "vectorizer": "text2vec-openai" + # highlight-end +} + +client.schema.create_class(class_obj) +# ===== END Create a class with a vectorizer ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +property_names = [c["name"] for c in client.schema.get("Article")["properties"]] +datatypes = [c["dataType"] for c in client.schema.get("Article")["properties"]] +vectorizer = client.schema.get("Article")["vectorizer"] +assert "Article" in classes +for p in ["title", "body", "url"]: + assert p in property_names +assert datatypes == [["text"], ["text"], ["text"]] +assert vectorizer == "text2vec-openai" + +# ===== NOT SHOWN - Delete the class ===== +client.schema.delete_class("Article") +# ===== NOT SHOWN - Delete the class ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "Article" not in classes + +# ===== Class-level moduleConfig ===== +class_obj = { + "class": "Article", + # highlight-start + "moduleConfig": { + "text2vec-openai": { + "vectorizeClassName": False, + "model": "ada", + "modelVersion": "002", + "type": "text" + } + }, + # highlight-end + "properties": [ + { + "name": "title", + "dataType": ["text"], + }, + { + "name": "body", + "dataType": ["text"], + }, + { + "name": "url", + "dataType": ["text"], + }, + ], + "vectorizer": "text2vec-openai" +} + +client.schema.create_class(class_obj) +# ===== END Class-level moduleConfig ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +property_names = [c["name"] for c in client.schema.get("Article")["properties"]] +datatypes = [c["dataType"] for c in client.schema.get("Article")["properties"]] +vectorizer = client.schema.get("Article")["vectorizer"] +module_config = client.schema.get("Article")["moduleConfig"] +assert "Article" in classes +for p in ["title", "body", "url"]: + assert p in property_names +assert datatypes == [["text"], ["text"], ["text"]] +assert vectorizer == "text2vec-openai" +assert module_config[vectorizer]["vectorizeClassName"] == False +assert module_config[vectorizer]["model"] == "ada" +assert module_config[vectorizer]["modelVersion"] == "002" + +# ===== NOT SHOWN - Delete the class ===== +client.schema.delete_class("Article") +# ===== NOT SHOWN - Delete the class ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "Article" not in classes + +# ===== Property-level moduleConfig ===== +class_obj = { + "class": "Article", + "moduleConfig": { + "text2vec-openai": { + "vectorizeClassName": False, + "model": "ada", + "modelVersion": "002", + "type": "text" + } + }, + "properties": [ + { + "name": "title", + "dataType": ["text"], + }, + { + "name": "body", + "dataType": ["text"], + # highlight-start + "moduleConfig": { + "text2vec-openai": { + "skip": False, + "vectorizePropertyName": True + } + } + # highlight-end + }, + { + "name": "url", + "dataType": ["text"], + # highlight-start + "moduleConfig": { + "text2vec-openai": { + "skip": True, + } + } + # highlight-end + }, + ], + "vectorizer": "text2vec-openai" +} + +client.schema.create_class(class_obj) +# ===== END Property-level moduleConfig ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +property_names = [c["name"] for c in client.schema.get("Article")["properties"]] +datatypes = [c["dataType"] for c in client.schema.get("Article")["properties"]] +vectorizer = client.schema.get("Article")["vectorizer"] +module_config = client.schema.get("Article")["moduleConfig"] +assert "Article" in classes +for p in ["title", "body", "url"]: + assert p in property_names +assert datatypes == [["text"], ["text"], ["text"]] +assert vectorizer == "text2vec-openai" +assert module_config[vectorizer]["vectorizeClassName"] == False +assert module_config[vectorizer]["model"] == "ada" +assert module_config[vectorizer]["modelVersion"] == "002" +properties = client.schema.get("Article")["properties"] +for p in properties: + if p["name"] == "body": + assert p["moduleConfig"]["text2vec-openai"]["skip"] == False + assert p["moduleConfig"]["text2vec-openai"]["vectorizePropertyName"] == True + if p["name"] == "url": + assert p["moduleConfig"]["text2vec-openai"]["skip"] == True + +# ===== NOT SHOWN - Delete the class ===== +client.schema.delete_class("Article") +# ===== NOT SHOWN - Delete the class ===== + +# Test +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "Article" not in classes diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/30_import.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/30_import.py new file mode 100644 index 000000000..d1a0dc602 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/30_import.py @@ -0,0 +1,112 @@ +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your API Key for the Weaviate instance. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +# An example object +data_object = { + "title": "Apollo 8", + "body": "Apollo 8 (December 21–27, 1968) was...", + "url": "https://en.wikipedia.org/wiki/Apollo_8" +} +# END An example object + +batch_size = 10 +num_workers = 1 +n_retries = 3 +data_objects = [data_object] +target_class = "TestClass" + +# Batch import example +# highlight-start +with client.batch( + batch_size=batch_size, # Specify batch size + num_workers=num_workers, # Parallelize the process + dynamic=True, # Enable/Disable dynamic batch size change + timeout_retries=n_retries, # Number of retries if a timeout occurs + connection_error_retries=n_retries, # Number of retries if a connection error occurs +) as batch: +# highlight-end + for data_object in data_objects: + batch.add_data_object( + data_object, + class_name=target_class + ) +# END Batch import example + +results = client.query.get(target_class, list(data_object.keys())).do() +assert len(results["data"]["Get"][target_class]) == 1 +client.schema.delete_class(target_class) + +from weaviate.util import generate_uuid5 +uuid = generate_uuid5(data_object) +object_vector = [1, 2, 3] + +# Example with additional properties +with client.batch( + batch_size=batch_size, # Specify batch size + num_workers=num_workers, # Parallelize the process + dynamic=True, # Enable/Disable dynamic batch size change + timeout_retries=n_retries, # Number of retries if a timeout occurs + connection_error_retries=n_retries, # Number of retries if a connection error occurs +) as batch: + for data_object in data_objects: + batch.add_data_object( + data_object, + class_name=target_class, + # highlight-start + uuid=uuid, + vector=object_vector, + # highlight-end + ) +# END Example with additional properties + +results = client.query.get(target_class, list(data_object.keys())).with_additional(["id", "vector"]).do() +assert len(results["data"]["Get"][target_class]) == 1 +assert results["data"]["Get"][target_class][0]["_additional"]["id"] == uuid +assert results["data"]["Get"][target_class][0]["_additional"]["vector"] == object_vector +client.schema.delete_class(target_class) + +# Example with callback +# highlight-start +def check_batch_result(results: dict): + """ + Check batch results for errors. + + Parameters + ---------- + results : dict + The Weaviate batch creation return value. + """ + + if results is not None: + for result in results: + if "result" in result and "errors" in result["result"]: + if "error" in result["result"]["errors"]: + print(result["result"]) +# highlight-end + +with client.batch( + batch_size=batch_size, # Specify batch size + num_workers=num_workers, # Parallelize the process + dynamic=True, # Enable/Disable dynamic batch size change + timeout_retries=n_retries, # Number of retries if a timeout occurs + connection_error_retries=n_retries, # Number of retries if a connection error occurs + # highlight-start + callback=check_batch_result, + # highlight-end +) as batch: + for data_object in data_objects: + batch.add_data_object( + data_object, + class_name=target_class, + uuid=uuid, + vector=object_vector, + ) +# END Example with callback diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/40_import_example_1.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/40_import_example_1.py new file mode 100644 index 000000000..dd692bf72 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/_snippets/40_import_example_1.py @@ -0,0 +1,341 @@ +# Full code snippet +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate +from weaviate.util import generate_uuid5 +import requests +import json + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your Weaviate instance API key. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +# Define the class +class_obj = { + # Class & property definitions + "class": "JeopardyQuestion", + "properties": [ + { + "name": "round", + "dataType": ["text"], + # Property-level module configuration for `round` + "moduleConfig": { + "text2vec-openai": { + "skip": True, + } + }, + # End of property-level module configuration + }, + { + "name": "value", + "dataType": ["int"], + }, + { + "name": "question", + "dataType": ["text"], + }, + { + "name": "answer", + "dataType": ["text"], + }, + ], + + # Specify a vectorizer + "vectorizer": "text2vec-openai", + + # Module settings + "moduleConfig": { + "text2vec-openai": { + "vectorizeClassName": False, + "model": "ada", + "modelVersion": "002", + "type": "text" + } + }, +} +# End class definition + +client.schema.create_class(class_obj) +# Finished creating the class + +url = 'https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/jeopardy_100.json' +resp = requests.get(url) +data = json.loads(resp.text) + +# Context manager for batch import +with client.batch( + batch_size=200, # Specify batch size + num_workers=2, # Parallelize the process +) as batch: + # Build data objects & add to batch + for i, row in enumerate(data): + question_object = { + "question": row["Question"], + "answer": row["Answer"], + "value": row["Value"], + "round": row["Round"], + } + batch.add_data_object( + question_object, + class_name="JeopardyQuestion", + uuid=generate_uuid5(question_object) + ) + +# END Full code snippet + +# Test data ingestion +def test_class_addition(client_in): + class_schema = client_in.schema.get("JeopardyQuestion") + assert class_schema["class"] == "JeopardyQuestion" + assert class_schema["vectorizer"] == "text2vec-openai" + assert len(class_schema["properties"]) == 4 +test_class_addition(client) +assert client.query.aggregate("JeopardyQuestion").with_meta_count().do()["data"]["Aggregate"]["JeopardyQuestion"][0]["meta"]["count"] == 100 +# Cleanup +client.schema.delete_class("JeopardyQuestion") +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "JeopardyQuestion" not in classes +# END Test data ingestion + +# ============================================================ +# ========== SMALLER CODE SNIPPETS =========================== +# ============================================================ + +client.schema.create_class(class_obj) + +# Retrieve "JeopardyQuestion" class schema +client.schema.get("JeopardyQuestion") +# END Retrieve "JeopardyQuestion" class schema + +''' +// RETRIEVED CLASS SCHEMA +{ + "class": "JeopardyQuestion", + "invertedIndexConfig": { + "bm25": { + "b": 0.75, + "k1": 1.2 + }, + "cleanupIntervalSeconds": 60, + "stopwords": { + "additions": null, + "preset": "en", + "removals": null + } + }, + "moduleConfig": { + "text2vec-openai": { + "model": "ada", + "modelVersion": "002", + "type": "text", + "vectorizeClassName": false + } + }, + "properties": [ + { + "dataType": [ + "text" + ], + "indexFilterable": true, + "indexSearchable": true, + "moduleConfig": { + "text2vec-openai": { + "skip": true, + "vectorizePropertyName": false + } + }, + "name": "round", + "tokenization": "word" + }, + { + "dataType": [ + "int" + ], + "indexFilterable": true, + "indexSearchable": false, + "moduleConfig": { + "text2vec-openai": { + "skip": false, + "vectorizePropertyName": false + } + }, + "name": "value" + }, + { + "dataType": [ + "text" + ], + "indexFilterable": true, + "indexSearchable": true, + "moduleConfig": { + "text2vec-openai": { + "skip": false, + "vectorizePropertyName": false + } + }, + "name": "question", + "tokenization": "word" + }, + { + "dataType": [ + "text" + ], + "indexFilterable": true, + "indexSearchable": true, + "moduleConfig": { + "text2vec-openai": { + "skip": false, + "vectorizePropertyName": false + } + }, + "name": "answer", + "tokenization": "word" + } + ], + "replicationConfig": { + "factor": 1 + }, + "shardingConfig": { + "virtualPerPhysical": 128, + "desiredCount": 1, + "actualCount": 1, + "desiredVirtualCount": 128, + "actualVirtualCount": 128, + "key": "_id", + "strategy": "hash", + "function": "murmur3" + }, + "vectorIndexConfig": { + "skip": false, + "cleanupIntervalSeconds": 300, + "maxConnections": 32, + "efConstruction": 128, + "ef": -1, + "dynamicEfMin": 100, + "dynamicEfMax": 500, + "dynamicEfFactor": 8, + "vectorCacheMaxObjects": 1000000000000, + "flatSearchCutoff": 40000, + "distance": "cosine", + "pq": { + "enabled": false, + "segments": 0, + "centroids": 256, + "encoder": { + "type": "kmeans", + "distribution": "log-normal" + } + } + }, + "vectorIndexType": "hnsw", + "vectorizer": "text2vec-openai" +} +// END RETRIEVED CLASS SCHEMA +''' + +# Load data +import requests +import json +url = 'https://raw.githubusercontent.com/weaviate-tutorials/edu-datasets/main/jeopardy_100.json' +resp = requests.get(url) +data = json.loads(resp.text) +# Finished loading data + +# Import data - simple version +with client.batch( + batch_size=200, # Specify batch size + num_workers=2, # Parallelize the process +) as batch: + # Build data objects & add to batch + for i, row in enumerate(data): + question_object = { + "question": row["Question"], + "answer": row["Answer"], + "value": row["Value"], + "round": row["Round"], + } + batch.add_data_object( + question_object, + class_name="JeopardyQuestion" + ) +# END Import data - simple version + +# Check object count +assert client.query.aggregate("JeopardyQuestion").with_meta_count().do()["data"]["Aggregate"]["JeopardyQuestion"][0]["meta"]["count"] == 100 +# END Check object count + +# Import data again - to demonstrate what happens if duplicated +with client.batch( + batch_size=200, # Specify batch size + num_workers=2, # Parallelize the process +) as batch: + for i, row in enumerate(data): + question_object = { + "question": row["Question"], + "answer": row["Answer"], + "value": row["Value"], + "round": row["Round"], + } + batch.add_data_object( + question_object, + class_name="JeopardyQuestion" + ) +# END Import data again - to demonstrate what happens if duplicated +assert client.query.aggregate("JeopardyQuestion").with_meta_count().do()["data"]["Aggregate"]["JeopardyQuestion"][0]["meta"]["count"] == 200 + +# Cleanup +client.schema.delete_class("JeopardyQuestion") +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "JeopardyQuestion" not in classes + +client.schema.create_class(class_obj) +test_class_addition(client) + + +# Import data with deterministic UUIDs +from weaviate.util import generate_uuid5 + +with client.batch( + batch_size=200, # Specify batch size + num_workers=2, # Parallelize the process +) as batch: + for i, row in enumerate(data): + question_object = { + "question": row["Question"], + "answer": row["Answer"], + "value": row["Value"], + "round": row["Round"], + } + batch.add_data_object( + question_object, + class_name="JeopardyQuestion", + uuid=generate_uuid5(question_object) + ) +# END Import data with deterministic UUIDs + +# Test +assert client.query.aggregate("JeopardyQuestion").with_meta_count().do()["data"]["Aggregate"]["JeopardyQuestion"][0]["meta"]["count"] == 100 +with client.batch( + batch_size=200, # Specify batch size + num_workers=2, # Parallelize the process +) as batch: + for i, row in enumerate(data): + question_object = { + "question": row["Question"], + "answer": row["Answer"], + "value": row["Value"], + "round": row["Round"], + } + batch.add_data_object( + question_object, + class_name="JeopardyQuestion", + uuid=generate_uuid5(question_object) + ) +assert client.query.aggregate("JeopardyQuestion").with_meta_count().do()["data"]["Aggregate"]["JeopardyQuestion"][0]["meta"]["count"] == 100 + +client.schema.delete_class("JeopardyQuestion") +classes = [c["class"] for c in client.schema.get()["classes"]] +assert "JeopardyQuestion" not in classes diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/images/academy_103_import_process_conceptual.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/images/academy_103_import_process_conceptual.png new file mode 100644 index 000000000..e303b7f79 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/images/academy_103_import_process_conceptual.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/images/academy_103_import_process_conceptual_simple.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/images/academy_103_import_process_conceptual_simple.png new file mode 100644 index 000000000..decd7d919 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/images/academy_103_import_process_conceptual_simple.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/index.mdx new file mode 100644 index 000000000..cf9f530ac --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/103_schema_and_imports/index.mdx @@ -0,0 +1,49 @@ +--- +title: P3_103 スキーマとインポート(Python) +description: スキーマを定義し、データを Weaviate にインポートしてデータセットの構造を設定します。 +sidebar_position: 103 +--- + +import ZeroToMvpDeprecationNote from '/docs/academy/py/zero_to_mvp/_snippets/deprecation.md'; + + + +## ユニット概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ + + +前回のユニットでは、 Weaviate の基本概念や機能、既存データに対する基本的なクエリの実行方法を学びました。さまざまなクエリタイプに慣れた今度は、独自の Weaviate インスタンスにデータを投入する方法を学んでいきます。 + +このユニットでは、 Weaviate を用いてデータを効果的に構造化し、望む形で適切な情報を取得できるようにする方法を見ていきます。具体的には、データ用のスキーマを定義し、 Weaviate にデータをインポートする手順を掘り下げます。 + +ユニットを終える頃には、 Weaviate の全体的なデータアーキテクチャがより明確になるでしょう。これにより、自分のニーズと目的に合ったベクトル データベースを構築できる力が身につき始めます。 + +それでは始めましょう。 + +### 事前準備 + +- (**必須**) `weaviate-client` がインストールされた Python(3)環境 +- (**必須**) [101A Weaviate Academy Preparation](../setup.mdx) の完了 +- (*推奨*) [Hello, Weaviate](../101_hello_weaviate/index.mdx) の完了 +- (*推奨*) [Queries 1](../102_queries_1/index.mdx) の完了 + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/10_bm25.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/10_bm25.mdx new file mode 100644 index 000000000..4464f17c9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/10_bm25.mdx @@ -0,0 +1,212 @@ +--- +title: BM25(キーワード)検索 +description: Weaviate で BM25 クエリを実装し、検索結果を効果的に最適化する方法をご紹介します。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/10_bm25.py'; + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +[//]: # (Image alt) + +## 概要 + +BM25 検索は、一般的に「キーワード検索」と呼ばれるものの実装の 1 つです。大まかに言えば、クエリとインデックス内のデータオブジェクトの間で検索語を照合して動作します。 + +## `bm25` クエリについて + +### 動作の仕組み + +ユーザーが BM25 クエリを送信すると、Weaviate はオブジェクトのテキストプロパティ内に検索語を含むオブジェクトを探します。その後、検索語がプロパティ内に出現する回数に基づいて結果をランキングします。 + +このように、BM25 クエリは単に条件に基づいてオブジェクトを含めたり除外したりするキーワードベースのフィルタリングとは異なります。 + +### `bm25` クエリの構文 + +以下に BM25 クエリの例を示します。各 BM25 クエリは次のとおりです。 + +- **必須** クエリ文字列を含める(長さは任意) +- **任意** `properties` のリストを指定できる +- **任意** 各 `properties` に対して重みを設定できる +- **任意** 各結果に `score` を返すようリクエストできる + + + + + + + +上記のクエリは、クエリ文字列 `"food"` に対する BM25F スコアに基づき、上位 3 件のオブジェクトを返します。`question` と `answer` プロパティを検索し、そのうち `question` プロパティは 3 倍にブーストされます。 + +
+ JSON レスポンスを表示 + + + +
+ +:::tip 演習 +ブースト係数やクエリ文字列を変更してみましょう。結果はどのように変化しますか? +::: + +## トークン化と `bm25` 検索 + +### トークン化が重要な理由 + +以前のユニットで [ 転置インデックス ](../103_schema_and_imports/10_data_structure.mdx#-inverted-index) について簡単に説明し、それがトークン化されたデータのインデックスを保持していることに触れました。 + +BM25 クエリが送信されると、Weaviate は各プロパティをそのトークン化設定に従って検索します。たとえば、あるプロパティが `word` トークン化オプションを使用している場合、クエリ文字列は小文字化された単語に分割され、各単語がインデックス内で検索されます。一方、プロパティが `field` トークン化を使用している場合、Weaviate はクエリ文字列全体をインデックス内で検索します。 + +:::tip これは転置インデックスにのみ適用されます +ここで説明しているトークン化は、言語モデルやベクトライザーなどにおけるトークン化とは異なります。本節で扱うトークン化は転置インデックスにのみ適用されます。 +::: + +具体的な例を見てみましょう。 + +### `word` トークン化 + +この例では、クエリ文字列 `Jeopardy` を使用して `question` プロパティを検索します。`question` プロパティは `word` トークン化オプションでトークン化されています。 + + + + + + + +`word` トークン化では、英数字は小文字化され、空白で分割されます。そのため、検索結果には `question` プロパティに TV 番組名 `Jeopardy!` を含むものが返されます。 + +
+ JSON レスポンスを表示 + + + +
+ +続いて、同じクエリを `field` トークン化オプションで実行してみましょう。 + +### `field` トークン化 + +この例では、クエリ文字列は同じ (`Jeopardy`) ですが、今回は `field` トークン化オプションが設定された `round` プロパティを検索します。 + + + + + + + +`field` トークン化では、空白をトリミングした後、文字列全体をそのまま保持します。そのため、`round` の値に `Jeopardy!` や `Double Jeopardy!` が含まれていることが分かっていても、検索結果は返されません。 + +
+ JSON レスポンスを表示 + + + +
+ +:::tip 演習 +クエリを `Jeopardy!` に変更してみましょう。結果はどのように変化しますか? +::: +### 経験則 + +[トークナイズの全オプション一覧](/weaviate/config-refs/collections.mdx#tokenization) は `word`、`whitespace`、`lowercase`、`field` です。各オプションを選ぶ際の経験則として、部分一致を取得したい長いテキストには `word` を、完全一致のみを取得したい短いテキストには `field` を使用します。その他のオプションはその中間で、たとえば大文字小文字を区別したい場合は `whitespace`、特殊文字を保持したい場合は `lowercase` のように、特定の状況で役立ちます。 + +## BM25F スコアリング + +結果のスコア付けとランキングに使用される正確なアルゴリズムは BM25F アルゴリズムと呼ばれます。詳細はこのコースの範囲を超えますが、要点として BM25F アルゴリズムは BM25 アルゴリズムの派生形で、`F` は「field」を意味します。検索対象のフィールドに基づいて結果をスコアリングし、ランキングします。 + +アルゴリズムの詳細に踏み込みたい場合は、[この Wikipedia ページ](https://en.wikipedia.org/wiki/Okapi_BM25#Modifications) をご覧ください。 + +## 復習 + + + + + +### 重要なポイント + +- BM25 検索はクエリとインデックス内のデータオブジェクト間で検索語をマッチさせ、それらの語の出現頻度に基づいて結果をランキングします。 +- BM25 クエリには必ずクエリ文字列が必要で、加えて検索するプロパティの一覧、各プロパティの重み、各結果に対するスコアを要求することを任意で指定できます。 +- BM25 クエリは検索対象プロパティのトークナイズ方法の影響を受けます。たとえば `word` トークナイズではクエリ文字列を小文字の単語に分割し、`field` トークナイズではクエリ文字列全体を検索します。 +- 検索のユースケースを考慮してトークナイズオプションを選択してください。例えば部分一致を含む長文検索には `word`、完全一致のみの短文検索には `field` を使用します。 +- 「F」は「field」を表す BM25F スコアリングは、検索対象のフィールドに基づいて検索結果をスコアリングし、順位付けします。 + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const Bm25Question = [{ + questionText: 'What does a BM25 search do?', + answerOptions: [ + { + answerText: 'Matches search terms between the query and data objects in the index and ranks results based on the frequency of those terms.', + isCorrect: true, + feedback: 'It is a keyword search with ranking based on term frequency.', + }, + { + answerText: 'Excludes objects based on the provided set of conditions.', + isCorrect: false, + feedback: 'This describes a filter.', + }, + { + answerText: 'Searches for exact matches of the entire query string in the index.', + isCorrect: false, + feedback: 'This is describing a form of tokenization (field tokenization), not BM25 search.', + }, + ] +}]; +export const wordTokenizationQuestion = [{ + questionText: 'What does the `word` tokenization option do?', + answerOptions: [ + { + answerText: 'Lowercases the query string and splits it by whitespace.', + isCorrect: false, + feedback: 'This is only partially true.', + }, + { + answerText: 'Indexes each string as-is.', + isCorrect: false, + feedback: 'This is the `field` tokenization.', + }, + { + answerText: 'Lowercases the query string, keeps alpha-numeric characters and splits it by whitespace.', + isCorrect: true, + feedback: 'Understanding different tokenization options and their impact can be very useful.', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/20_hybrid.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/20_hybrid.mdx new file mode 100644 index 000000000..e5130d179 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/20_hybrid.mdx @@ -0,0 +1,147 @@ +--- +title: ハイブリッド検索 +description: Weaviate でハイブリッドクエリを使用して、 vector とキーワード検索戦略を組み合わせ高精度を実現します。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/20_hybrid.py'; + + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + + + +[//]: # (Image alt) + +## 概要 + +ハイブリッド検索は、先ほど学習した `bm25` 検索と vector 検索を組み合わせ、両方の結果を統合したランキングを生成します。 + +vector 検索またはキーワード検索だけでは期待どおりの結果が得られない場合に、ハイブリッド検索が役立ちます。たとえば、 vector 検索だけでは無関係な結果が多すぎる場合に、特定のキーワードで重み付けをして結果を調整したい場合などです。 + +## `hybrid` クエリ + +### 仕組み + +ハイブリッド検索は、 `bm25` 検索結果と vector 検索結果を結合して動作します。具体的には、各結果の BM25F 検索ランキングと vector 検索ランキングを組み合わせて評価します。 + +各結果について、 BM25F ランキングの逆数と vector 検索ランキングを合計し、必要に応じて `alpha` の重み付けを適用して最終スコアを算出します。最終スコアによって結果が並べ替えられます。 + +この手法により、どちらか一方の検索で高評価を得た結果が優遇されます。例として、次の 5 件の結果を考えてみましょう。 + +- Result 1: BM25F ranking = 5, vector search ranking = 1 -> 合計スコア: 1.2 +- Result 2: BM25F ranking = 4, vector search ranking = 2 -> 合計スコア: 0.75 +- Result 3: BM25F ranking = 3, vector search ranking = 3 -> 合計スコア: 0.67 +- Result 4: BM25F ranking = 2, vector search ranking = 4 -> 合計スコア: 0.75 +- Result 5: BM25F ranking = 1, vector search ranking = 5 -> 合計スコア: 1.2 + +この例では、いずれか一方で高評価だった 1 と 5 が上位に来ています。一方、両方で中程度だった 3 は最下位になっています。 + +つまり、ハイブリッド検索では片方の検索で高評価を得た結果が上位に来やすく、平均的な結果は下位に配置されます。 + +### `hybrid` クエリ構文 + +ハイブリッドクエリは次のように記述します。各ハイブリッドクエリは次の要件を持ちます。 + +- **必須**: 任意長の query 文字列 +- **任意**: 検索対象の `properties` +- **任意**: `alpha` 値 +- **任意**: 検索対象の `vector` +- **任意**: 各結果の `score` および `explainScore` の取得 + + + + + + + +上記のクエリは、クエリ文字列 `"food"` に基づき、 BM25F スコアと `nearText` 類似度で上位 3 件のオブジェクトを返します。 BM25F スコアの計算では `question` と `answer` プロパティを検索します(オブジェクトのベクトルは `properties` の指定による影響を受けません)。 + +
+ JSON レスポンスを表示 + + + +
+ +## `hybrid` 検索パラメーター + +`hybrid` 検索には複数のパラメーターがあり、その一部は `bm25` 検索で既に登場しました。 + +`query` と `properties` は `bm25` 検索と同じですが、現在ハイブリッド検索では boost パラメーターはサポートされていません。一方、ハイブリッド検索固有のパラメーターも存在します。 + +[//]: # (### `vector`) + +[//]: # () +[//]: # (The `vector` parameter is optional. If you do not include a `vector` parameter, the `hybrid` search will generate a vector from the query string. If you do include a `vector` parameter, the `hybrid` search will use the vector you provide.) + +[//]: # () +[//]: # (In this way, you may be able to perform a hybrid search where the `bm25` search and the vector search are based on different concepts. For example, you could perform a `bm25` search with the query string `italian`, and have the vector search be based on a vector of `food`.) + +[//]: # () +[//]: # (:::warning) + +[//]: # (TODO - complete this section after I get responses on the slack comment/question) + +[//]: # (:::) + +### `alpha` + +任意の `alpha` パラメーターは、 BM25 検索ランキングと vector 検索ランキングの重み付けを決定します。指定しない場合は既定値 0.5 が使用され、両者が同等に重み付けされます。 + +`alpha` を 1 にすると純粋な vector 検索と同じになり、0 にすると純粋な BM25 検索と同じになります。 + +:::tip 演習 +上のクエリで `alpha` を変化させてみましょう。結果はどう変わりますか? +::: + +## 復習 + + + +### 復習問題 + +### 重要ポイント + +- ハイブリッド検索は `bm25` 検索と vector 検索を組み合わせ、両者の結果からランキングを生成します。 +- vector 検索またはキーワード検索だけでは求める結果が得られない場合に有効です。 +- ハイブリッド検索では、 vector と `bm25` のランキングの逆数を合計して検索結果を並べ替えます。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const hybridRankingQuestion = [{ + questionText: 'How do hybrid searches order its search results?', + answerOptions: [ + { + answerText: 'By multiplying the vector similarity with the BM25 score', + isCorrect: false, + feedback: 'It does not do that, unfortunately.', + }, + { + answerText: 'By averaging the vector and BM25 search rankings', + isCorrect: false, + feedback: 'It does not do that, unfortunately.', + }, + { + answerText: 'By summing the inverse of the vector and BM25 rankings', + isCorrect: true, + feedback: 'So it has the effect of rewarding results that score high in at least one of the searches.', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/30_generative.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/30_generative.mdx new file mode 100644 index 000000000..25c46aab9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/30_generative.mdx @@ -0,0 +1,242 @@ +--- +title: 生成検索 +description: Weaviate の Python SDK で高度なクエリを作成するための生成 AI の利用方法を学びます。 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/30_generative.py'; + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +[//]: # (Image alt) + +## 概要 + +生成検索の核心となる概念は、データベースから単にデータを取得するのではなく、 Weaviate がデータを変換してから返せるという点です。 + +このデータ変換機能により、生成検索は強力なツールとなり、データベースを単なる情報の保管庫ではなく、データと instructions の組み合わせに基づいてアウトプットを生成する存在へと変えてくれます。 + +## 設定 + +### モジュールの有効化 + +生成検索を利用するには、 Weaviate インスタンスで `generative-xxx` モジュールを有効化する必要があります。 + +WCD をご利用の場合、生成モジュールはデフォルトで有効化されています([ドキュメントはこちら](/cloud))。それ以外の場合は、生成モジュールが有効になっていることを確認するよう、 Weaviate インスタンスを設定してください。 + +### クラスの設定 + +Weaviate インスタンスで生成モジュールが 1 つだけ有効化されている場合、 Weaviate はすべての生成タスクでそのモジュールを自動的に使用します。 + +一方、複数の生成モジュールが設定されている場合は、各クラスに対して使用する生成モデルを定義する必要があります。下記はその例です。 + +```json +{ + "classes": [ + { + "class": "JeopardyQuestion", + "moduleConfig": { + "generative-openai": { + "model": "gpt-3.5-turbo" + } + } + } + ] +} +``` + +## 生成検索について + +### 仕組み + +生成検索は、実質的には 2 つの手順を 1 つのプロセスにまとめたものと考えると分かりやすいです。 +1. 検索を実行する +1. 検索結果とユーザーが提供したプロンプトを用いて生成モデルを呼び出す + +生成された出力は検索結果に追加され、ユーザーへ返されます。 + +生成検索には `single prompt` と `grouped task` の 2 種類があります。 + +- `single prompt` 検索では、ユーザーが指定したプロンプトと各検索結果を用いて、結果ごとに **1 件の応答** が生成されます。 +- `grouped task` 検索では、検索結果全体とユーザーが指定したプロンプトをまとめて用い、結果セット全体に対して **1 件の応答** が生成されます。 + +### 生成検索の構文 + +生成検索では検索プロセスにステップが 1 つ追加されます。そのため、生成検索を行う際は、プロンプトタイプ(`single prompt` または `grouped task`)と検索クエリの両方を指定する必要があります。 + +#### シングルプロンプト + +シングルプロンプト検索を実行するには、少なくとも 1 つのオブジェクトプロパティを含むプロンプトを指定する必要があります。指定したプロパティは検索結果に基づいて Weaviate が自動で置き換えます。 + +シングルプロンプト検索は次のように実行できます。 + + + + + + + +上記のクエリは、`nearText` 類似度検索を使って `Article` オブジェクトを上位 3 件検索します。その後、 Weaviate は各結果と指定したプロンプトを生成モデルへ送り、その出力をユーザーへ返します。 + +`single prompt` 検索では、検索で見つかったオブジェクトごとに出力が生成されます。そのため、レスポンス内の各オブジェクトには、生成された出力が `_additional` プロパティセットに含まれます。 + +
+ JSON レスポンスを見る + + + +
+ +#### グループタスク + +グループタスク検索では、プロパティを指定する必要はありません。次のように実行できます。 + + + + + + + +上記のクエリは、先ほどと同様に `nearText` 類似度検索を使って `Article` オブジェクトを上位 3 件検索します。ただし今回は、検索結果を連結してユーザーが指定したプロンプトと共に生成モデルへ送ります。 + +言い換えると、`grouped task` 検索ではタスクごとに 1 度だけ生成モデルが呼び出され、1 件の生成結果が得られます。 + +そのため、`grouped task` 検索ではタスク全体に対して 1 件の出力のみが生成されます。この生成出力は、レスポンスの最初のオブジェクト内の `_additional` プロパティセットとして返されます。 + +
+ JSON レスポンスを見る + + + +
+## オブジェクト プロパティ + +`single prompt` 形式の生成検索ではプロパティを指定する必要があることはすでに確認しました。 +また、`grouped task` 検索でも使用するプロパティを個別に指定できます。 + +### プロパティ指定の理由 + +`single prompt` の例では、それぞれのプロパティがモデルのプロンプトを構成する役割を果たし、`{summary}` のようなプレースホルダーを取得した summary テキストで置き換えます。 + +また、各 `grouped task` で使用するプロパティを指定して、生成モデルに渡したいデータだけを送るようにできます。 + +#### コンテキスト ウィンドウ長 + +プロパティを指定するもう一つの理由は、モデルのコンテキスト長を超過する可能性を低減することです。生成モデルは通常 transformer ベースで、多くはコンテキスト ウィンドウに制限があります。 + +そのため、必要なプロパティだけを生成モジュールに渡すことで、コンテキスト ウィンドウの制限を超えずに、より多くのオブジェクトの結果を含められる可能性があります。 + +### プロパティの指定方法 + +:::tip 返却プロパティと無関係な生成検索用プロパティ +`single prompt` 検索でも `grouped task` 検索でも、生成検索で使用するプロパティは返却プロパティと同じである必要はありません。 +::: + +先ほど見たように、`single prompt` 検索ではプロンプト内で使用するプロパティを指定できます。 + +`grouped task` 検索では、使用するプロパティを追加パラメーターとして渡す必要があります。 +次の例では、生成モデルに提供されたプロンプトをそのまま繰り返すように指示しています。 + + + + + + + +
+ See the JSON response + + + +
+ +## 生成検索パラメーター + +### モデルのオプション パラメーター + +生成モジュールは Large Language Model (LLM) と呼ばれるモデルを使用して、検索結果とプロンプトから出力を生成します。 + +Weaviate は、プロバイダーが提供する追加のオプション パラメーターを通じてこれらのモデルの挙動を調整できるようにしています。 + +すべてのパラメーターを網羅することはできませんが、よく使われるパラメーター群を以下に示します。 + +:::tip パラメーター名はモデルによって異なります +各モデルで使用されるパラメーター名は異なるため、必ず該当モジュールとモデルのドキュメントを参照してください。 +::: + +- `model`: 使用する実際の言語モデルを決定します。 +- `temperature`, `k`, `p`: モデルの「ランダムさ」の度合いを決定します。一方の極端ではモデルは決定論的に動作し、他方の極端ではより予測不可能(時に一貫性のない)出力を生成します。OpenAI など一部のプロバイダーはこれらの設定のうち 1 つだけを使用することを推奨しています。 +- `max_tokens`: 生成される出力の最大長を決定します。値が大きいほど、入力長との合計でコンテキスト制限を超える可能性が高くなります。 +- `xxx_penalty`: 同一トークンが再度出現することや出現回数など、特定の要素をどの程度ペナルティするかを決定します。 + +次の例では `generative-openai` モジュールに対してさまざまなパラメーターを指定しています: + +```json +{ + "classes": [ + { + "class": "JeopardyQuestion", + "moduleConfig": { + "generative-openai": { + "model": "gpt-3.5-turbo", + "temperatureProperty": 0.3, + "maxTokensProperty": 512, + "frequencyPenaltyProperty": 0.1, + "presencePenaltyProperty": -0.1 + } + } + } + ] +} +``` + +まずは、可能であればモデルを含むデフォルト設定を試すことをお勧めします。その上で満足のいく結果が得られない場合には、別のモデルやパラメーター、アプローチを試してみてください。 + +## まとめ + +### 重要なポイント + +- 生成検索はデータを返す前に変形することで、データベースをデータ処理のより能動的な参加者へと変えます。 +- 生成検索を使用するには、Weaviate インスタンスで生成モジュールが有効になっている必要があります。WCD では生成モジュールがデフォルトで有効です。 +- 生成検索は、検索を実行し、その検索結果とユーザーが提供したプロンプトを用いて生成モデルを呼び出すという 2 段階で構成されます。 +- `single prompt` 検索は各結果に対して応答を生成しますが、`grouped task` 検索は結果セット全体に対して 1 つの応答を生成します。 +- 生成検索ではオブジェクト プロパティを使用します。`single prompt` の例ではプロパティがモデルのプロンプトを構成し、`grouped task` でも指定できます。 +- 生成モジュールは LLM を使用しており、Weaviate はその挙動を調整するためのオプション パラメーターを公開しています。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/90_wrap_up.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/90_wrap_up.mdx new file mode 100644 index 000000000..59175dfa5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/90_wrap_up.mdx @@ -0,0 +1,25 @@ +--- +title: まとめ +description: クエリのまとめ - パート 2 +--- + +## ユニットレビュー + +このユニットでは、キーワード ( BM25 )、ハイブリッド、生成、 QnA 検索など、追加のクエリタイプについて学習しました。[Queries 1](../102_queries_1/index.mdx) で学んだツールと組み合わせることで、多彩な検索ツールを手にしました。 + +これらのツールはそれぞれ異なる方法でデータを問いただすことができます。各タイプの仕組みを理解しておくと、タスクに適したクエリを作成できます。 + +たとえば BM25 検索は厳密なキーワード検索に利用でき、ハイブリッド検索は BM25 と ベクトル 検索の結果を組み合わせられます。一方、生成検索と QnA 検索は、ユーザーに届ける前にデータを変換します。これらの検索は言語モデルの力を活用し、データに命を吹き込み、 Weaviate を単なるデータ取得以上のレベルへと引き上げます。 + +### 学習成果 + +- BM25 とハイブリッド検索を実行できます。 +- ベクトル、 BM25、ハイブリッド検索を区別できます。 +- 生成検索で配送前にデータを変換できます。 +- QnA 検索でデータから回答を抽出できます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_40_qna.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_40_qna.mdx new file mode 100644 index 000000000..d6c092d5b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_40_qna.mdx @@ -0,0 +1,152 @@ +--- +title: 質問応答 (QnA) +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCodeExample from '!!raw-loader!./_snippets/40_qna.py'; + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +[//]: # (Image alt) + +## 概要 + +質問応答 ( QnA ) モジュールは、その名前が示すとおりの働きをします。検索結果に含まれるデータを基に、あなたの質問に回答します。 + +これは生成モジュールが行うデータ変換よりもさらに特化した処理です。 QnA モジュールは、検索データから質問への答えを抽出しようとします。 + +そのため、場合によっては QnA モジュールが回答を返さないこともあります。 + +## 設定 + +### モジュールを有効化する + +QnA 機能を使用するには、 Weaviate インスタンスで `qna-xxx` モジュールを有効にする必要があります。 + +WCD を使用している場合、`qna` モジュールはデフォルトで有効になっています([ドキュメント](/cloud) を参照)。それ以外の場合は、`qna-xxx` モジュールが有効になるように Weaviate インスタンスを設定してください。 + +設定方法は本ユニットの範囲外ですが、各モジュールの設定方法については [モジュール設定](/weaviate/modules/reader-generator-modules/index.md) を参照してください。 + +### クラスを設定する + +Weaviate インスタンスで 1 つだけ qna モジュールが有効になっている場合、すべての QnA タスクで自動的にそのモジュールが使用されます。 + +一方、複数の qna モジュールが構成されている場合は、下記のようにクラスごとに使用する qna モデルを指定しなければなりません。 + +```json +{ + "classes": [ + { + "class": "JeopardyQuestion", + "moduleConfig": { + "qna-openai": { + "model": "gpt-3.5-turbo-instruct" + } + } + } + ] +} +``` + +QnA 機能を使用するには、対象クラスに ベクトライザー (`text2vec`) モジュールが設定されていることも必要です。 + +## QnA クエリについて + +### 仕組み + +生成モジュールと同様に、 QnA 検索は次の 2 段階で行われます。 +1. 検索を実行する +1. 検索結果と質問を用いて回答を抽出する + +適切な回答が見つかったかどうかに応じて、`_additional` プロパティ配下の `answer` サブプロパティに回答が格納されます。モデルによっては、テキスト内での回答の位置も返します。 + +回答が見つからなかった場合は、その旨が `answer` サブプロパティに示されます。 + +### QnA 構文 + +生成検索では、同じ質問文が +- 検索の実行 +- 回答の抽出 +の両方に使用されます。 + +したがって、下記の例では `"How many championships does Lewis Hamilton have?"` というクエリを用いて最も近いオブジェクトを検索し、そこから Weaviate が質問への回答を抽出しようとします。 + + + + + + + +このクエリでは、記事に回答が含まれており、モデルによって正しく抽出されていることが確認できます。 + +
+ JSON レスポンスを見る + + + +
+ +### プロパティの指定方法 + +QnA モジュールが回答を探す際に対象とするオブジェクトのプロパティを指定できます。生成クエリの場合と同様、入力の長さを短縮したい場合や、情報源を明確に限定したい場合に便利です。 + +:::note `nearText` search unaffected +Specifying properties to search only affects the answer extraction part of the query, as the underlying object vectors do not change. +::: + + + + + + + +このクエリでは、必要な情報が `title` フィールドに存在しないため、 Weaviate は質問に答えることができません。 + +
+ JSON レスポンスを見る + + + +
+ +### オブジェクト数の制限 + +これも 2 段階検索であるため、回答抽出を行う前に Weaviate が最初に取得するオブジェクト数を指定できます。 + +オブジェクト数を増やすことで、質問の答えを含むオブジェクトを取得できる可能性を高められます。 +## レビュー + +### 重要なポイント + +- Question and Answer (QnA) 検索は、別の 2 ステップ検索であり、配信前に取得したデータから特定の質問への回答を抽出しようとします。 +- QnA 検索を実行するには、Weaviate インスタンスで `qna-xxx` モジュールを有効にする必要があります。`qna-openai` モジュールは WCD ではデフォルトで有効になっています。 +- QnA モジュールは、取得した各オブジェクト内から回答を探し、追加プロパティとして返します。 +- QnA モジュールが回答を特定できない場合は、その旨をレスポンスで示します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/10_bm25.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/10_bm25.py new file mode 100644 index 000000000..264330d35 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/10_bm25.py @@ -0,0 +1,152 @@ +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate +import json + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your API Key for the Weaviate instance. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +# ===== Generic BM25 Query ===== + +# GenericBM25Query +response = ( + client.query + .get("JeopardyQuestion", ["question", "answer"]) + # highlight-start + .with_bm25( + query="food", # Query string + properties=["question^2", "answer"] # Searched properties, including boost for `question` + ) + .with_additional("score") # Include score in the response + # highlight-end + .with_limit(3) + .do() + ) + +print(json.dumps(response, indent=2)) +# END GenericBM25Query + +# Tests +assert "JeopardyQuestion" in response["data"]["Get"] +assert len(response["data"]["Get"]["JeopardyQuestion"]) == 3 +assert response["data"]["Get"]["JeopardyQuestion"][0].keys() == {"question", "answer", "_additional"} +assert response["data"]["Get"]["JeopardyQuestion"][0]["_additional"].keys() == {"score"} +# End test + + +expected_response = ( +# Expected GenericBM25Query results +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "score": "4.0038033" + }, + "answer": "cake", + "question": "Devil's food & angel food are types of this dessert" + }, + { + "_additional": { + "score": "3.8706005" + }, + "answer": "a closer grocer", + "question": "A nearer food merchant" + }, + { + "_additional": { + "score": "3.2457707" + }, + "answer": "food stores (supermarkets)", + "question": "This type of retail store sells more shampoo & makeup than any other" + } + ] + } + } +} +# END Expected GenericBM25Query results +) + +# ===== BM25 - `word` Tokenization Example ===== + +# BM25WithWordTokenization +response = ( + client.query + .get( + class_name="JeopardyQuestion", + properties=["question", "round"] + ) + .with_bm25( + "Jeopardy", + properties=["question"] + ) + .with_limit(2) + .do() +) + +print(json.dumps(response, indent=2)) +# END BM25WithWordTokenization + +expected_response = ( +# Expected BM25WithWordTokenization results +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "question": "Capistrano swallows, Undeliverable mail, \"Jeopardy!\" champs", + "round": "Jeopardy!" + }, + { + "question": "This opera star & \"Celebrity Jeopardy!\" contestant began life as Belle Silverman", + "round": "Double Jeopardy!" + } + ] + } + } +} +# END Expected BM25WithWordTokenization results +) + +assert response == expected_response + + +# ===== BM25 - `field` Tokenization Example ===== + +# BM25WithFieldTokenization +response = ( + client.query + .get( + class_name="JeopardyQuestion", + properties=["question", "round"] + ) + .with_bm25( + "Jeopardy", + properties=["round"] + ) + .with_limit(2) + .do() +) + +print(json.dumps(response, indent=2)) +# END BM25WithFieldTokenization + +expected_response = ( +# Expected BM25WithFieldTokenization results +{ + "data": { + "Get": { + "JeopardyQuestion": [] + } + } +} +# END Expected BM25WithFieldTokenization results +) + +assert response == expected_response + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/20_hybrid.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/20_hybrid.py new file mode 100644 index 000000000..9bb12310c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/20_hybrid.py @@ -0,0 +1,77 @@ +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate +import json + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your API Key for the Weaviate instance. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +# ===== Generic Hybrid Query ===== + +# GenericHybridQuery +response = ( + client.query + .get("JeopardyQuestion", ["question", "answer"]) + # highlight-start + .with_hybrid( + query="food", # Query string + properties=["question", "answer"], # Searched properties + vector=None # Manually provide a vector; if not, Weaviate will vectorize the query string + ) + .with_additional(["score", "explainScore"]) # Include score & explainScore in the response + # highlight-end + .with_limit(3) + .do() + ) + +print(json.dumps(response, indent=2)) +# END GenericHybridQuery + +# Tests +assert "JeopardyQuestion" in response["data"]["Get"] +assert len(response["data"]["Get"]["JeopardyQuestion"]) == 3 +assert response["data"]["Get"]["JeopardyQuestion"][0].keys() == {"question", "answer", "_additional"} +assert response["data"]["Get"]["JeopardyQuestion"][0]["_additional"].keys() == {"score", "explainScore"} +# End test + + +expected_response = ( +# Expected GenericHybridQuery results +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "explainScore": "(bm25)\n(hybrid) Document df958a90-c3ad-5fde-9122-cd777c22da6c contributed 0.003968253968253968 to the score\n(hybrid) Document df958a90-c3ad-5fde-9122-cd777c22da6c contributed 0.012295081967213115 to the score", + "score": "0.016263336" + }, + "answer": "a closer grocer", + "question": "A nearer food merchant" + }, + { + "_additional": { + "explainScore": "(vector) [0.022335753 -0.027532013 -0.0061008437 0.0023294748 -0.00041679747 -0.007862403 -0.018513374 -0.037407625 -0.004291675 -0.012575763]... \n(hybrid) Document ec776112-e651-519d-afd1-b48e6237bbcb contributed 0.012096774193548387 to the score", + "score": "0.012096774" + }, + "answer": "Famine", + "question": "From the Latin for \"hunger\", it's a period when food is extremely scarce" + }, + { + "_additional": { + "explainScore": "(vector) [0.022335753 -0.027532013 -0.0061008437 0.0023294748 -0.00041679747 -0.007862403 -0.018513374 -0.037407625 -0.004291675 -0.012575763]... \n(hybrid) Document 98807640-cd16-507d-86a1-801902d784de contributed 0.011904761904761904 to the score", + "score": "0.011904762" + }, + "answer": "Tofu", + "question": "A popular health food, this soybean curd is used to make a variety of dishes & an ice cream substitute" + } + ] + } + } +} +# END Expected GenericHybridQuery results +) diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/30_generative.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/30_generative.py new file mode 100644 index 000000000..49bc178fb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/30_generative.py @@ -0,0 +1,207 @@ +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate +import json + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your API Key for the Weaviate instance. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +# ===== Basic Single Prompt Generative Query ===== + +# SinglePromptQuery +response = ( + client.query + .get("Article", ["title", "summary"]) + .with_near_text({"concepts": ["housing prices"]}) + .with_limit(3) + # highlight-start + .with_generate( + single_prompt="Provide a two-bullet point summary of the article, whose title is {title} and body {summary}" + ) + # highlight-end + .do() +) + +print(json.dumps(response, indent=2)) +# END SinglePromptQuery + +# Tests +assert "Article" in response["data"]["Get"] +assert len(response["data"]["Get"]["Article"]) == 3 +assert response["data"]["Get"]["Article"][0].keys() == {"title", "summary", "_additional"} +assert response["data"]["Get"]["Article"][0]["_additional"].keys() == {"generate"} +assert "singleResult" in response["data"]["Get"]["Article"][0]["_additional"]["generate"].keys() +# End test + +expected_response = """ +# Expected SinglePromptQuery results +{ + "data": { + "Get": { + "Article": [ + { + "_additional": { + "generate": { + "error": null, + "singleResult": "- Real house prices have risen by 5% on average in the latest 12-month period among the 25 countries tracked by The Economist, the quickest in over a decade.\n- House prices in suburban locations are rising faster than in cities due to the expectation that commuting may no longer be daily, reversing a decade-long trend." + } + }, + "summary": "As restrictions have eased, house prices have started to go through the roof. Among the 25 countries that The Economist tracks, real house prices rose by 5% on average in the latest 12-month period, the quickest in over a decade. The expectation that commuting may no longer be daily has caused house prices in suburban locations to rise faster than in cities\u2014reversing a decade-long trend. One reason is that house prices do not look as if they threaten financial stability. If house prices in America fell by one-quarter, its 33 biggest banks would still have 50% more capital than they had going into the crisis of 2007-09.", + "title": "House prices are going ballistic" + }, + { + "_additional": { + "generate": { + "error": null, + "singleResult": "- Politicians are taking action to address housing shortages, and consultants in Auckland have detected a genuine interest in boosting housing supply.\n- Evidence suggests that autocratic planning systems may be more effective at increasing housing supply, as seen in Switzerland where house prices have risen less than in any other rich country." + } + }, + "summary": "Consultants to the government in Auckland detect a genuine interest in boosting housing supply. The part of the country with the most elastic housing supply, Pine Bluff, a midsized city in Arkansas, has an average house price of $90,000. Some evidence seems to back up the view that economists\u2019 obsession with housing supply is misguided. Autocratic planning systems do a better job of boosting housing supply. In the past century Swiss house prices have risen by less than those in any other rich country.", + "title": "Supply - Politicians are finally doing something about housing shortages" + }, + { + "_additional": { + "generate": { + "error": null, + "singleResult": "- American house prices rose by 11% in the year to January, the fastest pace for 15 years, and real house prices have risen by an average of 5% across the 25 countries tracked by The Economist.\n- House prices outside Germany's seven biggest cities rose by 11% last year, compared with 6% within them, while house prices in central London and Sydney rose by just 4% and 3% last year, respectively, and those in Manhattan fell by 4%." + } + }, + "summary": "American house prices rose by 11% in the year to January, the fastest pace for 15 years. Across the 25 countries tracked by The Economist, real house prices have risen by an average of 5% in the latest 12-month period. At first glance, the robustness of house prices in the face of the economic turmoil inflicted by covid-19 might seem baffling: property prices typically move in tandem with the economy. House prices outside Germany\u2019s seven biggest cities rose by 11% last year, compared with 6% within them. By contrast, house prices in central London and Sydney rose by just 4% and 3% last year, respectively; those in Manhattan fell by 4%.", + "title": "House prices in the rich world are booming" + } + ] + } + } +} +# END Expected SinglePromptQuery results +""" + +# ===== Basic Grouped Generative Query ===== + +# GroupedTaskQuery +response = ( + client.query + .get("Article", ["title", "summary"]) + .with_near_text({"concepts": ["housing prices"]}) + .with_limit(3) + # highlight-start + .with_generate( + grouped_task="Provide any common threads between these articles, if any" + ) + # highlight-end + .do() +) + +print(json.dumps(response, indent=2)) +# END GroupedTaskQuery + +# Tests +assert "Article" in response["data"]["Get"] +assert len(response["data"]["Get"]["Article"]) == 3 +assert response["data"]["Get"]["Article"][0].keys() == {"title", "summary", "_additional"} +assert response["data"]["Get"]["Article"][0]["_additional"].keys() == {"generate"} +assert "groupedResult" in response["data"]["Get"]["Article"][0]["_additional"]["generate"].keys() +# End test + +expected_response = """ +# Expected GroupedTaskQuery results +{ + "data": { + "Get": { + "Article": [ + { + "_additional": { + "generate": { + "error": null, + "groupedResult": "All three articles discuss the recent rise in house prices in various countries, with a focus on the impact of the COVID-19 pandemic on the housing market. The articles also touch on the factors driving the increase in prices, such as changes in commuting patterns and supply shortages. Additionally, the articles mention the potential risks and concerns associated with the rapid rise in house prices, including the threat to financial stability and the impact on affordability for buyers." + } + }, + "summary": "As restrictions have eased, house prices have started to go through the roof. Among the 25 countries that The Economist tracks, real house prices rose by 5% on average in the latest 12-month period, the quickest in over a decade. The expectation that commuting may no longer be daily has caused house prices in suburban locations to rise faster than in cities\u2014reversing a decade-long trend. One reason is that house prices do not look as if they threaten financial stability. If house prices in America fell by one-quarter, its 33 biggest banks would still have 50% more capital than they had going into the crisis of 2007-09.", + "title": "House prices are going ballistic" + }, + { + "_additional": { + "generate": null + }, + "summary": "Consultants to the government in Auckland detect a genuine interest in boosting housing supply. The part of the country with the most elastic housing supply, Pine Bluff, a midsized city in Arkansas, has an average house price of $90,000. Some evidence seems to back up the view that economists\u2019 obsession with housing supply is misguided. Autocratic planning systems do a better job of boosting housing supply. In the past century Swiss house prices have risen by less than those in any other rich country.", + "title": "Supply - Politicians are finally doing something about housing shortages" + }, + { + "_additional": { + "generate": null + }, + "summary": "American house prices rose by 11% in the year to January, the fastest pace for 15 years. Across the 25 countries tracked by The Economist, real house prices have risen by an average of 5% in the latest 12-month period. At first glance, the robustness of house prices in the face of the economic turmoil inflicted by covid-19 might seem baffling: property prices typically move in tandem with the economy. House prices outside Germany\u2019s seven biggest cities rose by 11% last year, compared with 6% within them. By contrast, house prices in central London and Sydney rose by just 4% and 3% last year, respectively; those in Manhattan fell by 4%.", + "title": "House prices in the rich world are booming" + } + ] + } + } +} +# END Expected GroupedTaskQuery results +""" + +# ===== Grouped Generative Query w/ Specific properties ===== + +# GroupedTaskWithProperties +response = ( + client.query + .get("Article", ["title"]) + .with_near_text({"concepts": ["housing prices"]}) + .with_limit(3) + # highlight-start + .with_generate( + grouped_task="Repeat the provided prompt, exactly", + grouped_properties=["title"] + ) + # highlight-end + .do() +) + +print(json.dumps(response, indent=2)) +# END GroupedTaskWithProperties + +# Tests +assert "Article" in response["data"]["Get"] +assert len(response["data"]["Get"]["Article"]) == 3 +assert response["data"]["Get"]["Article"][0].keys() == {"title", "_additional"} +assert response["data"]["Get"]["Article"][0]["_additional"].keys() == {"generate"} +assert "groupedResult" in response["data"]["Get"]["Article"][0]["_additional"]["generate"].keys() +# End test + +expected_response = """ +# Expected GroupedTaskWithProperties results +{ + "data": { + "Get": { + "Article": [ + { + "_additional": { + "generate": { + "error": null, + "groupedResult": "[{\"title\":\"House prices are going ballistic\"},{\"title\":\"Supply - Politicians are finally doing something about housing shortages\"},{\"title\":\"House prices in the rich world are booming\"}]" + } + }, + "title": "House prices are going ballistic" + }, + { + "_additional": { + "generate": null + }, + "title": "Supply - Politicians are finally doing something about housing shortages" + }, + { + "_additional": { + "generate": null + }, + "title": "House prices in the rich world are booming" + } + ] + } + } +} +# END Expected GroupedTaskWithProperties results +""" diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/40_qna.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/40_qna.py new file mode 100644 index 000000000..1b8006648 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/_snippets/40_qna.py @@ -0,0 +1,112 @@ +# ===== Instantiate Weaviate client w/ auth config ===== +import weaviate +import json + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY"), # Replace with your API Key for the Weaviate instance. Delete if authentication is disabled. + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", + }, +) + +# ===== SimpleQnA Query ===== + +# SimpleAskQuery +ask = { + "question": "How many championships does Lewis Hamilton have?", +} + +response = ( + client.query + .get("WikiArticle", ["title", "_additional {answer {hasAnswer property result startPosition endPosition} }"]) + .with_ask(ask) + .with_limit(1) + .do() +) + +print(json.dumps(response, indent=2)) +# END SimpleAskQuery + +# Tests +assert "WikiArticle" in response["data"]["Get"] +assert len(response["data"]["Get"]["WikiArticle"]) == 1 +assert response["data"]["Get"]["WikiArticle"][0].keys() == {"title", "_additional"} +assert response["data"]["Get"]["WikiArticle"][0]["_additional"].keys() == {"answer"} +# End test + +""" +# Expected SimpleAskQuery results +{ + "data": { + "Get": { + "WikiArticle": [ + { + "_additional": { + "answer": { + "endPosition": 0, + "hasAnswer": true, + "property": "", + "result": " Lewis Hamilton has seven World Drivers' Championship titles.", + "startPosition": 0 + } + }, + "title": "Lewis Hamilton" + } + ] + } + } +} +# END Expected SimpleAskQuery results +""" + +# ===== QnA Query with Properties ===== + +# AskQueryWithProperties +ask = { + "question": "How many championships does Lewis Hamilton have?", + "properties": ["title"] +} + +response = ( + client.query + .get("WikiArticle", ["title", "_additional {answer {hasAnswer property result startPosition endPosition} }"]) + .with_ask(ask) + .with_limit(1) + .do() +) + +print(json.dumps(response, indent=2)) +# END AskQueryWithProperties + +# Tests +assert "WikiArticle" in response["data"]["Get"] +assert len(response["data"]["Get"]["WikiArticle"]) == 1 +assert response["data"]["Get"]["WikiArticle"][0].keys() == {"title", "_additional"} +assert response["data"]["Get"]["WikiArticle"][0]["_additional"].keys() == {"answer"} +# End test + +""" +# Expected AskQueryWithProperties results +{ + "data": { + "Get": { + "WikiArticle": [ + { + "_additional": { + "answer": { + "endPosition": 0, + "hasAnswer": true, + "property": "", + "result": " Lewis Hamilton has seven World Drivers' Championship titles.", + "startPosition": 0 + } + }, + "title": "Lewis Hamilton" + } + ] + } + } +} +# END Expected AskQueryWithProperties results +""" diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/index.mdx new file mode 100644 index 000000000..e803a6606 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/104_queries_2/index.mdx @@ -0,0 +1,51 @@ +--- +title: P3_104 クエリ 2 (Python) +description: 高度な手法とカスタムフィルターで Weaviate のクエリをさらに探究する。 +sidebar_position: 104 +--- + +import ZeroToMvpDeprecationNote from '/docs/academy/py/zero_to_mvp/_snippets/deprecation.md'; + + + +## ユニット概要 + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +[//]: # (Image alt) + + + +このユニットでは、Weaviate で実行できるさらに多くのクエリの種類について学びます。 + +まず、BM25F ランキングアルゴリズムを用いたキーワード検索の方法と、キーワード検索と ベクトル 検索を組み合わせたハイブリッド検索を見ていきます。 + +次に、生成検索と質問応答 (QnA) 検索を取り上げます。これらの検索では、データオブジェクトを取得するだけでなく、返す前に結果を変換することができます。 + +このユニットを終える頃には、目的に応じて選択できる複数のクエリタイプを習得し、望む形式で適切な情報を取得できるようになります。 + +それでは始めましょう。 + +### 前提条件 + +- (**Required**) `weaviate-client` がインストールされた Python (3) 環境。 +- (**Required**) [101A Weaviate Academy 準備](../setup.mdx) を完了してください。 +- (*Recommended*) [Hello, Weaviate](../101_hello_weaviate/index.mdx) を完了してください。 +- (*Recommended*) [クエリ 1](../102_queries_1/index.mdx) を完了してください。 +- (*Recommended*) [スキーマとインポート](../103_schema_and_imports/index.mdx) を完了してください。 + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_10_body.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_10_body.mdx new file mode 100644 index 000000000..c3d37621f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_10_body.mdx @@ -0,0 +1,83 @@ +--- +title: アカデミーのメインボディ例 +--- + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +Image alt + +## トップレベル見出し + +テキスト + +### 理論サブヘッド +### 実践サブヘッド + +テキスト + +### 理論サブヘッド +### 実践サブヘッド + +テキスト + +## トップレベル見出し + +テキスト + +### 理論サブヘッド +### 実践サブヘッド + +テキスト + +### 理論サブヘッド +### 実践サブヘッド + +テキスト + + + +## 復習 + + + +クイズの質問 + +### 復習課題 + +:::note Exercise +Try out ... +::: + +### 重要ポイント + +:::info +要約を追加してください +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +const varName = [{ + questionText: 'questionText', + answerOptions: [ + { + answerText: 'answerOne', + isCorrect: false, + feedback: 'feedbackOne', + }, + { + answerText: 'answerTwo', + isCorrect: false, + feedback: 'feedbackTwo', + }, + { + answerText: 'answerThree', + isCorrect: false, + feedback: 'feedbackThree', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_90_wrap_up.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_90_wrap_up.mdx new file mode 100644 index 000000000..af4b9b973 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_90_wrap_up.mdx @@ -0,0 +1,17 @@ +--- +title: まとめ +--- + +## ユニットの振り返り + +このユニットでは、あなたは... +### 学習成果 + +今では、次のことができるはずです: +... + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_index.mdx new file mode 100644 index 000000000..28e15100d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_000_template/_TEMPLATE_index.mdx @@ -0,0 +1,28 @@ +--- +title: タイトル +sidebar_position: 101 +--- + + + + +:::warning TODO +Intro video here +::: + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/50_cross_references.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/50_cross_references.mdx new file mode 100644 index 000000000..322aa1722 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/50_cross_references.mdx @@ -0,0 +1,29 @@ +--- +title: 相互参照 +--- + +## 相互参照 + +### 相互参照について + +### 設定方法 + +### 相互参照を含めたインポート方法 + +### クエリ例 + +## 復習 + +### 復習課題 + +:::caution TODO +復習用の演習を追加してください +::: + +### 要点 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/70_import_example_2.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/70_import_example_2.mdx new file mode 100644 index 000000000..f51d85894 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/70_import_example_2.mdx @@ -0,0 +1,32 @@ +--- +title: 例 +--- + +## ケーススタディ + +### 使用データセット +ここでは、[一部](https://github.com/weaviate-tutorials/edu-datasets/blob/main/winemag_tiny.csv) の [ Kaggle のワインレビュー](https://www.kaggle.com/datasets/zynicide/wine-reviews) データセットを使用します。 + +この小規模データセットは、世界各地のワインレビュー 50 行で構成されています。ここではスキーマを構築します。 + +### ベクトル化オプションの検討 + +### インデックス作成オプションの検討 + +### 画像ベクトル化 + +## レビュー + +### レビュー演習 + +:::caution TODO +レビュー演習を追加する +::: + +### 主なポイント + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/index.mdx new file mode 100644 index 000000000..25cb6ca44 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/index.mdx @@ -0,0 +1,28 @@ +--- +title: 103 ベクトル化の基本 +sidebar_position: 103 +--- + +## ユニット概要 + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +Image alt + + + +ようこそ!このユニットでは、前回のクエリ入門ユニットを踏まえ、理論的な背景や内部動作についてより詳細なコンテキストを提供します。 + +まず、ベクトル検索がなぜ機能するのか、そして何がその高い性能を支えているのかを説明します。この議論では、ベクトル検索を支えるディープラーニングモデルにも触れ、それらがなぜ重要なのかを解説します。また、本ユニットでは Weaviate がデータをどのようにベクトルへ変換するか、そしてその挙動をどのように、なぜカスタマイズできるのかを示します。さらに、Weaviate で利用できるベクトライザーのグループと、ベクトライザー選択の経験則についても取り上げ、十分な情報を基にスムーズに始められるよう支援します。 + +### 前提条件 + +- (**必須**) 稼働中の Weaviate インスタンス + - [Weaviate Cloud](/cloud) の `sandbox` インスタンスを推奨します + - サンプルデータセット「 JeopardyQuestions 」をインポート済み([`weaviate-demo-datasets`](https://pypi.org/project/weaviate-demo-datasets/) より) +- (*推奨*) [Hello, Weaviate](../101_hello_weaviate/index.mdx) を完了している +- (*推奨*) [Queries 1](../102_queries_1/index.mdx) を完了している + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/intro_vectors.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/intro_vectors.mdx new file mode 100644 index 000000000..274a05e74 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/intro_vectors.mdx @@ -0,0 +1,153 @@ +--- +title: ベクトルと意味 +sidebar_position: 10 +--- + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +## ベクトルとベクトル検索 + +Image alt + +これまで「ベクトル検索」という言葉を、その動作 ― 類似度にもとづく検索 ― に着目して説明してきました。また、この文脈では「セマンティック検索」とほぼ同じ意味で用いてきました。ここで少し立ち止まり、詳しく見ていきましょう。 + +### ベクトルとベクトル検索 + +![](https://mlabonne.github.io/blog/images/tensor/scalar.png) + +「ベクトル検索」という名前は、類似度検索を行う際に「ベクトル」を用いることに由来します。つまり、ベクトル検索は類似度検索の実装方法のひとつです。 + +では、ベクトルとは具体的に何でしょうか。 + +この文脈でのベクトルとは数の集合です。正確には、`1, 5, 5`、`0.591, -0.132, 0, 0.105`、`0, 0, 0, 0, 0, 0` のような **一次元の数値配列** です。 + +:::note ベクトル表記 +ベクトルは通常、要素を角括弧で囲んで表します。したがって、上記のベクトルはそれぞれ `[1, 5, 5]`、`[0.591, -0.132, 0, 0.105]`、`[0, 0, 0, 0, 0, 0]` のように表記されます。 +::: + +ベクトル自体は比較的小さな概念で、単なる数の集合 ― 一次元配列 ― にすぎません。一見すると大したことがないように思えますが、ベクトルの真価は「意味」を表現できる点にあります。では、数の列がどのように意味を持つのでしょうか。 + +これはベクトル検索の核心となる大きなアイデアであり、初めて触れる方にとっては最も理解に時間がかかる部分かもしれません。ぜひ一緒に学んでいきましょう。 + +:::info ベクトル / テンソル / 配列 +「テンソル」や「配列」という言葉を見たことがあるかもしれません。文脈によって多少の違いはありますが、多くの場合同じものを指しており、ソフトウェアライブラリや次元数などによって呼称が変わる程度です。 +::: + +:::tip 重要なポイント +ベクトルの真価は、それが「意味」を表現できることにあります。この洞察と深層学習の発展が、ベクトル検索を支えています。 +::: + +### ベクトルの日常的な例 + +![](../../tmp_images/a_isometric_view_of_a_world_map_with_a_pin_on_it_0.jpg) +![](https://i.stack.imgur.com/ikf0N.jpg) + +考え方のひとつとして、ベクトルの各要素は意味の特定の側面を表します。そして、ベクトル全体でそれらの側面を組み合わせたものが「意味」になります。 + +実際、みなさんも既に意味を表すベクトルを使った経験があるかもしれません。たとえば、 +- 位置情報を誰かに送って物体の位置を示したことがある場合、それは緯度と経度(場合によっては高度)を含むベクトルです。 +- 色を表す際に、赤・緑・青(場合によっては透明度)の値を持つベクトルを使ったことがあるかもしれません。 + +これらの例では、ベクトルの各数値が物体の経度や「どれだけ緑か」といった側面を表し、ベクトル全体で「位置」や「色」という意味を表現しています。 + +さらに発展させると、上記 2 つのベクトルを結合して、緯度・経度・赤・緑・青・透明度を含む 1 つのベクトルにすることもできます。すると、そのベクトルは物体の「位置」と「色」の両方を表すことになります。 + +つまり、ベクトルは「どれだけ北か」「どれだけ西か」「どれだけ赤いか」「どれだけ緑か」「どれだけ青いか」「どれだけ透明か」といった属性を列挙することで、物体のあらゆる性質を表現できます。 + + + +## ベクトルで意味を表現する + +Image alt + +### なぜベクトルで意味を表すのか + +![](https://miro.medium.com/v2/resize:fit:1400/format:webp/1*SYiW1MUZul1NvL1kc1RxwQ.png) + +意味を表現するためのベクトル利用は、単語や文、さらにはドキュメント全体の意味を表すところまで拡張されています。 + +ここでも、ベクトルの各要素は意味の側面を表します。たとえば "lion"、"grapefruit"、"cat"、"cow" という単語を表したい場合、各要素で次のような側面を捉えるかもしれません。 +- どれだけ「毛がふさふさ」しているか +- どれだけ「大きい」か +- どれだけ「危険」か +- どれだけ「食用」か + +などです。 + +すると、ベクトル全体はそれらの側面を組み合わせた意味を表します。たとえば "lion" を表すベクトルは `[0.8, 0.9, 0.9, 0.1]`、"grapefruit" を表すベクトルは `[0.1, 0.3, 0.1, 0.9]` のようになります。 + +実際のモデルが生成するベクトルはもっと長く、数百から数千次元になることもありますが、考え方は同じです。各数値が意味の一側面を表し、ベクトル全体で単語の意味を表現します。 + +### ベクトルはどのように生成されるのか + +![](../../tmp_images/a_machine_with_a_conveyer_belt_producing_many_long_numbers_0.jpg) + +ベクトルは機械学習モデルによって生成されます。これらのモデルは大量のデータで訓練され、単語とその意味の関係性を学習します。 + +たとえば、モデルは "lion" と "tiger" がどちらも大型のネコ科動物であるため類似していることを学習します。同時に "lion" と "cow" がどちらも動物であるという共通点も学びます。そして、この知識を使って各ベクトルの要素を調整し、単語の意味を最もよく表すように最適化します。 + +そのため、適切なモデル選びは非常に重要です。選んだモデルはベクトルの品質、ひいては「どの単語が類似しているか」の判断に大きな影響を与えます。 + +日常英語の用例で学習したモデルと、科学論文あるいは医学や法律といった特定ドメインで学習したモデルとでは、生成されるベクトルが異なるのは当然です。 + +具体的なユースケースに合ったモデル選定については、別の章で詳しく解説します。 + + + + + +## まとめ + +:::warning TODO +Video here +::: + +### 復習課題 + +あなた自身の文章で XXX を説明してみましょう。 + +:::warning TODO +Input box for user to put answer in and get back a similarity score & our definition? +?? +::: + +### 重要ポイント + +:::info +Add summary +::: + +import Quiz from '/src/components/Academy/quiz.js' +const vectorDefinition = [ + { + questionText: 'What is a vector in the context of data science?', + answerOptions: [ + { answerText: 'An array of letters.', isCorrect: false, feedback: 'It is not an array of letters.'}, + { answerText: 'An array of numbers.', isCorrect: true, feedback: 'Note: Typically they are floating point numbers.'}, + { answerText: 'An array of symbols.', isCorrect: false, feedback: 'It is not an array of symbols.'}, + { answerText: 'A number with direction and magnitude.', isCorrect: false, feedback: 'This is a definition in science or mathematics, but not so much in the data science context.'}, + ], + }, +]; +const vectorsAndMeaning = [ + { + questionText: 'Which of these is not a good example of vectors representing meaning?', + answerOptions: [ + { answerText: 'An RGB value representing color.', isCorrect: false, feedback: 'Actually, this is a good example. An RGB value uses three numbers for (R)ed, (G)reen and (B)lue to represent color.'}, + { answerText: 'A location coordinate representing longitude, latitude and altitude.', isCorrect: false, feedback: 'Actually, this is a good example. These three numbers would accurately and precisely describe the location.'}, + { answerText: 'A 1024-dimensional vector generated by a language model to represent the word "butterfly".', isCorrect: false, feedback: 'Actually, this is a good example. This is in fact a typical way in which modern vector would be generated.'}, + { answerText: 'None, these are all good examples.', isCorrect: true, feedback: 'All of these are perfectly reasonable examples of vectors representing meaning.'}, + ], + }, +]; +const vectorGeneration = [ + { + questionText: 'How are vectors generated?', + answerOptions: [ + { answerText: 'Manually inputting numbers into an array.', isCorrect: false, feedback: 'This might be theoretically possible, but highly impractical.'}, + { answerText: 'Training machine learning models on large amounts of data.', isCorrect: true, feedback: 'This is typically how they are generated.'}, + { answerText: 'Automatically generating random numbers.', isCorrect: false, feedback: 'While this would work, these vectors would not be "meaningful". Interestingly, this is how they are typically "initialized" during training.'}, + { answerText: 'Copying numbers from other vectors.', isCorrect: false, feedback: 'This would work, but would not produce unique vectors.'}, + ], + }, +]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/vector_parameters.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/vector_parameters.mdx new file mode 100644 index 000000000..c1acffb3b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/vector_parameters.mdx @@ -0,0 +1,120 @@ +--- +title: 効果的な ベクトル 検索 +sidebar_position: 40 +--- + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +## ベクトル 検索 の 理論 + +画像の alt + +### 距離 指標 + +## ベクトライザー の 概要 + +画像の alt + +### 経験則 + +### ベクトライザー の 設定 + +## 追加 の 検索 手法 + +### 検索 オペレーター + +語彙 検索 を 行う とき に 検索 語 を 指定 する の と 同様 に、 Weaviate で ベクトル 検索 を 実行 する には、検索 元 と なる ベクトル を 提供 する 必要 が あります。 + +これら は 例 として `nearVector`、`nearObject`、`nearText` を 使用 し、 GraphQL の 引数 として 渡す こと が できます。 + +これら は GraphQL クエリ 内 で クラス(例: `Get`)への 引数 として Weaviate に 提供 され ます。 + +例えば、次 の クエリ は `Question` クラス で 類似 オブジェクト を 検索 する ため に `nearVector` オペレーター を 追加 して います。 + +```graphql +{ + Get { + Question ( + limit: 1, + nearVector: {vector: } + ) { + question + answer + } + } +} + +print(json.dumps(response, indent=2)) +``` + +「unusual animals」 の ベクトル を 入力 と した 場合、クエリ は 次 の よう に 返却 します。 + +```json +{ + "data": { + "Get": { + "Question": [ + { + "answer": "raccoons", + "question": "The crab-eating one of these masked animals eats fish, fruit & frogs, too" + } + ] + } + } +} +``` + +検索 オペレーター は `Aggregate` や `Explore` 関数 と 共 に も 使用 できます。これら は ベクトル 空間 を どの よう に 探索 する か を 指定 する 重要 な 入力 です。詳細 は この ユニット の 後半 で 取り上げ ます。 + +画像の alt + +### `NearObject` + +### `NearVector` + +## ベクトル 検索 の 理論 + +画像の alt + +### 距離 指標 + +## 復習 + +画像の alt + +### 復習 エクササイズ + +あなた 自身 の 言葉 で XXX を 説明 できます か? + +:::warning TODO +Input box for user to put answer in and get back a similarity score & our definition? +?? +::: + +### 重要 な ポイント + +:::info +概要 を 追加 +::: + +import Quiz from '/src/components/Academy/quiz.js' +const varName = [{ + questionText: 'questionText', + answerOptions: [ + { + answerText: 'answerOne', + isCorrect: false, + feedback: 'feedbackOne', + }, + { + answerText: 'answerTwo', + isCorrect: false, + feedback: 'feedbackTwo', + }, + { + answerText: 'answerThree', + isCorrect: false, + feedback: 'feedbackThree', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/vector_search.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/vector_search.mdx new file mode 100644 index 000000000..653861065 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_104_vectorization_essentials/vector_search.mdx @@ -0,0 +1,122 @@ +--- +title: ベクトル検索の概要 +sidebar_position: 20 +--- + +## ベクトル検索について + +:::warning TODO +導入動画はこちら +::: + +### ベクトル検索はどのように機能しますか? + +![](../../tmp_images/person_holding_a_magnifying_glass_in_front_of_a_big_pile_of_numbers_1.jpg) + +先ほど、ベクトルは単語の意味を表現できると述べました。また別のセクションでは、ベクトル検索が類似度ベースの検索を行う優れた方法であることも触れました。 + +これら 2 つのアイデアがどのように交差するか、もうお分かりでしょう。ベクトル検索は、意味の数値表現を利用して類似度ベースの検索を行います。2 つのベクトルが互いに近いほど、それらが表す単語の意味も似ています。 + +そのため、ベクトル検索ではベクトルベースのクエリオブジェクトをベクトルインデックスに渡し、インデックスはクエリオブジェクトに最も似た結果のリストを返します。 + +ベクトルインデックスは、テキストや画像などのオブジェクトを入力として受け取り、それをベクトルに変換する場合もあれば、クエリオブジェクトとして直接ベクトルを受け取る場合もあります。 + +### ベクトル類似度はどのように測定されますか? + +![](../../tmp_images/scale_of_justice_with_words_on_either_side_0.jpg) + +大まかに言うと、ベクトル類似度は各ベクトルを構成する数値の 2 組がどれだけ近いかを測定します。線形代数に詳しくない場合は、やや抽象的に聞こえるかもしれません。 + +しかし直感的には、2 つのベクトルが近いほど、それらが表す単語の意味も似ているということです。 + +実際には、ベクトル類似度を測定する方法は数多くあります。代表的な手法には次のようなものがあります。 +- コサイン類似度 +- ユークリッド距離 +- ドット積 +- マンハッタン距離 + +どの類似度指標を使うかはユースケースやモデルによって異なります。Weaviate では、特に指定がない限りデフォルトの指標は `cosine similarity` です。これらの選択肢については別のセクションで詳しく扱います。 + +## セマンティック検索とレキシカル検索 + +:::warning TODO +導入動画はこちら +::: + +### セマンティック検索とは? + +![](../../tmp_images/confused_people_looking_at_two_similar_piles_of_documents__1.jpg) + +「セマンティック」とは「意味に関連する」という意味です。言語学では「構文的 (syntactic)」—構造や文法に関する—と対比して使われます。したがって「セマンティック検索」とは、意味に基づいて行う検索を指します。 + +現在、セマンティック検索を行う主流の方法がベクトル検索です。ベクトルは単語、文、さらには文書全体の意味を効率的かつ高精度で捉えられるため、セマンティック検索に最適です。 + +「セマンティック検索」は、画像・音声・動画など他のメディアで表現される概念の類似度を探す検索を指す場合もあります。後ほど詳しく説明しますが、これらのメディアタイプでは、描写されている概念・オブジェクト・トーンといった特定の側面を比較します。 + +本コースでは特に断りがない限り、「セマンティック検索」と「ベクトル検索」を同義で用います。 + +### レキシカル検索とは? + +![](../../tmp_images/person_holding_a_magnifying_glass_in_front_of_a_big_pile_of_words_1.jpg) + +従来の検索システムは「レキシカル (lexical)」検索、つまりシステムやデータベースの「語彙」に基づく検索を採用してきました。 + +レキシカル検索は、文字列や部分文字列を正確にマッチさせ、各種演算子を用いて条件を満たす/満たさない情報セットを操作します。 + +例えば、レシピデータベースから材料に「chili」を含むオブジェクトを取得するのはレキシカル検索です。通常は複数の条件を組み合わせます。次のクエリは「chili」を含み、かつ 2010 年以降に追加されたエントリを検索します。 + +```sql +SELECT * FROM recipe_table WHERE (ingredients LIKE '%chili%') AND (entry_year > 2010) +``` + +この問い合わせは正確な答えを返しますが、柔軟性に欠けるという欠点があります。 + +たとえば、同義語である `ghost pepper` が使われているレシピは取得できません。また、エントリが `chilli` と誤綴りされていた場合など、タイプミスにも弱いです。 + +一方、セマンティック検索はこれらの問題をよりきめ細かく扱えます。 + +:::note Jargon ("lexical", "semantic", "syntactic") +専門用語は可能な限り避けていますが、必要な場合は説明を添えます。 + +ベクトル検索は *natural language processing* の分野に起源を持つため、*lexical* や *semantic* といった言語学由来の用語がよく使われます。*vector* は数学の世界から来た言葉です。🤓 +::: + +### ベクトル検索とレキシカル検索の比較 + +![](../../tmp_images/person_holding_a_magnifying_glass_in_front_of_a_big_pile_of_numbers_1.jpg) +![](../../tmp_images/person_holding_a_magnifying_glass_in_front_of_a_big_pile_of_words_1.jpg) + +レシピデータベースに対して材料 `chili` で検索した場合、レキシカル検索はデータ内にその単語が正確に含まれるエンティティのみを返します。 + +一方、ベクトル検索では `ghost pepper`、`jalapeno`、`habanero`、`carolina reaper` など、意味的に関連する用語を含むエンティティも結果に含めます。これらはレキシカル検索では無視されます。 + +さらに、最新のベクトル検索は単語が文中で持つコンテキストも考慮します。例えば、レシピがこれらの材料を「使用する」場合と「使用しない」よう指示している場合とを区別できます。 + +加えて、ベクトルデータベースはクエリと各結果との類似度を数値化できます。そのため、類似度という意味のある指標で結果をランキングでき、より関連性の高い結果を早く見つけやすくなります。 + + + + + +## 復習 + +:::warning TODO +動画はこちら +::: + +### 復習課題 + +あなた自身の言葉で、XXX を説明してみてください。 + +:::warning TODO +ユーザーが回答を入力し、類似度スコアと公式の定義を受け取れる入力ボックス? +?? +::: + +### 重要ポイント + +:::info +要約を追加 +::: + +import Quiz from '/src/components/Academy/quiz.js' \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_106_data_import/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_106_data_import/index.md new file mode 100644 index 000000000..cb9dac725 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_106_data_import/index.md @@ -0,0 +1,8 @@ +--- +title: 106 データインポート +sidebar_position: 106 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_107_crud_operations/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_107_crud_operations/index.md new file mode 100644 index 000000000..ccc34edd1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_107_crud_operations/index.md @@ -0,0 +1,8 @@ +--- +title: 107 CRUD 操作 +sidebar_position: 107 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_108_modules/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_108_modules/index.mdx new file mode 100644 index 000000000..f0c949ccf --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_108_modules/index.mdx @@ -0,0 +1,8 @@ +--- +title: 108 モジュール +sidebar_position: 108 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/102_arguments.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/102_arguments.mdx new file mode 100644 index 000000000..da1d12229 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/102_arguments.mdx @@ -0,0 +1,144 @@ +--- +title: 検索フィルター +--- + +:::tip ネストされたフィルター +`operands` 内に各項目をネストすることで、`where` フィルターも入れ子にできます。ぜひご自身で試すか、次の例をご覧ください。 + +
+ + ネストされた where フィルターの例 + + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer", "points"] +).with_limit(2).with_near_text( + {"concepts": "Intergalactic travel"} +).with_additional( + ["distance", "id"] +).with_where({ + "operator": "And", + "operands": [ + { + "path": ["question"], + "operator": "Like", + "valueText": "*rocket*" + }, + { + "operator": "Or", + "operands": [ + { + "path": ["points"], + "operator": "Equal", + "valueInt": 200 + }, + { + "path": ["points"], + "operator": "Equal", + "valueInt": 1000 + } + ] + } + ] +}).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion ( + limit: 2 + nearText: { + concepts: ["Intergalactic travel"], + } + where: { + operator: And, + operands: [ + { + path: ["question"], + operator: Like, + valueText: "*rocket*" + } + { + operator: Or, + operands: [ + { + path: ["points"], + operator: Equal, + valueInt: 200 + }, + { + path: ["points"], + operator: Equal, + valueInt: 1000 + } + ] + }, + ] + + } + ) { + question + answer + points + _additional { + distance + id + } + } + } +} +``` + + + + +
+ +結果は次のようになります: + +
+ JSON レスポンスを確認する + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "_additional": { + "distance": 0.18400955, + "id": "48fe1f8f-8e09-5aee-afe9-1728ab2fe8a0" + }, + "answer": "space shuttles", + "points": 200, + "question": "These transports, first sent up in 1981, lift off like a rocket & land like a plane" + }, + { + "_additional": { + "distance": 0.24946856, + "id": "c00decd4-4cf1-5b03-a789-a57077e082fb" + }, + "answer": "Huntsville", + "points": 1000, + "question": "A campus for the University of Alabama is here, nicknamed \"Rocket City, U.S.A.\"" + } + ] + } + } +} +``` + +
+ +::: \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/_graphql.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/_graphql.mdx new file mode 100644 index 000000000..90e9319e6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/_graphql.mdx @@ -0,0 +1,159 @@ +--- +title: GraphQL の詳細 +sidebar_position: 99 +--- + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +## GraphQL 概要 + +Image alt + +ここでは、なぜ Weaviate で GraphQL を使用するのか、そして GraphQL を使用する際に留意すべき点について少し立ち止まって説明します。 + +### クエリ構造 + +GraphQL の大きな利点の 1 つは、取得したいデータをユーザーが正確に指定できる点です。つまり、必要なデータだけをリクエストできるため、データの過剰取得や不足取得を抑えられます。 + +それでは、Weaviate における GraphQL の基本構文を確認しましょう。 + +```graphql +{ + { + { + + } + } +} +``` + +Weaviate の GraphQL クエリには複数のコンポーネントが含まれていることが分かります。Wikipedia 記事オブジェクトのデータベースを問い合わせる場合、上記クエリの各フィールドは次のようになります。 + +* ``: 使用したい関数。例: `Get`、`Aggregate`、`Explore` +* ``: データを取得したいクラス。例: `WikiArticle` +* ``: 取得したいプロパティ。例: `title`、`wiki_summary` + +各フィールドには `limit` で返却オブジェクト数を制限したり、`where` でフィルターを適用したりといった引数も渡せます。 + +GraphQL クエリにおけるデータフローは、次の図のように概念化できます。 + +![](https://kinsta.com/wp-content/uploads/2022/09/graphql.png) + +最初はこの詳細さが難しく感じるかもしれません。しかしこれは強力な機能であり、きわめてカスタマイズ性の高いクエリを構築し、必要なデータだけを取得できます。 + +さらに、REST API では複数回のリクエストが必要だった処理を、GraphQL では 1 回のクエリで実現できるため、非常に効率的です。 + +### クエリ構文 + +ほとんどの場合、GraphQL はフォーマットに関して非常に柔軟で、[空白](https://spec.graphql.org/October2021/#sec-White-Space) や [カンマ](https://spec.graphql.org/October2021/#sec-Insignificant-Commas) は通常無視されます。例えば、次のクエリはすべて同じ意味になります。 + +このクエリ: + +```graphql +{ + Get { + JeopardyQuestion (limit: 1) { + question + answer + } + } +} +``` + +次のクエリと同じです: + +```graphql +{Get{JeopardyQuestion(limit:1){question answer}}} +``` + +さらに次のようにも書けます(カンマに注目してください): + +```graphql +{Get{JeopardyQuestion(limit:1){question,answer}}} +``` + +ただし重要な点として、GraphQL の名前は [大文字小文字を区別します](https://spec.graphql.org/October2021/#sec-Names)。そのため `Get` や `JeopardyQuestion` は、`get` や `jeopardyquestion` とは別物になります。 + + + + + +## 復習 + +Image alt + +各セクションには 1 分程度の短いリキャップ/復習ビデオを用意する予定です。 + +### 復習演習 + +**構想中のセクションです。** ユーザーが自由形式の入力を行い、類似度スコアと当社の定義を返すようにしたいと考えています。 + +:::info TODO +あなた自身の文章で XXX を説明できますか? + +Input box -> ベクトライザー -> model answer と比較 +::: + +### 重要なポイント + +:::info +要約を追加 +::: + +import Quiz from '/src/components/Academy/quiz.js' +const graphQLSyntax = [{ + questionText: 'GraphQL について正しいものはどれですか?', + answerOptions: [ + { + answerText: '大文字小文字を区別しない。', + isCorrect: false, + feedback: 'GraphQL は大文字小文字を区別します。', + }, + { + answerText: '空白は通常無視される。', + isCorrect: true, + feedback: 'これはカンマについても同様です。', + }, + { + answerText: 'GraphQL は常に同じフィールドをレスポンスに含める。', + isCorrect: false, + feedback: '以前の Get クエリで確認したとおり、GraphQL では返却フィールドを指定する必要があります。', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/_leftovers.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/_leftovers.mdx new file mode 100644 index 000000000..f50d4ee3f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/_leftovers.mdx @@ -0,0 +1,530 @@ +## 102 + +--- +title: クエリの概要 +sidebar_position: 10 +--- + +import imageUrl from '../../tmp_images/academy_placeholder.jpg'; + +## Weaviate クエリの実行 + +Image alt + +このユニットでは、情報を取得するために Weaviate でクエリを実行するさまざまな方法に焦点を当てます。 + +### Python クライアントを使用する + +Weaviate は内部的にはクエリに GraphQL を使用しますが、このユニットで直接 GraphQL を入力する必要はありません。代わりに、Python クライアントを使ってクエリを実行し、その仕組みを学びます。 + +ただし、基礎となるクエリ構造を理解しやすくするため、このユニットでは Python コードとともに生の GraphQL クエリも示します。 + +したがって、次のようなクエリを示したときには、 + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_near_text( + {"concepts": ["intergalactic travel"]} +).with_limit(2).do() + +print(json.dumps(response, indent=2)) +``` + +内部的にはこのように動作しています。 + +```graphql +{ + Get { + JeopardyQuestion ( + nearText: { + concepts: ["intergalactic travel"] + } + limit: 2 + ) { + question + answer + } + } +} +``` + +今後は、該当する場合は次のようにタブで分けて表示します。 + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +This tab will show Python code. +``` + + + + +```graphql +This tab will show GraphQL code. +``` + + + + +### 生の GraphQL クエリ + +Weaviate の Python クライアントは、生の GraphQL クエリを実行できます。また、[Weaviate Query app](/cloud/tools/query-tool) を使用することも可能です。 + +Python では、次のようにして GraphQL クエリを直接実行できます。 + +```python +query = ''' +{ + Get { + JeopardyQuestion ( + nearText: { + concepts: ["intergalactic travel"] + } + limit: 2 + ) { + question + answer + } + } +} +''' + +response = client.query.raw(query) +print(json.dumps(response, indent=2)) +``` + +あるいは、Weaviate Console というグラフィカルインターフェースを使用して Weaviate インスタンスに接続し、クエリを実行することもできます。 + + + +### GraphQL 構文 + +このユニットでは `Function`、`Class`、`properties`、`Argument` などの用語が登場します。これらは Weaviate の GraphQL 構文に由来し、次の形式を取ります。 + +```graphql +{ + { + () { + + } + } +} +``` + +ここで +- `` はアクション、 +- `` は対象データコレクション、 +- `` はオプションを指定し、 +- `` は取得するデータを表します。 + +これらの用語を覚えておいてください。 + + + +## クエリ関数 + +Image alt + +Weaviate の主なクエリ関数は `Get`、`Aggregate`、`Explore` です。 + +これら 3 つの関数は、それぞれオブジェクトを `Get` し、情報を `Aggregate` し、ベクトル空間を `Explore` します。 + +以下では詳細を学ぶ前に、それぞれを簡単に確認しましょう。 + +### `Get` オブジェクト + +`Get` 関数は Weaviate でデータオブジェクトを取得するために使用します。多くのユースケースでは、`Get` が最も一般的に利用されるクエリ関数となります。 + +次をご覧ください。 + + + + +```python +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_limit(1).do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Get { + JeopardyQuestion (limit: 1) { + question + answer + } + } +} +``` + + + +これは `JeopardyQuestion` クラスに対する `Get` クエリで、最大 `1` 件のオブジェクトを返し、そのオブジェクトの `["question", "answer"]` プロパティを取得します。 + +結果は次のようなレスポンスになります。 + +```json +{ + "data": { + "Get": { + "JeopardyQuestion": [ + { + "answer": "Amazon.com", + "question": "On July 16, 1995 this company made its first sale, a science textbook" + } + ] + } + } +} +``` + +レスポンスには `JeopardyQuestion` クラスから取得したデータオブジェクトと、その `question` および `answer` プロパティの値が含まれていることが確認できます。 + + +================= + +`groupBy` 引数があることに注目してください。 + +`groupBy` はクエリ結果をグループ化するための任意引数です。`Aggregate` 関数は、各グループの結果数などのメタデータも返すことができます。 + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + + + + +```python +response = client.query.aggregate( + , +).with_group_by_filter( + +).with_fields( + "groupedBy {path value}" # requires `groupBy` argument + +).with_meta_count( # optional +)..do() +``` + + + + +```graphql +{ + Aggregate (groupBy:[]) { # `groupBy`: optional argument + groupedBy { # requires `groupBy` argument + path + value + } + meta { # optional + count + } + ( + + ) { + + } + } +} +``` + + + +### `Aggregate` 情報 + +`Get` がオブジェクトを返すのに対し、 `Aggregate` は結果セットの要約統計量、つまり集計値を返します。 + +このため、 `Aggregate` を使用すると、オブジェクトのグループから件数、合計、平均などの要約値を取得できます。次の例をご覧ください。 + + + + +```python +response = client.query.aggregate( + "JeopardyQuestion", +).with_near_text( + {"concepts": ["Animals in movies"]} +).with_object_limit( + 10 +).with_meta_count().with_fields("value {maximum minimum mean}").do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Aggregate { + JeopardyQuestion ( + objectLimit: 10 + nearText: { + concepts: ["Animals in movies"] + } + ) { + meta { + count + } + points { + maximum + minimum + mean + } + } + } +} +``` + + + + +先ほどのクエリは、 `JeopardyQuestion` クラスからクエリテキストに最も近い 10 件 のオブジェクトを取得し、 `value` の最大値・最小値・平均値と件数を返します。 + +結果は次のようになります。 + +```json +{ + "data": { + "Aggregate": { + "JeopardyQuestion": [ + { + "meta": { + "count": 10 + }, + "points": { + "maximum": 1000, + "mean": 320, + "minimum": 0 + } + } + ] + } + } +} +``` + +最大で 10 件 のオブジェクトを対象にしたクエリであっても、返されるのは 1 つの集計結果セットである点に注目してください。 + +### `Explore` ベクトル空間 + +`Explore` を使うと、 Weaviate に保存されているオブジェクトの ベクトル 空間全体を探索できます。 + +つまり、 `Explore` を使用すれば、対象のクラスに関係なく、指定したオブジェクトまたは ベクトル に類似するオブジェクトを検索できます。したがって、検索すべきクラスがはっきりしていない場合に `Explore` は非常に便利です。 + +本データセットに当てはめると、 `Explore` 関数によるクエリは `JeopardyQuestion` クラスと `Category` クラスの両方からオブジェクトを返します。 + +`Explore` 関数については、後続のユニットでさらに詳しく学習します。 + + + +## レビュー + +Image alt + +### レビュー演習 + +あなた自身の言葉で XXX を説明できますか? + +:::warning TODO +ユーザーが回答を入力し、類似度スコアと私たちの定義を受け取る入力ボックス? +?? +::: + + + +## `Aggregate` のサブプロパティ + +これまでに見たように、すべてのデータ型で `meta` プロパティが使用でき、 `count` サブプロパティと組み合わせて取得したオブジェクト数を返せます。 + +これに加えて、 `Aggregate` クエリで使用できるサブプロパティはいくつもあります。ただし、それらが利用できるかどうかは、集計対象のデータ型によって異なります。 + +`Question` クラスを例に、これらのサブプロパティの一部を見てみましょう。 + +### 例 + +次のクエリを試してみてください。 + + + + +```python +response = client.query.aggregate( + "JeopardyQuestion", +).with_fields( + "round {type topOccurrences {value occurs}}" +).with_near_text( + {"concepts": ["Intergalactic travel"]} +).with_object_limit(10).with_meta_count().do() + +print(json.dumps(response, indent=2)) +``` + + + + +```graphql +{ + Aggregate { + JeopardyQuestion ( + nearText: { + concepts: ["Intergalactic travel"], + distance: 0.2 + } + ) { + meta { + count + } + round { + type + topOccurrences { + value + occurs + } + } + } + } +} +``` + + + + +GraphQL クエリで要求しているプロパティに注目し、それぞれがどのような値を返すのか考えてみましょう。ソースデータの性質によって、これらのプロパティはどのように変化するでしょうか。 + +では実際に実行してみましょう。クエリは次のような結果を返すはずです。 + +
+ JSON レスポンスを表示 + +```json +{ + "data": { + "Aggregate": { + "JeopardyQuestion": [ + { + "meta": { + "count": 10 + }, + "round": { + "topOccurrences": [ + { + "occurs": 5, + "value": "Double Jeopardy!" + }, + { + "occurs": 4, + "value": "Jeopardy!" + }, + { + "occurs": 1, + "value": "Final Jeopardy!" + } + ], + "type": "text" + } + } + ] + } + } +} +``` + +
+ +
+ このクエリの説明 + +このクエリでは、 `round` の下にサブプロパティを指定して追加の集計を行い、最も頻出する回答とその件数を取得しています。 + +
+ +### 利用可能なサブプロパティ + +サブプロパティを使用すると、 Weaviate のデータをより細かく集計できます。クエリで指定できるサブプロパティは、集計対象のデータ型によって異なります。 + +`string` データ型と同様に、 `text` プロパティでは次のいずれか、または複数を取得できます。 + +- count +- type +- topOccurrences + +一方、たとえば `int` データ型の場合は、次の情報を集計できます。 + +- count +- type +- minimum +- maximum +- mean +- median +- mode +- sum + +:::note Exercise +上記のクエリを次のように変更して再度試してみてください。 +- `answer` プロパティのデータを基に集計できますか? +- 結果を `round` でグループ化し、 `answer` から topOccurrences を集計してみましょう。 +::: + +:::info +サマリーを追加 +::: + +import Quiz from '/src/components/Academy/quiz.js' +const queryMethods = [{ + questionText: 'Which of these is not a valid way of running queries with Weaviate?', + answerOptions: [ + { + answerText: 'Sending a HTTP GET request.', + isCorrect: true, + feedback: 'In Weaviate, the REST interface is not used for queries.', + }, + { + answerText: 'Using the Weaviate Console.', + isCorrect: false, + feedback: 'You can use the Weaviate Console to directly enter GraphQL queries', + }, + { + answerText: 'With the Weaviate Python client.', + isCorrect: false, + feedback: 'In fact, you can send raw GraphQL queries or use native Python methods to perform queries with the Python client.', + }, + ] +}]; +const functionExplanations = [{ + questionText: 'Which of the following are correct?', + answerOptions: [ + { + answerText: 'You can use the Get function to retrieve summary information about a group of objects.', + isCorrect: false, + feedback: 'The Get function is used to retrieve individual objects.', + }, + { + answerText: 'The Aggregate function will return objects from Weaviate.', + isCorrect: false, + feedback: 'The Aggregate function will return summary, or aggregated, information about retrieved objects.', + }, + { + answerText: 'The Get function can retrieve objects from multiple classes in one query.', + isCorrect: false, + feedback: 'Each Get query can only search one class of objects.', + }, + { + answerText: 'None of the above.', + isCorrect: true, + feedback: 'All of the above are false!', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/tmp.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/tmp.mdx new file mode 100644 index 000000000..4616606b0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_109_tmp_leftovers/tmp.mdx @@ -0,0 +1,77 @@ +# その他の情報 + +### クロスリファレンス付き `Get` + +このセクションを締めくくる前に、クロスリファレンスを利用した `Get` クエリの実行方法を見てみましょう。本ユニットではまだクロスリファレンスを詳しく扱っていませんが、ここではオブジェクト同士を接続する手段であることだけ理解していれば十分です。 + +以下の例では、`Question` クラスに対して `Get` クエリを実行しますが、今回は `hasCategory` プロパティもクエリに含めます。このプロパティは `Category` クラスへのクロスリファレンスであり、各質問のカテゴリを返すために使用されます。 + +```graphql +{ + Get { + Question ( + limit: 1 + nearText: { + concepts: ["Seafaring technology from Scandanavia."], + } + ) { + question + answer + hasCategory { + ... on Category { + title + _additional { + id + } + } + } + _additional { + distance + id + } + } + } +} +``` + +これにより、次のような結果が得られます。 + +
+ Query results + +```json +{ + "data": { + "Get": { + "Question": [ + { + "_additional": { + "distance": 0.14927602, + "id": "5d9d5c8d-13e7-5791-b2f9-3724a1a1d301" + }, + "answer": "Oslo", + "hasCategory": [ + { + "_additional": { + "id": "fec50326-dfa1-53c9-90e8-63d0240bd933" + }, + "title": "MUSEUMS" + } + ], + "question": "1,200-year-old Viking ships are on display at the Vikingskiphuset in this Norwegian capital" + } + ] + } + } +} +``` + +
+ +ここでは、`hasCategory` プロパティがオブジェクトの配列となっており、`Question` が関連付けられている `Category` 型のオブジェクトと、その要求したプロパティが格納されています。また、`Category` クラスの `title` プロパティも返され、`_additional` フィールドにはカテゴリの `id` が含まれます。 + +クロスリファレンスを使用すると、データモデルに高い柔軟性と強力な表現力を持たせることができ、オブジェクト同士を接続する優れた方法となります。スキーマに関するユニットで、これらについてさらに詳しく説明します。 + +:::info `...` pattern +上記のクエリで `... on Category` というパターンにお気付きかもしれません。この構文は GraphQL の用語で「フラグメント」と呼ばれます。このように記述することで、フラグメントは `hasCategory` プロパティが `Category` 型であることを示し、その形式で結果を返すよう指定しています。 +::: \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/combining_models.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/combining_models.md new file mode 100644 index 000000000..a0455d898 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/combining_models.md @@ -0,0 +1,12 @@ +--- +title: モデルの組み合わせ +sidebar_position: 3 +--- + +こちらの Slack ディスカッションに触発されました: https://weaviate.slack.com/archives/C017EG2SL3H/p1677534406507339 + +- 生成検索 + ベクトライザー のようなケースでモデルを組み合わせる方法 + +- CLIP + Q&A + +などなど \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/common_model_types.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/common_model_types.md new file mode 100644 index 000000000..b65ef8db5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/common_model_types.md @@ -0,0 +1,100 @@ +--- +title: 一般的なモデルタイプ +sidebar_position: 2 +--- + +## ベクトル表現の種類 + +:::warning TODO +イントロ動画はこちら +::: + +ここでいうベクトルとは、通常、機械学習モデルから生成されたベクトルを指します。より具体的には、ニューラルネットワークから得られる「 dense ベクトル」と呼ばれるベクトルを指します。 + +しかし、特にテキストの意味を表す際には、他にも次のようなベクトル表現があります。 + +- One-hot encoding +- TF-IDF ( term frequency-inverse document frequency ) ベクトル +- BM25 ベクトル + +以下では、これらと dense ベクトルについて簡単に説明します。 + +### One-hot encoding + +One-hot encoding では、テキストを 0 と 1 の集合で表現し、1 はその単語がテキスト内に存在することを示します。これは「 bag of words 」表現とも呼ばれることがあります。 + +そのため、この表現は大部分が 0 になる非常にスパースなベクトルになります。これは、ほとんどの単語が特定のテキストには存在しないためです。 + +この方法の制限として、各単語は「存在する/しない」のみで表されるため、単語間の類似性を捉えられません。また、テキスト内での単語の相対的重要性を考慮できません。 + +### TF-IDF ベクトル + +TF-IDF 表現は、テキスト内での単語の相対的重要性を考慮することで One-hot encoding を改良したものです。 + +TF-IDF は「 term frequency-inverse document frequency 」の略で、コーパス内の文書において単語がどれほど重要かを示す統計量です。 + +TF-IDF の値は、その単語が文書内に出現する回数に比例して増加しますが、コーパス全体での単語の出現頻度によって調整されます。これにより、"the"、"a"、"is"、"are" のような全文書で頻出する単語は減点され、全体でまれな単語に高い重みが付きます。 + +直感的には、TF-IDF はまれな単語により大きな重みを与えることで、テキスト内での単語の相対的重要性を捉えます。 + +### BM25 ベクトル + +BM25 ベクトルは TF-IDF ベクトルに似ていますが、文書の長さを考慮できる点が異なります。長い文書は単語数が多くなるため、それだけで TF-IDF スコアが高くなる可能性がありますが、必ずしも短い文書より関連性が高いとは限りません。 + +そのため、BM25 ベクトルは文書の長さで TF-IDF スコアを正規化します。 + +### Dense ベクトル + +#### Word ベクトル + +Word ベクトルはニューラルネットワークから得られるベクトル表現の一種で、単語が現れる文脈を学習することで単語の意味を捉えます。 + +" word2vec " や " GloVe " といったモデルが、この種の表現学習を一般化しました。Word ベクトルの主な欠点は、親文のローカルな文脈、つまり文中での単語の使われ方を考慮できないことです。 + +そのため、同音異義語のように語義の判別が必要な場合、Word ベクトルは文脈内での単語の意味を捉えられません(たとえば "bank" が金融機関なのか川岸なのか)。 + +:::note Word vectors + weighting +Word ベクトルに TF-IDF や BM25 のような重み付け手法を組み合わせることで、テキスト内での単語の相対的重要性を反映したベクトルを生成できます。得られたベクトルはテキスト全体の表現として利用できます。 +::: + +#### Transformer 由来のベクトル + +現在の多くのベクトルデータベースは、Transformer モデルから得られたベクトルを使用しています。 + +Transformer はニューラルネットワークの一種で、親文の文脈を考慮して単語の意味を決定します。これにより、前述の "bank" の例のように複数の意味を持つ単語を文脈に応じて判別できます。 + +現在の主な課題は、入力サイズ(例: テキスト長)が大きくなるにつれて計算資源を多く消費することです。 + + + + + +## メディアタイプ別 + +## テキストベクトライザーの種類 + +## マルチメディアベクトライザー + +import Quiz from '/src/components/Academy/quiz.js' +const sparseOrDense = [ + { + questionText: 'From the folloowing, select the correct statement about sparse and dense vectors.', + answerOptions: [ + { answerText: 'One-hot encoding & word vectors: sparse, Transformer-derived: dense.', isCorrect: false, feedback: 'Word vectors are not sparse.'}, + { answerText: 'Document vector generated from BM25-weighted word vectors: sparse.', isCorrect: false, feedback: 'Word vectors are dense. Accordingly, a document vector generated by weighting BM25 scores are also dense.'}, + { answerText: 'One-hot encoding: sparse, TF-IDF based bag of words: dense.', isCorrect: false, feedback: 'Bag-of-words vectors are sparse. Accordingly, a vector that is based on TF-IDF weighting is also sparse.'}, + { answerText: 'One-hot encoding: sparse, Word vectors & transformer-derived: dense.', isCorrect: true, feedback: 'This is the only correct answer.'}, + ], + }, +]; +const wordVecVsTransformer = [ + { + questionText: 'Select the correct statement.', + answerOptions: [ + { answerText: 'One-hot encoding & word vectors: sparse, Transformer-derived: dense.', isCorrect: false, feedback: 'Word vectors are not sparse.'}, + { answerText: 'Document vector generated from BM25-weighted word vectors: sparse.', isCorrect: false, feedback: 'Word vectors are dense. Accordingly, a document vector generated by weighting BM25 scores are also dense.'}, + { answerText: 'One-hot encoding: sparse, TF-IDF based bag of words: dense.', isCorrect: false, feedback: 'Bag-of-words vectors are sparse. Accordingly, a vector that is based on TF-IDF weighting is also sparse.'}, + { answerText: 'One-hot encoding: sparse, Word vectors & transformer-derived: dense.', isCorrect: true, feedback: 'This is the only correct answer.'}, + ], + }, +]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/index.mdx new file mode 100644 index 000000000..dce1b62ef --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_999_vectorizer_selection_1/index.mdx @@ -0,0 +1,8 @@ +--- +title: 105 ベクトライザー選択 1 +sidebar_position: 105 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_snippets/deprecation.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_snippets/deprecation.md new file mode 100644 index 000000000..f0143aa4c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_snippets/deprecation.md @@ -0,0 +1,5 @@ +:::info +このコースは Weaviate Python クライアント API ( `v3` )向けに作成されたもので、現在は非推奨です。 + +Weaviate を初めてご利用になる場合は、`v4` クライアント API で作成された 100 レベル コースのうち、[テキストデータ](/academy/py/starter_text_data/index.md)、[独自の ベクトル](/academy/py/starter_custom_vectors/index.md)、または [マルチモーダルデータ](/academy/py/starter_multimodal_data/index.md) を扱うコースから始めることをお勧めします。 +::: \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_snippets/setup.py b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_snippets/setup.py new file mode 100644 index 000000000..5dbd6853b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/_snippets/setup.py @@ -0,0 +1,87 @@ +# ===== Basic instantiation ===== +import weaviate +import os + +client = weaviate.Client( + url="https://edu-demo.weaviate.network", + auth_client_secret=weaviate.auth.AuthApiKey(api_key="learn-weaviate"), # A read-only API Key for the Weaviate instance +) + +print(client.is_ready()) # This should return `True` +# ===== END Basic instantiation ===== +assert client.is_ready() + +# ===== Instantiate to edu-demo with OpenAI ===== +import weaviate + +client = weaviate.Client( + url="https://edu-demo.weaviate.network", + auth_client_secret=weaviate.auth.AuthApiKey(api_key="learn-weaviate"), # A read-only API Key for the Weaviate instance + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY" # Replace with your OPENAI API key + } +) +# ===== END Instantiate to edu-demo with OpenAI ===== +assert client.is_ready() + +# ===== Arbitrary code example ===== +import json + +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_near_text( + {"concepts": ["intergalactic travel"]} +).with_limit(2).do() + +print(json.dumps(response, indent=2)) +# ===== END Arbitrary code example ===== +assert len(response["data"]["Get"]["JeopardyQuestion"][0]) == 2 + +# ===== Fuller arbitrary code example ===== +import weaviate +import json + +client = weaviate.Client( + url="https://edu-demo.weaviate.network", + auth_client_secret=weaviate.auth.AuthApiKey(api_key="learn-weaviate"), # A read-only API Key for the Weaviate instance + additional_headers={ + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY" # Replace with your OPENAI API key + } +) + +response = client.query.get( + "JeopardyQuestion", + ["question", "answer"] +).with_near_text( + {"concepts": ["intergalactic travel"]} +).with_limit(2).do() + +print(json.dumps(response, indent=2)) +# ===== END Fuller arbitrary code example ===== +assert len(response["data"]["Get"]["JeopardyQuestion"][0]) == 2 + +# ===== GraphQL example with Python execution ===== +gql_query = """ +# ===== Equivalent GraphQL example ===== +{ + Get { + JeopardyQuestion ( + nearText: { + concepts: ["intergalactic travel"] + } + limit: 2 + ) { + question + answer + } + } +} +# ===== END Equivalent GraphQL example ===== +""" + +gql_response = client.query.raw(gql_query) +print(json.dumps(gql_response, indent=2)) +# ===== END GraphQL example with Python execution ===== + +assert response == gql_response diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/index.md new file mode 100644 index 000000000..cb0094c57 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/index.md @@ -0,0 +1,28 @@ +--- +title: (v3) ゼロから MVP +description: セットアップ、データクエリ、スキーマを含め、ゼロから Weaviate の MVP を構築します。 +--- + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; +import CourseUnits from '/src/components/Academy/courseUnits.jsx'; +import { courseData } from '/src/components/Academy/courseData.js' + +## コース概要 + +import ZeroToMvpDeprecationNote from '/docs/academy/py/zero_to_mvp/_snippets/deprecation.md'; + + + +このコースは、 Weaviate の利用を開始し、 Weaviate 初心者から短時間で Weaviate を用いた MVP レベルのプロダクトを構築できるようになることを目的としています。 + +その過程で、 Weaviate の仕組みだけでなく、ベクトルの仕組みやベクトル検索の動作についての直感も身に付けられます。また、慣れ親しんだ言語で操作できるよう、 Weaviate のクライアントライブラリの使い方も学びます。 + +これらの短いユニットを終える頃には、ご自身のデータで Weaviate のインスタンスを構築し、求めるデータを望む形式で取得できる検索ツール一式を自由に使えるようになっています。 + +## 学習目標 + + + +## ユニット + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/setup.mdx new file mode 100644 index 000000000..908cc2043 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/py/zero_to_mvp/setup.mdx @@ -0,0 +1,192 @@ +--- +title: P3_101A Weaviate Academy 事前準備 +description: Weaviate をゼロからセットアップし、最初のプロジェクトを構築しましょう。 +sidebar_position: 101.5 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import PythonCodeExample from '!!raw-loader!./_snippets/setup.py'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; + +import ZeroToMvpDeprecationNote from '/docs/academy/py/zero_to_mvp/_snippets/deprecation.md'; + + + +## 概要 + +この短いガイドに従って、Python クライアントで Weaviate を使用するための環境を整えましょう。 + + + +## Python と Python クライアント + +まだ Python と Weaviate Python クライアントをセットアップしていない場合は、以下の手順に従ってください。 + +### Python のインストール + +Python 3 はさまざまな方法でインストールできます。簡単な方法の一つは、[Python.org](https://www.python.org/downloads/) の手順に従ってお使いのシステム向けインストーラーを利用することです。 + +### Weaviate クライアントのインストール + +:::tip 仮想環境 +プロジェクトを分離するために仮想環境を使用することがベストプラクティスです。 + +仮想環境に馴染みがない場合は、ぜひ学習してください。概要をつかむには [FreeCodeCamp](https://www.freecodecamp.org/news/how-to-setup-virtual-environments-in-python/) のチュートリアル、より詳しく学ぶには [RealPython](https://realpython.com/python-virtual-environments-a-primer/) の記事がおすすめです。 +::: + +次のライブラリも必要です。 + +``` +weaviate-client +``` + +仮想環境をアクティベートし、以下のコマンドで Weaviate クライアントをインストールします。 + +```shell +pip install weaviate-client +``` + +### Python コードの実行 + +Python コードは Jupyter Notebook で実行することを推奨します。ライブラリは次のコマンドでインストールできます。 + +```shell +pip install notebook +``` + +その後、表示されているコードを Jupyter Notebook で実行してください。もちろん、お好みの方法で実行しても構いません。 + +:::tip Jupyter が初めてですか? +Jupyter Notebook の使い方を学ぶには、[こちらのチュートリアル](https://realpython.com/jupyter-notebook-introduction/) をご覧ください。 +::: + +## Weaviate + +### インスタンスへのアクセス + +本コースでは、`https://edu-demo.weaviate.network` に用意された Weaviate インスタンスを使用します。 + +読み取り専用の Weaviate API キーでこのインスタンスに接続できます。 + +以下のコードを Python 環境で実行できることを確認してください。 + + + +すべてが正しく設定されていれば、`True` が返されます。 + +### 推論 API キー + +OpenAI の API を利用するため、API キーが必要です。 + +まだお持ちでない場合は OpenAI アカウントを作成し、[こちら](https://platform.openai.com/api-keys) から無料の API キーを作成してください。 + +続いて、下記のようにクライアントをインスタンス化します。`YOUR-OPENAI-API-KEY` をご自身の OpenAI API キーに置き換えてください。 + + + +## コード例 + +### クライアントのインスタンス化 + +簡潔さのため、Weaviate Academy の多くのコード例ではクライアントのインスタンス化を省略しています。そのため、次のような例が表示された場合: + + + +前セクションで示した方法でクライアントをインスタンス化する必要があります。つまり、上記のコードは次のようになります。 + + + +### GraphQL + +Weaviate Academy のユニットは Python などのクライアントライブラリで使用することを前提としています。そのため、GraphQL や REST クエリを直接実行する必要はありません。 + +ただし、基礎となるクエリ構造を学べるよう、必要に応じて生の GraphQL/REST クエリと対応する Python コードの両方を示します。 + +したがって、次のようなクエリを示す場合: + + + +実際には裏側で以下が実行されています。 + + + +今後は、必要に応じて次のようにタブで分けて表示します。 + + + + +```python +This tab will show Python code. +``` + + + + +```graphql +This tab will show GraphQL code. +``` + + + +### 生の GraphQL クエリ + +Weaviate Python クライアントは、生の GraphQL クエリを実行できます。 +さらに、[Weaviate Query app](/cloud/tools/query-tool) も利用できます。 + +Python では、次のようにして GraphQL クエリを直接実行できます。 + + + + + + + +### 重要なポイント + +- ご利用の環境に Weaviate クライアント ライブラリをインストール済みです。 +- OpenAI 推論キーをお持ちです。 +- Python コードを実行できる環境があること。 +- Weaviate Python クライアントをインスタンス化し、例のコードを実行する方法を理解しています。 +- Academy の各ユニットでは Python コードに加えて、必要に応じて生の GraphQL や REST スニペットも示します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/10_introduction.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/10_introduction.mdx new file mode 100644 index 000000000..251af8c3f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/10_introduction.mdx @@ -0,0 +1,99 @@ +--- +title: 概要 +description: AI モデルの概要 +--- + +## AI モデルの使用例 + +私たちは、 AI モデルがこれまで人間にしかできないと考えられていたタスクに取り組めることを知っています。いくつか具体的な例を見てみましょう。 + +### 画像生成 + + AI モデルは、あなたのテキスト記述に合わせて、想像どおりの画像を生成できます。 + +
+ +| プロンプト | 生成された画像 | +| --- | --- | +| `a sleek looking robot cowboy riding on a big, cute, cartoon unicorn, on the moon.` | ![月面で大きくてかわいいアニメ風ユニコーンに乗るスタイリッシュなロボットカウボーイ](./_img/10_generated_unicorn.png) | + +
OpenAI の AI モデル DALL-E によって生成された画像
+
+ +### 言語理解 + +彼らは、大きな話題から小さな話題まで、私たちと対話することもできます。 + +
+ +| AI との技術的な会話 | AI とのカジュアルな会話 | +| --- | --- | +| ![AI モデル Claude と AI モデルについて議論する会話](./_img/10_chat_example_1.png) | ![AI モデル Claude とユニコーンについての会話](./_img/10_chat_example_2.png) | + +
Anthropic の AI モデル claude との会話
+
+ +### コード補完 + +実際、多くの人がすでに日々のワークフローで、コードのような複雑なタスクですら、これらを相棒として利用しています。 + +
+ +![Copilot の例](./_img/10_copilot_example.png) + +
VSCode で Microsoft Copilot を使用
+
+ +### 表: AI モデルの種類 + +以下は、入力と出力形式をまとめ、具体例を添えた AI モデルのより広い概要です。 + +
+ +| 種類 | 入力 | 出力形式 | 出力の意味 | モデル / 利用例 | 入力例 | 出力例 | +| --- | --- | --- | --- | --- | --- | --- | +| 大規模(またはビジョン)言語モデル | テキスト(または テキスト + 画像) | テキスト | 入力テキストへの回答 | claude-3-7-sonnet, gemini-2.0 | フランスの首都はどこですか? | フランスの首都はパリです | +| 画像生成モデル | テキスト | 画像 | 入力内容の画像化 | Stable diffusion, Dall-E | かわいい赤い犬の画像 | ![犬の画像](./_img/10_cute_dog.png) | +| 埋め込みモデル | テキスト | 数値配列 | 意味を数値的に捉える | Word2vec, sentence-transformers | かわいい赤い犬の画像 | [0.0149, 0.8932, …, 0.0589] | +| 画像分類器 | 画像 | 数値配列 | カテゴリの確率 | ResNet, 疾病検出モデル | ![犬の画像](./_img/10_cute_dog.png) | [0.958, 0.042] | +| 回帰モデル | 数値 | 数値 | 数値予測 | 住宅価格予測, 電力需要予測 | [4, 950, 1985, 2010, 10011, 0] | 2585913 | + +
AI モデルの概要
+
+ +## AI モデルは人間のように思考するか + +今日では、 AI モデルはこれらの驚くべきタスク(そしてそれ以上)を、人間レベルの質と驚異的な速度で実行できます。しかし、 AI モデルは重要な点で人間とは大きく異なります。 + + AI は統計を「大好物」としています。より正確に言えば、統計の魔法だけで動いています。 + +本質的に、 AI モデルは統計を利用して、さまざまな種類の入力を出力へと変換します。内部について説明する前に、 AI モデルの仕事を(非常に複雑な)パターンマッチングだと考えると良いかもしれません。そのため、 大規模言語モデルを [確率論的オウム](https://en.wikipedia.org/wiki/Stochastic_parrot) と表現する人もいます。 + +とはいえ、彼らが非常に優れたツールであることに疑いはありません。そして、これらのモデルを最大限に活用するには、内部をある程度理解しておくと役に立ちます。 + +## AI モデルとは + + AI モデルの世界を探索し始めると、たくさんの専門用語に出会います。最上位のレベルですら、「機械学習」「深層学習」「ニューラルネットワーク」、そして本書で使用している「 AI モデル」などの用語を耳にするでしょう。 + +それでは、これらの違いは何でしょうか。以下のように捉えることができます。 + +- **人工知能 (AI)** は、機械が人間の知能を模倣できるようにするあらゆる技術を包括する幅広い用語です。 +- **機械学習 (ML)** は、 AI システムを構築するための特定の手法です。 ML システムはルールベースではなく、データから学習してパターンを見つけ出し、その予測能力を得ます。 +- **深層学習 (DL)** は、 多層(つまり「深い」)の人工ニューラルネットワークに基づく機械学習の一分野です。コンピュータビジョンや自然言語処理など、近年の AI モデルの多くは深層学習モデルによって実現されています。 +- **ニューラルネットワーク (NN)** は、深層学習モデルのアーキテクチャを指します。相互接続されたノード(ニューロン)の層で構成され、情報をネットワーク内で処理してから回答を生成します。 + +ご覧のとおり、これらは技術的な具体性や深さが異なります。本コースでは「 AI モデル」を総称として使います。 ML、 DL、 NN は、 AI 機能を提供するための具体的なツールと考えてください。 + +本書の文脈で最も一般的に使用する AI モデルは、生成モデルと埋め込みモデルです。生成モデルは情報を分析・変換するのに役立ち、埋め込みモデルは分析・変換するために最適な文脈情報を検索するのに役立ちます。(注:これらのモデルはほとんどの場合、深層学習モデルです。) + +しかし、この単純さに惑わされないでください。同じモデルタイプ内でも非常に多くの微妙な違いがあり、開発者としては多くの落とし穴があります。 + +つまり、正しく扱えば、大きなチャンスがあるということです。まもなく、これらのモデルタイプ(そして遭遇するかもしれないその他のモデル)を詳しく見ていきます。 + +それでも、これらのモデルには共通点も多く存在します。これから、そのいくつかの側面を見ていきましょう。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/20_inside_ai_models.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/20_inside_ai_models.mdx new file mode 100644 index 000000000..830f39b4d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/20_inside_ai_models.mdx @@ -0,0 +1,142 @@ +--- +title: 一般的な AI モデル +description: AI モデルの内部を覗く +--- + +import ThemedImage from '@theme/ThemedImage'; + +現代の AI モデルの大部分はディープラーニングモデルです。多くの生成モデルや埋め込みモデルがこのカテゴリに含まれ、回帰モデルや分類モデルの多くも同様です。 + +では、これらの共通点をいくつか見てみましょう。 + +## ディープラーニングモデル + +次のようなディープラーニングモデルの図を目にしたことがあるかもしれません。 + + + +import NNBasicLight from './_img/nn_explained_01_basic.png'; +import NNBasicDark from './_img/nn_explained_01_basic_dark.png'; + + + +見た目はシンプルですが、これはディープラーニングモデルをかなり正確に表しています。詳細を見ていきましょう。 + +この図に詳細を追加すると、次のようになります。モデルは入力(この例では配列 `[x1, x2, x3]`)を取り、出力(同じく配列 `[y1, y2, y3]`)へと変換します。 + +import NNBasicLabellingLight from './_img/nn_explained_05_basic_labelling.png'; +import NNBasicLabellingDark from './_img/nn_explained_05_basic_labelling_dark.png'; + + + +この変換は「ノード」と呼ばれる要素、通常「隠れ層」と呼ばれる層によって実行されます。 + +## 入力と出力 + +前述のとおり、入力と出力はさまざまな形式を取り、さまざまな事柄を表現できます。そして、まさにここでそれが当てはまります。 + +例では 3 つの値の配列を入力・出力としていますが、実際には任意の長さの配列を扱えます。 + +たとえば回帰モデルなら、`[, , , , , , , ...]` のような入力を取り、ドル建ての金額を出力します。一方、分類モデルでは同じ入力を受け取りつつ、`[0.05, 0.65, 0.20, 0.10]` のような確率の配列を出力し、住宅が「低価格」「中価格」「高級」「超高級」といった価格帯に入る可能性を示します。 + +import NNInputsOutputsLight from './_img/nn_explained_10_inputs_and_outputs.png'; +import NNInputsOutputsDark from './_img/nn_explained_10_inputs_and_outputs_dark.png'; + + + +これらのモデルの制約のひとつは、入力と出力の両方が数値でなければならない点です。これは、入力を出力へ変換するために必要です。(テキストや画像などをどのように数値化するかは後で説明します。) + +それでは、モデルは実際にどのように入力を出力へ変換しているのでしょうか。実際には、以下に示すような計算を一連で行っています。この図では、特定のノード(行 1、列 1 のノード `h11`)の値がどのように計算されるかを示しています。 + +import NNNodeCalcsLight from './_img/nn_explained_20_node_calculation.png'; +import NNNodeCalcsDark from './_img/nn_explained_20_node_calculation_dark.png'; + + + +ご覧のように、計算自体は比較的シンプルです。前の層にある接続ノードの値を線形代数で組み合わせてノードの値を算出し、その過程で「重み」と「バイアス」を適用します。 + +その後に「活性化関数」を適用して非線形性を導入し、ネットワークが複雑なパターンを学習できるようにします。活性化関数がなければ、追加した層は無駄になってしまいます。 + +ディープラーニングモデルが行うことは、実のところこれだけです。ただし ―― 大規模に行います。 + +## パラメータ + +ご覧のように、各ノードの値は前の層およびその重み・バイアスによって決まります。これらの重みとバイアスそれぞれがパラメータと呼ばれます。モデル内のすべてのパラメータを合計したものがパラメータ数であり、モデルのサイズを示す指標として使われます。 + +import NNTotalParamsLight from './_img/nn_explained_25_total_parameters.png'; +import NNTotalParamsDark from './_img/nn_explained_25_total_parameters_dark.png'; + + + +大規模な AI モデルは数十億ものパラメータを持ちます。Meta の Llama3 最大モデルは 4050 億パラメータを持ち、初期の GPT-4 モデルは約 1.8 兆パラメータと言われています。 + +こうしてモデルは内部で入力の集合を出力へと変換します。 + +import NNFinalOutputLight from './_img/nn_explained_30_final_output.png'; +import NNFinalOutputDark from './_img/nn_explained_30_final_output_dark.png'; + + + +十分なパラメータ数を与えられると、それらを調整することでモデルに驚異的な能力を持たせることができます。 + +:::info より大きなモデルが常に優れているのでしょうか? + +必ずしもそうではありません。モデルを構築・学習しない場合でも、巨大なモデルを利用するにはオーバーヘッドがあります。大きなモデルは実行に多くのリソース(メモリ)を必要とし、出力生成が遅く、その分コストも高くなります。平均的には大型モデルのほうが高性能ですが、特定の用途では同等に機能する小型モデルを見つけられる場合もあります。 +
+ +AI モデル選定に関しては、後ほど詳しく取り上げます。 + +::: + +住宅の特徴を表す数値列を入力として、価格を予測(回帰)したり、特定のクラスに属する確率を算出したりできることは、ある程度直感的かもしれません。 + +しかし、この考え方がどのように `gpt` のような生成 AI モデルや埋め込みモデルへとつながるのでしょうか。実は、思っているよりも似ています。 + +次のセクションでこれを詳しく見ていきましょう。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/30_generative_models.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/30_generative_models.mdx new file mode 100644 index 000000000..5aa0986e9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/30_generative_models.mdx @@ -0,0 +1,133 @@ +--- +title: 生成 AI モデル +description: 生成 AI モデルの内部を探る +--- + +import ThemedImage from '@theme/ThemedImage'; + +:::info 生成モデルと Weaviate + +Weaviate は多くの生成モデルと統合されており、例えば検索結果から要約を生成するなど、保存されたデータと組み合わせて便利に利用できます。実際には、このモジュールで説明する多くの詳細は Weaviate を使うことで抽象化されています。 + +::: + +多くの人は `Claude.ai`、`ChatGPT`、`Meta AI` といったチャット型アプリケーション経由で AI モデルを利用しているかもしれません。これらのアプリケーションも深層学習モデルによって動作しています。具体的には `claude-3.5`、`gpt-4`、`llama-3` といったモデルです。 + +この種のモデルは一般に「生成 AI」または「生成モデル」と呼ばれます。 + +## 生成 AI モデルの仕組み + +前節では深層学習モデルの動作を見ました。ここで簡単におさらいします。 + +import NNInputsOutputsLight from './_img/nn_explained_10_inputs_and_outputs.png'; +import NNInputsOutputsDark from './_img/nn_explained_10_inputs_and_outputs_dark.png'; + + + +深層学習モデルは数値入力を受け取り、「隠れ層」を通して変換し、数値出力を生成します。しかし生成モデルはテキスト入力をテキスト出力に変換します ― 一見まったく異なるタスクです。 + +生成モデルがこれを実現できるのは、トークナイゼーションと自己回帰生成という 2 つの重要な要素があるからです。 + +### トークナイゼーション + +深層学習モデルへの入力は数値ですが、生成モデルはテキスト入力を受け取ります。トークナイゼーションはテキストを数値列へ変換する最初のステップです。 + +例えば `Explain tokenization like I am five.` という入力を考えます。生成モデルはこの入力を次のように「トークン化」するかもしれません。 + +import Tokenization from './_img/tokenization.png'; + +Neural Network Node Calculations + +各部分が一意の「トークン」であり、モデルにとっての最小理解単位と考えられます。モデルはそれぞれのトークンを一意の整数に置き換えます。さらに入力の最初と最後に特殊トークンを追加すると、その列がモデルへの入力となります。入力例は以下のようになります。 + +`[200264, 176289, 6602, 2860, 1299, 357, 939, 6468, 13, 200265]` + +各モデルには独自のトークナイザーがあり、挙動が異なる点に注意してください。 + +### 自己回帰生成 + +反対側では、生成モデルは 1 トークンを出力するように構成されています。生成モデルのアーキテクチャは次のようになります。 + +import NNGenerativeModels from './_img/nn_explained_40_generative_models.png'; +import NNGenerativeModelsDark from './_img/nn_explained_40_generative_models_dark.png'; + + + +しかし実際に私たちが対話するとき、生成モデルは可変長のテキストを出力します。 + +生成モデルはどのようにして 1 度に 1 トークンずつ生成しながら、まとまりのあるテキスト列を作り出すのでしょうか。ほとんどの(テキスト)生成モデルは、多くの人が難しい作業を行うときと同じように ― つまり「一歩一歩」トークンを積み重ねていくことで実現しています。次の図をご覧ください。 + +import NNAutoRegressiveModels from './_img/nn_explained_45_auto_regressive.png'; +import NNAutoRegressiveModelsDark from './_img/nn_explained_45_auto_regressive_dark.png'; + + + +生成モデルでは、生成された各トークンが入力列の一部となり、前の入力列は 1 つ下へスライド(最後尾は削除)します。これを繰り返し、モデルが生成終了を示す特殊トークンを出力するまで続きます。 + +この仕組みによって `gpt-4` のようなモデルは質問に対して一貫した回答を生成できます。各トークンはユーザー入力と、それまでに生成されたすべてのトークンを基に生成されるのです。 + +したがって、モデルに「コンテキスト長」の上限があると言われる場合、それは入力トークン `[x1, x2, …, xn]` の最大長を指します。また多くの場合、出力長にも制限が設けられています。これは自己回帰により入力が膨らむにつれ、出力トークンが初期入力を「忘れて」しまわないようにするためです。 + +### 生成モデルを使用する理由 + +この「一歩先に 1 トークンを生成する」というシンプルなタスクを通じて、生成モデルは非常に高度な多くのタスクをこなします。 + +生成モデルは以下のような分野横断的能力を示しています。 + +- 複数のプログラミング言語でコードを作成・デバッグ +- ニュアンスを理解した会話 +- 複雑な文書の要約や多言語翻訳 +- 難しい概念をさまざまな難易度で説明 +- 物語からマーケティングコピーまでコンテンツを生成 + +さらに生成モデルは "zero-shot" や "few-shot" 学習を行えます。つまり、明示的に訓練されていないタスクでも、ほとんどまたはまったく例を示さずに取り組めます。 + +これにより、生成モデルが特定用途向けモデルの代替となり、長いモデル開発プロセスを短縮できる場合があります。 + +驚くべきことに、これらすべての能力は生成モデルが持つたった 1 つの目標 ― 次のトークンを予測する ― から派生しています。 + +生成モデルを利用する際は、どれだけ印象的で複雑に見えても、モデルは膨大なパラメータを用いたパターンマッチングを行っているにすぎないことを忘れないようにしましょう。そうすることで、モデルに不適切な魔法的性質を付与せず、その出力を健全な懐疑心を持って扱えます。 + +これが生成モデルの基本です。後ほど具体的なモデル例やモデルの評価・選択などを学びます。今は別の種類のモデルであるエンベディングモデルについて学びましょう。 + +:::tip 高度なトピック + +本節では主に、テキスト入力からテキスト出力を生成する大規模言語モデルについて話しました。 +
+ +しかし多くの最新生成モデルはマルチモーダルです。テキストだけでなく画像も入力に含められる「ビジョン・ランゲージモデル」が存在します。また Stable Diffusion や Sora のように、画像や動画といった視覚的出力を生成するモデルもあります。 +
+ +これらのモデルも基本的な動作は前述と同様ですが、モダリティ固有の要素を持つことでさらに多彩な表現が可能になっています。 + +::: +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/40_embedding_models.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/40_embedding_models.mdx new file mode 100644 index 000000000..dff71eb08 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/40_embedding_models.mdx @@ -0,0 +1,135 @@ +--- +title: 埋め込みモデル +description: 埋め込みモデルの内部を探る +--- + +import ThemedImage from '@theme/ThemedImage'; + +:::info Embedding models and Weaviate + +埋め込みはベクトル データベースであるWeaviateにとって不可欠で、ベクトル/セマンティック検索を実現します。Weaviateのようなベクトル データベースを使えば、これらの埋め込みを数百万、あるいは数十億件でも簡単に保存・検索できます。 + +::: + +生成モデルが AI 世界のスターだとすれば、埋め込みモデルは配管のような存在です。華やかさはありませんが、インフラを支える重要な部品です。 + +埋め込みモデルとは何か、そしてなぜそれほど重要なのかを見ていきましょう。 + +## 埋め込みモデルの仕組み + +埋め込みモデルは、与えられた入力の「意味」を捉えることを目指します。生成された埋め込みは、その後、分類・クラスタリング、あるいは最も一般的には情報検索などのタスクに利用できます。 + +よく使われる埋め込みモデルには、Cohere の `embed-multilingual-v3.0`、OpenAI の `text-embedding-3-large`、Snowflake の `snowflake-arctic-embed-l-v2.0` などがあります。 + +これらの名前は総じて汎用的で説明的です。派手さもないため、あまり知られていないかもしれません。 + +しかし、生成モデルに劣らず興味深い存在であり、多くの共通点もあります。たとえば、どちらもテキスト入力をトークナイザーで数値形式へ変換します。大きな違いは、生成モデルがトークンを 1 つずつ出力するのに対し、埋め込みモデルは固定長(あるいは固定形状)の数列を一度に出力する点です。 + +import NNEmbeddingModels from './_img/nn_explained_50_embedding_models.png'; +import NNEmbeddingModelsDark from './_img/nn_explained_50_embedding_models_dark.png'; + + + +意味を数値で表現するという概念は、最初はピンとこないかもしれません。ここで一歩戻り、よりシンプルな例を見てみましょう。 + +### 類推:色のエンコーディング + +このアプローチの類推として、 RGB や CMYK、 HSL など、色を数値で表現する方法が挙げられます。 + +いずれの方式でも、任意の色を数値の列として表現できます。たとえばウェブ公式の「red」を例に取ると、 RGB では `[255, 0, 0]`、 CMYK では `[0, 100, 100, 0]`、 HSL では `[0, 100%, 50%]` となります。 + +つまり、それぞれの方式は、色を数列として表現するための標準化された方法です。 + +埋め込みモデルも同様に機能します。たとえば、「You’re a wizard, Harry.」というフレーズは次のように表現されるかもしれません。 + +`[0.021, -0.103, 0.036, 0.088, -0.022, ..., 0.056]` + +実際のシーケンス長は、 256、 1024、 1536 など、かなり大きいことが一般的です。 + +もちろん、最新の埋め込みモデルは、色を RGB 値に変換するアルゴリズムよりはるかに複雑です。しかし原理は同じで、どの方式も入力を一貫して数列に変換します。 + +では、これがどのように役立つのでしょうか。実はさまざまなタスクで利用できます。 + +## 埋め込みモデルを使う理由 + +先ほど、埋め込みモデルを色を数値化する RGB のような体系になぞらえました。埋め込みモデルの最大の利点も同様で、元の対象同士を意味のある形で比較できる点にあります。 + + RGB に戻ると、「crimson」は `[220, 20, 60]` です。これが red の `[255, 0, 0]` とかなり近く、一方で「aqua」の `[0, 255, 255]` とは大きく異なることが分かります。 + +| | R | G | B | +| --- | --- | --- | --- | +| Red | 255 | 0 | 0 | +| Crimson | 220 | 20 | 60 | +| Aqua | 0 | 255 | 255 | + +実際には、類似度を 1 つの数値として定量化できます。そこでよく使用される指標が「コサイン類似度」です。 Python での実装例を示します。 + +```python +import numpy as np + +def cosine_similarity(a: list, b: list) -> float: + # Calculate the cosine similarity between two input lists + return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)) +``` + +比較結果を表にまとめると、これを類似度行列と呼びます。ここでは各セルが、対応する行と列の類似度を表しています。 + +| | Red | Crimson | Aqua | +| --- | --- | --- | --- | +| Red | 1 | 0.961 | 0 | +| Crimson | 0.961 | 1 | 0.247 | +| Aqua | 0 | 0.247 | 1 | + +このデモからの重要なポイントは、この方式を使えば色同士の類似度を比較できるということです。言い換えれば、ある色に最も似ている色を多数の候補の中から特定できるようになります。 + +## 埋め込みモデルの応用 + +埋め込みモデルの話に戻ると、その価値は、与えられたオブジェクトに対して最も意味が近いオブジェクトを集合の中から見つけ出せる点にあります。 + +次の 3 つのテキストを見てみましょう。 + +``` +1. "You're not wizened, Harry." +2. "Harry can wield magic." +3. "Ron is not a great driver." +``` + +これらのうち、`"You're a wizard, Harry."` に最も近いのはどれでしょうか。 + +おそらく多くの人が 2 と答えるでしょう。しかしその理由は? そしてプログラムにも同じ答えを出させるには? 2 にはクエリと重複する語が 1 つしか含まれていない点に注目してください。 + +これこそ埋め込みが可能にするタスクです。埋め込みとコサイン類似度を使うと、次のような結果になります。 + +| | 順位 | コサイン距離 | +| --- | --- | --- | +| Harry can wield magic. | 1 | 0.238 | +| You're not wizened, Harry. | 2 | 0.274 | +| Ron is not a great driver. | 3 | 0.803 | + +この類似度の概念は、セマンティック検索で利用されます。最新の AI システムでは、セマンティック検索は 検索拡張生成 ( RAG ) の重要な構成要素となっており、生成システムに正確で最新のコンテキストを提供して補完します。 + +埋め込みの応用範囲はさらに広がっています。レコメンダー、クラスタリング、分類など、他の AI システムでも広く利用されています。 + +:::tip Advanced topics + +本節では、テキスト入力からベクトル 埋め込みを生成するテキスト埋め込みモデルに関する話題が中心でした。 +
+ +生成モデルと同様、埋め込みモデルの世界も非常に大きく興味深いものです。マルチモーダル埋め込みモデルは複数の入力タイプを受け取り、同じ空間で互換性のある埋め込みを生成できます。また、近年の埋め込みには、多ベクトル 埋め込み(例: ColBERT)や可変長埋め込みなど、さまざまな形式があります。 +
+ +これらについては、特定のモダリティやモデル選定をより深く掘り下げる際に、改めて取り上げる予定です。 + +::: +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/50_model_training.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/50_model_training.mdx new file mode 100644 index 000000000..16d0b96fd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/50_model_training.mdx @@ -0,0 +1,94 @@ +--- +title: "概要:モデルの学習" +description: AI モデルがどのように学習されるかの超簡潔な紹介 +--- + +import ThemedImage from '@theme/ThemedImage'; + +このセクションでは、AI モデルがどのように学習されるかを非常に簡潔に説明します。これは AI モデルの仕組みや活用方法を理解するうえで重要なポイントです。詳細な学習手順には踏み込みませんが、全体像をつかむためのハイレベルな概要を提供します。 + +## モデルの学習とは + +これまでに、AI モデル、より具体的には deep learning モデルは、入力に対して多数の変換を適用して出力を生成することを学びました。これらの変換は主に `weights`、`biases`、`activation functions` を通じて実行され、以下のノード計算例に示されています。 + +import NNNodeCalcsLight from './_img/nn_explained_20_node_calculation.png'; +import NNNodeCalcsDark from './_img/nn_explained_20_node_calculation_dark.png'; + + + +また、`weights` と `biases` をまとめて deep learning モデルの `parameters` と呼ぶことも学びました。名前のとおり、`parameters` は deep learning モデルの挙動を決定するものです(アーキテクチャとは対照的です)。 + +:::info + +*Parameter*: n. システムの要素を特徴付ける任意の定数 + +出典: Merriam-Webster Dictionary + +::: + +同じアーキテクチャであっても、parameters が異なれば別の仕事をこなすモデルになります。 + +これらの models には一般に数百万、あるいは数十億もの parameters が含まれるため、目的の動作を実現するように手動で値を設定するのは事実上不可能です。その代わり、parameters は数値的に “学習” させることで調整されます。これが「deep *learning*」モデルと呼ばれる理由です。 + +## モデルはどのように学習されるか + +高いレベルで見ると、学習の流れは他の機械学習モデルと同じです。一般の方には、Microsoft Excel の「ゴール シーク」や、もっと基本的には [“Hot and Cold” ゲーム](https://en.wikipedia.org/wiki/Hunt_the_thimble)に似ているといえます。 + +deep learning では、各学習 “iteration” でモデルの出力を “理想的な” 出力と比較します(これを “loss function” と呼びます)。そして複雑な数学を駆使して parameters を更新し、モデルが少しずつ上手にタスクをこなせるようにします。 + +:::note Why gloss over the “fancy math”? + +ここで “fancy math” という表現を使ったのは、複雑な数学と計算が関わっていることを軽く示すためです。もちろんこれは AI における非常に興味深く重要な分野です。 +
+ +ここで鍵になるのは “gradient descent” で、loss function を数値的に微分し、その勾配を利用して parameters を少しずつ更新していきます。 +
+ +ただし本ドキュメントの範囲外であり、モデルを単に利用したい方にとっては必須ではないため、詳細な説明は割愛します。もし詳しく学びたい場合は優れた資料が多数あります。 +
+ +いくつかのお気に入りリソースを紹介します: +- [動画: Let’s reproduce GPT-2 by Andrej Karpathy](https://www.youtube.com/watch?v=l8pRSuU81PU) +- [Fine-tune large language models: Hugging Face](https://huggingface.co/learn/nlp-course/en/chapter11/1) + +::: + + +import NNBackpropagation from './_img/nn_explained_55_backprop.png'; +import NNBackpropagationDark from './_img/nn_explained_55_backprop_dark.png'; + + + +このプロセスは出力側から入力側へと学習結果を伝搬させていくため “back propagation”(バックプロパゲーション、略して backprop)と呼ばれます。 + +モデル学習プロセスにおいて、このような更新が 1 回の “iteration” です。学習期間中に非常に多くの iteration を繰り返します。モデルの巨大さと、必要な iteration 数の多さが、学習にかかるコストと時間を大きくしている要因です。 + +## モデル:構築か購入か + +大型言語モデルをゼロから学習させるには数か月、そしてコンピューティング資源に数百万ドルかかることもあります。現代の GPU はこの用途に最適化されているため、近年特に高い需要があります。 + +現代の AI モデルは複数の段階で学習され、“pre-training” と “fine-tuning” と呼ばれます。簡単に言えば、pre-training でモデルの一般能力を獲得し、fine-tuning で特定のドメインやアプリケーション向けに適応させます。 + +ほとんどの場合、ユーザーは既製のモデルを選択しますが、適切な専門知識と目的があれば fine-tuning が有効なケースもあります。これについては後の「モデルの評価と選択」のセクションで詳しく扱います。 + +次に、これらのモデルを実際にどう利用するかを見ていきましょう。商用の推論プロバイダを通じてアクセスする方法やローカルで推論を行う方法、そのメリット・デメリットを確認し、モデルカードを読み解きながら各モデルの詳細を理解していきます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/60_using_models.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/60_using_models.mdx new file mode 100644 index 000000000..d92e4a97d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/60_using_models.mdx @@ -0,0 +1,501 @@ +--- +title: AI モデルの利用 +description: 推論のために AI モデルを使用する例 +--- + +import ThemedImage from '@theme/ThemedImage'; + +このモジュールのここまでの内容では、主に AI モデルの理論的な側面について説明してきました。これによって、これらのモデルに関する基礎的な理解を深め、あるいは確立できたことと思います。 + +しかし、 AI モデルは単なる素晴らしい科学的成果以上のものです。私たちがより生産的になるためのツールでもあります。では、その理解を踏まえて、実践的な利用へと移っていきましょう。 + +このセクションでは、 AI モデルの利用例を紹介します。モデルが構築された後、そのモデルを実行して出力を生成するステップは「推論を行う」とも呼ばれます。 + +## 推論の基本 + +import NNInference from './_img/nn_explained_80_inference.png'; +import NNInferenceDark from './_img/nn_explained_80_inference_dark.png'; + + + +推論の方法には、推論モダリティからモデルプロバイダー、そしてモデルそのものまで、非常に多くの選択肢があります。そのため、組み合わせによっては意思決定が容易に圧倒されてしまうこともあります。 + +そこで、このセクションでは一般的な選択肢を整理して概観します。 + +まずは、これらのモデルを利用するさまざまな方法、すなわち推論プロバイダーを利用するかローカルで推論を行うかというモードについて説明します。そして各モード内で、代表的なプロバイダーやソフトウェアライブラリを使った推論例を示します。 + +これにより、多岐にわたる選択肢への敷居の高さや神秘性を取り除き、後のモデルの評価および選定に関する議論の基礎を築けるはずです。 + +:::note このセクションでは Weaviate を使用しません + +あなたはすでに、 Weaviate がモデルプロバイダーと連携して推論を簡単に行えるようにしていることをご存じかもしれません。しかし、このセクションではモデルへ直接アクセスします。これにより、後で Weaviate があなたに代わって推論を実行するときに、その裏側で何が起こっているのかを理解しやすくなります。 + +::: + +## サービスプロバイダー経由の推論 + +最新の AI モデルへ最も手軽にアクセスする方法は、推論サービスプロバイダーが提供する Web API を利用することです。 + +特定の種類の AI モデルの人気が急増したおかげで、誰でも登録して使える推論プロバイダー(および API)が数多く存在します。 + +代表的な推論プロバイダーとしては、 Anthropic、 AWS、 Cohere、 Google、 Microsoft、 OpenAI などが挙げられます。 + +すべてのモデルがすべての推論プロバイダーで利用できるわけではありません。独自の専用モデルを開発しているプロバイダーもあれば、純粋に推論サービスの提供に特化しているプロバイダーもあります。 + +Cohere を介して推論を実行する例を見てみましょう。 + +:::info 費用はかかりますか? + +執筆時点では、 Cohere はいくつかの注意事項や制限付きで無償の API アクセスを提供していました。詳細については最新の利用規約を必ずご確認ください。有料サービスを利用する場合でも、ここで行う推論の量は非常に少なく、費用は 1 米ドル未満とごくわずかです。 + +::: + +### 準備 + +このセクションでは Cohere を使用します。 [Cohere](https://cohere.com/) は、生成、埋め込み、再ランカーの各種モデルを開発しています。 Cohere のモデルは他の推論サービスでも、また Cohere 自身でも利用できます。ここでは Cohere API を直接利用します。 + +:::info +執筆時点では、 Cohere は無償で利用できるトライアルキーを提供していました。 +::: + +Cohere API を利用するには、[アカウントに登録](https://cohere.com/) した後、ダッシュボードに移動します。そこで `API keys` というセクションに進むと、 API キーを管理できます。 + +本チュートリアルにはトライアルキーで十分ですので作成してください。そして、この API キーを `COHERE_API_KEY` という名前の環境変数に設定します。 + +お好みのパッケージマネージャーで Cohere SDK をインストールします。例: + +```bash +pip install cohere +``` + +### 埋め込みモデルの利用 + +次のスニペットは、一連のテキスト片( `source_texts` )を埋め込みに変換します。 + +```python +import cohere +import os + +cohere_api_key = os.getenv("COHERE_API_KEY") +co = cohere.ClientV2(api_key=cohere_api_key) + +source_texts = [ + "You're a wizard, Harry.", + "Space, the final frontier.", + "I'm going to make him an offer he can't refuse.", +] + +response = co.embed( + texts=source_texts, + model="embed-english-light-v3.0", + input_type="search_document", + embedding_types=["float"], +) + +source_embeddings = [] +for e in response.embeddings.float_: + print(len(e)) # This will be the length of the embedding vector + print(e[:5]) # This will print the first 5 elements of the embedding vector + source_embeddings.append(e) # Save the embedding for later use +``` + +後で検索できるようにソーステキストを保存するため、ここでは入力タイプとして `search_document` を指定している点に注意してください。 + +これにより、次のような出力が得られます(数値は多少異なる場合があります): + +``` +384 +[0.024459839, 0.039001465, -0.013053894, 0.016342163, -0.049926758] +384 +[-0.0051002502, 0.017578125, -0.0256958, 0.023513794, 0.018493652] +384 +[-0.076660156, 0.04244995, -0.07366943, 0.0019054413, -0.007736206] +``` + +各ベクトルについて、その長さ(次元数)と先頭の数次元を表示しています。 + +次に、クエリ(例: `intergalactic voyage` )に最も一致するテキストを見つけるには、まずクエリテキストを埋め込みに変換します: + +```python +# Get the query embedding: +query_text = "Intergalactic voyage" + +response = co.embed( + texts=[query_text], + model="embed-english-light-v3.0", + input_type="search_query", + embedding_types=["float"], +) + +query_embedding = response.embeddings.float_[0] + +print(len(query_embedding)) +print(query_embedding[:5]) +``` + +これにより、次のような出力が得られます: + +``` +384 +[-0.007019043, -0.097839355, 0.023117065, 0.0049324036, 0.047027588] +``` + +ここで、クエリ ベクトルがドキュメント ベクトルと同じ次元数であり、各次元が同様の形式であることが確認できます。 + +ベクトル検索を行うには: + +```python +# Find the most similar source text to the query: +import numpy as np + +# Calculate the dot product between the query embedding and each source embedding +dot_products = [np.dot(query_embedding, e) for e in source_embeddings] + +# Find the index of the maximum dot product +most_similar_index = np.argmax(dot_products) + +# Get the most similar source text +most_similar_text = source_texts[most_similar_index] + +print(f"The most similar text to '{query_text}' is:") +print(most_similar_text) +``` + +次のような出力が得られます: + +``` +The most similar text to 'Intergalactic voyage' is: +Space, the final frontier. +``` + +直感的にも納得できる結果になっていると思います。興味があれば、ソーステキストやクエリテキストを変えて試してみてください。 + +埋め込みモデルは意味をできる限り捉えようとしますが、完全ではありません。特定の埋め込みモデルは、特定のドメインや言語でより良く機能します。 + +### 生成モデルの利用 + +次に、 Cohere の大規模言語モデルのひとつを使ってみましょう。大規模言語モデルがどのように機能するかを説明するよう依頼します: + +```python +import cohere +import os + +cohere_api_key = os.getenv("COHERE_API_KEY") +co = cohere.ClientV2(api_key=cohere_api_key) + +messages = [ + { + "role": "user", + "content": "Hi there. Please explain how language models work, in just a sentence or two.", + } +] + +response = co.chat( + model="command-r-plus", + messages=messages, +) + +print(response.message.content[0].text) + +``` + +レスポンスは次のようになるかもしれません(出力は多少異なる場合があります): + +``` +Language models are artificial intelligence systems that generate and understand human language by analyzing vast amounts of text data and learning patterns, structures, and context to create responses or translations. These models use machine learning algorithms to create statistical representations of language, enabling them to produce human-like text output. +``` + +Claude AI や ChatGPT のような Web インターフェースを見たことがあれば、マルチターンの会話に馴染みがあるでしょう。 + +API では、前の会話履歴を LLM に渡すだけで同じ結果を得ることができます: + +```python +import cohere +import os + +cohere_api_key = os.getenv("COHERE_API_KEY") +co = cohere.ClientV2(api_key=cohere_api_key) + +messages = [ + { + "role": "user", + "content": "Hi there. Please explain how language models work, in just a sentence or two.", + } +] + +# Initial response from the model +response = co.chat( + model="command-r-plus", + messages=messages, +) + +# Append the initial response to the messages +messages.append( + { + "role": "assistant", + "content": response.message.content[0].text, + } +) + +# Provide a follow-up prompt +messages.append( + { + "role": "user", + "content": "Ah, I see. Now, can you write that in a Haiku?", + } +) + +response = co.chat( + model="command-r-plus", + messages=messages, +) + +# This response will take both the initial and follow-up prompts into account +print(response.message.content[0].text) +``` + +レスポンスは次のようになります: + +``` +Language models, oh +Patterns and words, they dance +New text, probabilities. +``` + +メッセージ履歴全体を含めたことで、言語モデルが履歴を文脈として正しく応答している点に注目してください。 + +これは Claude AI や ChatGPT といったアプリケーションで起こっていることとほぼ同じです。あなたが入力するたびに、メッセージ履歴全体がモデル推論に利用されています。 + +ここまでで、 Cohere の Web ベース API を使ったモデル推論の仕組みを確認しました。この方式ではモデルはオンラインでホストされ、リモートで実行されます。次は、これらのモデルをローカルで実行する例を見ていきましょう。 +## ローカル推論 + +多くの場合、AI モデルの推論をローカル(オンプレミス)モデルで実行することが望ましい、あるいは必須となることがあります。 + +これにはさまざまな理由があります。例えば、データをローカルに保持したい(コンプライアンスやセキュリティのためなど)、独自に学習させた専用モデルを使用したい、あるいは商用の推論 API よりもローカル推論のほうが経済的に有利といったケースです。 + +推論プロバイダーが提供する選択肢と比べるとローカル推論の選択肢は少ないかもしれませんが、それでも十分に幅広いオプションが存在します。公開されているモデルは多数あり、プロセスを容易にするソフトウェア ライブラリも豊富です。一般的なディープラーニング ライブラリである PyTorch や TensorFlow に加え、Hugging Face Transformers、Ollama、ONNX Runtime などのライブラリを利用するとローカル推論がより簡単になります。特に Ollama と ONNX Runtime を使えば、GPU / TPU などのハードウェア アクセラレーションがなくても実用的な速度で動作します。 + +それでは、Ollama を用いて推論を実行する例を見ていきましょう。 + +:::info Model licenses + +他の製品と同様に、AI モデルには使用条件を定めたライセンスが付いていることが一般的です。 + +公開モデルであっても、商用利用が許可されていないものもあります。用途に適しているかどうかを判断するため、必ず各モデルのライセンスを確認してください。 + +::: + +### 準備 + +このセクションでは Ollama を使用します。 +[Ollama](https://ollama.com/) は、AI モデルをローカルで実行・デプロイするためのオープンソース フレームワークです。Llama、Mistral、Snowflake の埋め込みモデルなど、さまざまなオープンソース モデルを簡単にダウンロード、セットアップ、対話できます。Ollama にはコマンドライン インターフェースと REST API、さらに複数のプログラミング言語向け SDK が用意されています。 + +:::info System requirements + +このセクションではローカル推論を実行します。ここで使用するモデルは比較的小規模ですが、それでも AI モデルにはある程度のシステム リソースが必要です。少なくとも 16 GB の RAM を搭載した最新のコンピューターを推奨します。 + +GPU は必須ではありません。 + +::: + +Ollama を使用するには、公式サイトにアクセスしてダウンロードとインストール手順に従ってください。 + +続いて必要なモデルをプルします。ここでは 10 億パラメータの Gemma3 生成モデルと、1 億 1,000 万パラメータの Snowflake Arctic 埋め込みモデルを使用します。 + +Ollama をインストールしたら、次のコマンドでモデルをプルします。 + +```bash +ollama pull gemma3:1b +ollama pull snowflake-arctic-embed:110m +``` + +次に、モデルがロードされているかを確認するために以下を実行します。 + +```bash +ollama list +``` + +出力結果に `gemma3:1b` と `snowflake-arctic-embed:110m` が含まれていれば成功です。 + +お好みの環境で、任意のパッケージ マネージャーを使って Ollama の Python ライブラリをインストールします。例: + +```bash +pip install ollama +``` + +### 埋め込みモデルの使用 + +次のスニペットは、一連のテキスト (`source_texts`) を埋め込みに変換します。 + +```python +import ollama + +source_texts = [ + "You're a wizard, Harry.", + "Space, the final frontier.", + "I'm going to make him an offer he can't refuse.", +] + +response = ollama.embed(model='snowflake-arctic-embed:110m', input=source_texts) + +source_embeddings = [] +for e in response.embeddings: + print(len(e)) # This will be the length of the embedding vector + print(e[:5]) # This will print the first 5 elements of the embedding vector + source_embeddings.append(e) # Save the embedding for later use +``` + +出力は次のようになります(数値は環境によって異なります)。 + +``` +768 +[-0.030614788, 0.01759585, -0.001181114, 0.025152, 0.005875709] +768 +[-0.039889574, 0.05197108, 0.036466435, 0.012909834, 0.012069418] +768 +[-0.04942698, 0.05466185, -0.007884168, -0.00252788, -0.0025294009] +``` + +各ベクトルについて、その長さ(次元数)と先頭数次元を表示しています。(ここでの次元数は Cohere の例とは異なります。モデルごとに *次元数* が異なるためです。) + +同じステップを踏んでみましょう。まずクエリ(ここでは `intergalactic voyage`)に最もよく合致するテキストを見つけるため、クエリ テキストを埋め込みます。 + +```python +# Get the query embedding: +query_text = "Intergalactic voyage" + +response = ollama.embed(model='snowflake-arctic-embed:110m', input=query_text) + +query_embedding = response.embeddings[0] + +print(len(query_embedding)) +print(query_embedding[:5]) +``` + +結果例: + +``` +768 +[-0.043455746, 0.05260946, 0.025877617, -0.017234074, 0.027434561] +``` + +ここでも、クエリ ベクトルとドキュメント ベクトルは同じ次元数で、各次元の形式も同様です。 + +ベクトル検索を実行するには以下のようにします。 + +```python +# Find the most similar source text to the query: +import numpy as np + +# Calculate the dot product between the query embedding and each source embedding +dot_products = [np.dot(query_embedding, e) for e in source_embeddings] + +# Find the index of the maximum dot product +most_similar_index = np.argmax(dot_products) + +# Get the most similar source text +most_similar_text = source_texts[most_similar_index] + +print(f"The most similar text to '{query_text}' is:") +print(most_similar_text) +``` + +埋め込みを比較するスニペットは Cohere の例とまったく同じです。実行結果は次のようになります。 + +``` +The most similar text to 'Intergalactic voyage' is: +Space, the final frontier. +``` + +Snowflake モデルでも、候補の中で宇宙関連の文章が最も近いと判定されました。 + +### 生成モデルの使用 + +次に、`gemma3:1b` モデルを使って Ollama で大規模言語モデルを試してみましょう。再び「大規模言語モデルはどのように機能するか」を説明させます。 + +```python +from ollama import chat +from ollama import ChatResponse + +messages = [ + { + "role": "user", + "content": "Hi there. Please explain how language models work, in just a sentence or two.", + } +] + +response: ChatResponse = chat(model='gemma3:1b', messages=messages) + +print(response.message.content) +``` + +応答は次のようになる場合があります(出力は環境により異なります)。 + +``` +Language models, like me, are trained on massive amounts of text data to predict the next word in a sequence, essentially learning patterns and relationships within language to generate text that seems coherent and relevant. +``` + +前回と同様に、マルチターンの会話を行うことも可能です。 + +```python +from ollama import chat +from ollama import ChatResponse + +messages = [ + { + "role": "user", + "content": "Hi there. Please explain how language models work, in just a sentence or two.", + } +] + +# Initial response from the model +response: ChatResponse = chat(model='gemma3:1b', messages=messages) + +# Append the initial response to the messages +messages.append( + { + "role": "assistant", + "content": response.message.content, + } +) + +# Provide a follow-up prompt +messages.append( + { + "role": "user", + "content": "Ah, I see. Now, can you write that in a Haiku?", + } +) + +response: ChatResponse = chat(model='gemma3:1b', messages=messages) + +# This response will take both the initial and follow-up prompts into account +print(response.message.content) +``` + +私の場合の応答は次のようでした。 + +``` +Words flow, patterns bloom, +Digital mind learns to speak, +Meaning takes new form. +``` + +具体的な応答内容やシンタックスは異なるものの、推論プロバイダーとローカルモデルの間でワークフローと基本原則は同じでした。 + +では、どのようにしてこれらの選択を行えばよいのでしょうか? + +先に触れたように、これは重要かつ広範なテーマであり、後ほど詳しく扱います。次のセクションでは、その第一歩として推論プロバイダーとローカルモデルのどちらを選ぶか、そしてモデルカードを読む際のポイントを取り上げます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/70_strategy.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/70_strategy.mdx new file mode 100644 index 000000000..d86bcf390 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/70_strategy.mdx @@ -0,0 +1,130 @@ +--- +title: ランドスケープの把握 +description: 広大で複雑な AI モデルの世界をナビゲートする方法 +--- + +## アクセスモードの選択 + +アプリケーションに AI モデルを導入する際、商用の推論サービスプロバイダーを利用するかローカル推論を行うかを選ぶことで、選択肢を絞り込むことができます。 + +それぞれのアプローチには、ユースケースに応じて考慮すべき明確な利点とトレードオフがあります。 + +### 推論サービスプロバイダー + +例: AWS、Cohere、Google、Microsoft Azure、OpenAI など + +**利点:** + +- インフラ管理やハードウェア投資が不要 +- プロバイダー独自の専有モデルへアクセス可能 + - 定期的なモデル更新と改善 +- ワークロードの変動に応じた自動スケーリング + +**欠点:** + +- ローカルまたはセルフマネージド推論よりコストが高い傾向 +- データが環境外に出るためプライバシー面の考慮が必要 +- サードパーティサービスの稼働状況に依存 + - プロバイダーがサービスを停止した場合のリスク +- カスタマイズの自由度が限定的 + +### ローカル推論 + +例: Hugging Face Transformers / Accelerate、llama.cpp、Ollama、PyTorch Serve、TensorFlow Serving + +**利点:** + +- データ送受信を自分で管理可能 +- 推論にインターネット接続が不要 +- 独自に学習させたカスタムモデルのデプロイが可能 + +**欠点:** + +- ハードウェア調達の初期費用が高い +- 最新で最強力なモデルにアクセスしにくい +- モデルの更新・保守を自分で担う必要 +- 使用可能なハードウェアによる性能制約の可能性 + +### 判断基準 + +選択の際は、次の質問を検討してください。 + +1. **データの機密性**: 機密情報や規制対象のデータを扱いますか? データを外部に出せない場合、利用可能な推論プロバイダーやローカルモデルが限定されます。 +2. **推論量**: 1 日 / 1 か月あたりどの程度のリクエストを処理しますか? 多くの場合、ローカルモデルの初期コストが負担となる可能性があります。 +3. **レイテンシ要件**: モデル応答の時間制約はどの程度厳しいですか? 厳しい場合、小規模ユーザーがローカルモデルを使うことは難しいかもしれません。 +4. **予算制約**: 優先するのは初期費用の削減ですか、それとも長期的なコスト最適化ですか? +5. **技術リソース**: ローカルモデルのデプロイや学習を管理する能力がありますか? + +万能な解決策は存在しません。 + +しかし、まずは商用の推論サービスプロバイダーを利用すると、導入時のハードルが低くなる場合があります。 + +## モデルカードの読み方 + +モデル「カード」は、一般製品における製品ラベルや仕様書と同じように、 AI モデルについての情報を提供するものです。 + +モデルカードは、モデルプロバイダーがモデルの概要と最適な利用方法を理解してもらうために提供します。 + +**モデルカードの例** + +モデルカードには複数の形式があります。以下は埋め込みモデルのカード例です。 + +- [https://huggingface.co/Cohere/Cohere-embed-english-v3.0](https://huggingface.co/Cohere/Cohere-embed-english-v3.0) +- [https://docs.cohere.com/v2/docs/cohere-embed](https://docs.cohere.com/v2/docs/cohere-embed) +- [https://huggingface.co/Snowflake/snowflake-arctic-embed-l-v2.0](https://huggingface.co/Snowflake/snowflake-arctic-embed-l-v2.0) + +生成 AI モデルのカード例は次のとおりです。 + +- [https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) +- [https://ollama.com/library/llama3.3:70b](https://ollama.com/library/llama3.3:70b) +- [https://ai.google.dev/gemma/docs/core/model_card_3](https://ai.google.dev/gemma/docs/core/model_card_3) +- [https://build.nvidia.com/microsoft/phi-4-multimodal-instruct/modelcard](https://build.nvidia.com/microsoft/phi-4-multimodal-instruct/modelcard) + +この少数の例だけでも、カードはホスティングサイトやモデルプロバイダーによって内容が大きく異なることが分かります。特に初めての場合、この情報量は圧倒されるかもしれません。 + +import ModelCards from './_img/model_cards.png'; + +Model Cards + +詳細は後続のコースで扱いますが、ここでは注目すべき主要パラメーターを紹介します。 + +1. **基本情報** + - モデル名とバージョン + - モデルタイプ(生成、埋め込み など) + - モデルサイズ(パラメータ数)とアーキテクチャ + - 学習データの概要 + - API 経由でアクセスする場合のコスト、またはハードウェア要件 +2. **技術仕様** + - 埋め込みモデルの場合の次元数 + - 生成モデルの場合のコンテキスト長 + - 対応言語やモダリティ +3. **性能指標** + - ベンチマーク結果 + - 既知の強みと制限 + - 下流タスクでの性能 +4. **使用情報** + - 想定ユースケース + - 実装ガイドラインやコードスニペット +5. **法的・倫理的考慮事項** + - ライセンス形態と使用制限 + - バイアスや公平性に関する潜在的課題 + +これらの項目を確認するだけでも、自分のニーズに合ったモデルを見極めるのに大いに役立ちます。 + +他の情報がない場合は、まず次の観点でフィルタリングすると良いでしょう。 + +- 適切なモデルタイプ +- モダリティ、言語、コンテキスト長または次元数の適合性 +- モデルへのアクセス方法(推論サービスプロバイダー / ローカル推論) +- ライセンスが要件を満たしているか + +そのうえで、信頼できるモデルプロバイダーのモデルやベンチマーク性能を基に候補を選定します。 + +最終的には、モデルおよびアプリケーションの性能を自分で評価したい場合もあるでしょう。 + +しかし、これらのシンプルなヒューリスティクスを活用することで、優れたベースラインモデル、または複数のベースラインモデルを選ぶまでの道のりが大きく短縮されます。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_chat_example_1.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_chat_example_1.png new file mode 100644 index 000000000..4acea1134 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_chat_example_1.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_chat_example_2.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_chat_example_2.png new file mode 100644 index 000000000..827526443 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_chat_example_2.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_copilot_example.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_copilot_example.png new file mode 100644 index 000000000..fbdd72aa8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_copilot_example.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_cute_dog.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_cute_dog.png new file mode 100644 index 000000000..b119a577a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_cute_dog.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_generated_unicorn.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_generated_unicorn.png new file mode 100644 index 000000000..f00a76cc1 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/10_generated_unicorn.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/model_cards.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/model_cards.png new file mode 100644 index 000000000..45ecf3d96 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/model_cards.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_01_basic.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_01_basic.png new file mode 100644 index 000000000..4c381868b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_01_basic.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_01_basic_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_01_basic_dark.png new file mode 100644 index 000000000..55031837e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_01_basic_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_05_basic_labelling.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_05_basic_labelling.png new file mode 100644 index 000000000..3a547fee7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_05_basic_labelling.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_05_basic_labelling_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_05_basic_labelling_dark.png new file mode 100644 index 000000000..8748a902c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_05_basic_labelling_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_10_inputs_and_outputs.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_10_inputs_and_outputs.png new file mode 100644 index 000000000..5af800cc0 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_10_inputs_and_outputs.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_10_inputs_and_outputs_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_10_inputs_and_outputs_dark.png new file mode 100644 index 000000000..8da006b7d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_10_inputs_and_outputs_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_20_node_calculation.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_20_node_calculation.png new file mode 100644 index 000000000..408ff3307 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_20_node_calculation.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_20_node_calculation_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_20_node_calculation_dark.png new file mode 100644 index 000000000..229748857 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_20_node_calculation_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_25_total_parameters.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_25_total_parameters.png new file mode 100644 index 000000000..17d3fd818 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_25_total_parameters.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_25_total_parameters_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_25_total_parameters_dark.png new file mode 100644 index 000000000..f0760a239 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_25_total_parameters_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_30_final_output.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_30_final_output.png new file mode 100644 index 000000000..e0f9026cd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_30_final_output.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_30_final_output_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_30_final_output_dark.png new file mode 100644 index 000000000..146da2fb2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_30_final_output_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_40_generative_models.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_40_generative_models.png new file mode 100644 index 000000000..7f878f1b4 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_40_generative_models.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_40_generative_models_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_40_generative_models_dark.png new file mode 100644 index 000000000..8a54645c0 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_40_generative_models_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_45_auto_regressive.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_45_auto_regressive.png new file mode 100644 index 000000000..7a2ba4f09 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_45_auto_regressive.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_45_auto_regressive_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_45_auto_regressive_dark.png new file mode 100644 index 000000000..86223a488 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_45_auto_regressive_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_50_embedding_models.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_50_embedding_models.png new file mode 100644 index 000000000..244e3ec6f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_50_embedding_models.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_50_embedding_models_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_50_embedding_models_dark.png new file mode 100644 index 000000000..882af08c2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_50_embedding_models_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_55_backprop.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_55_backprop.png new file mode 100644 index 000000000..8fd9095fd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_55_backprop.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_55_backprop_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_55_backprop_dark.png new file mode 100644 index 000000000..a372dbc00 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_55_backprop_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_80_inference.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_80_inference.png new file mode 100644 index 000000000..43b6927e4 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_80_inference.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_80_inference_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_80_inference_dark.png new file mode 100644 index 000000000..eecc0f80d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/nn_explained_80_inference_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/tokenization.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/tokenization.png new file mode 100644 index 000000000..d2e2dbee7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/_img/tokenization.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/index.mdx new file mode 100644 index 000000000..53f227dba --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/010_ai_models_deep_dive/index.mdx @@ -0,0 +1,33 @@ +--- +title: "10 個の AI モデル:やさしい深掘り" +description: "ソフトウェアエンジニアおよび AI ビルダー向けの AI モデルに関する実践的な入門ガイドです。" +sidebar_position: 10 # Like a subject number (e.g. CS101) +--- + +## ユニット概要 + + + +AI モデルの世界は、広大で高くそびえる知識の塔であり、なおかつ急速に拡大し続けています。このコースだけでその全体を網羅するのは不可能だとしても、皆さんは驚かないでしょう。 + +しかし私たちは、 AI ビルダーにとって重要な事項について詳細な概要を提供することを目指しています。 + +### 前提条件 + +- なし + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/10_intro_weaviate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/10_intro_weaviate.mdx new file mode 100644 index 000000000..04e9f3ef8 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/10_intro_weaviate.mdx @@ -0,0 +1,172 @@ +--- +title: Weaviate 入門 +description: Weaviate 理論の概要 +--- + +## Weaviate とは + +import ReactPlayer from 'react-player/lazy' + + +
+ + Weaviate はオープンソースの ベクトル データベースです。ですが、それは具体的にどういう意味でしょうか?ここで詳しく見ていきましょう。 + +### ベクトル データベース + + Weaviate は、必要な情報を素早く正確に取得できる優れたツールです。その核心となるのが、卓越した **ベクトル データベース** である点です。 + +従来の SQL を使うリレーショナルデータベースなどはご存じかもしれません。データベースは情報を整理し、保存し、検索できます。**ベクトル** データベースも同じことができますが、大きな違いは「類似度」に基づいて操作できる点です。 + +#### 従来の検索方法 + +ヨーロッパの都市に関する記事を収めたリレーショナルデータベースから、「主要な」ヨーロッパの都市を取得したいと想像してください。SQL で次のようなクエリを書くかもしれません。 + +```sql +SELECT city_name wiki_summary +FROM wiki_city +WHERE (wiki_summary LIKE '%major European city%' OR + wiki_summary LIKE '%important European city%' OR + wiki_summary LIKE '%prominent European city%' OR + wiki_summary LIKE '%leading European city%' OR + wiki_summary LIKE '%significant European city%' OR + wiki_summary LIKE '%top European city%' OR + wiki_summary LIKE '%influential European city%' OR + wiki_summary LIKE '%notable European city%') + (… and so on) +``` + +このクエリは、`wiki_summary` 列にこれらの文字列(`major`、`important`、`prominent` など)が含まれる都市を返します。 + +多くの場面で問題なく機能しますが、この方法には大きく 2 つの制約があります。 + +#### 従来検索の制約 + +この検索方法では、概念を表すかもしれない語句を自分で特定する必要があります。これは簡単ではありません。 + +さらに、結果として得られたオブジェクトをどのようにランキングするかという問題も解決できません。 + +上記の検索では、関連性の低い「別のヨーロッパの都市」についての記述がたった一度登場しただけのエントリでも、パリやローマといった高い関連性を持つエントリと同じ重み付けになります。 + +ベクトル データベースは、類似度検索によってこの作業をよりシンプルにします。 + +#### ベクトル検索の例 + +完全一致を探す代わりに、「Major European city」に *最も近い* オブジェクトを検索するクエリを実行できます。 + +その結果として返ってくるのは、クエリとの *類似度でランク付けされた* エントリのリストです。 + +言い換えると、結果は「Major European city」というアイデア、つまり意味に対する類似度を反映します。 + +さらに、 Weaviate はデータを類似度に基づいて「インデックス化」するため、この種のデータ取得を非常に高速に行えます。 + + Weaviate はこれらすべてを手助けし、実際にはさらに多くのことが可能です。別の言い方をすれば、 Weaviate は情報の活用方法を強化します。 + +:::info ベクトル検索 vs セマンティック検索 +ベクトル検索は「セマンティック検索」とも呼ばれます。意味(セマンティクス)の類似度に基づいて結果を返すためです。 +::: + +### オープンソース + + Weaviate はオープンソースです。つまり、その [コードベースはオンラインで公開](https://github.com/weaviate/weaviate) されており、誰でも閲覧・利用できます[(1)](#-notes)。 + +しかも、それはどのように利用しても *同じ* コードベースです。自身の PC で動かす場合も、クラウド環境で動かす場合も、マネージドサービスである [Weaviate Cloud (WCD)](https://console.weaviate.cloud/) を使う場合も、まったく同じ技術を使用しています。 + +そのため、希望すれば自身のデバイスで無料で Weaviate を動かしたり、利便性のためにマネージドサービスを利用したりできます。さらに、実際に何を動かしているかを確認でき、オープンソースコミュニティの一員として開発に貢献することも可能です。 + +また、 Weaviate に関する知識はローカル、クラウド、マネージドインスタンス間で互換性があります。WCD で学んだことはローカル環境でも同様に適用でき、その逆も同じです。😉 + +### 情報をダイナミックに + +情報を本のような静的なものとして捉えがちですが、 Weaviate と現代の AI 駆動型言語モデルを組み合わせれば、単に静的情報を取得するだけでなく、その上に簡単に構築できます。以下の例をご覧ください。 + +#### 質問応答 + +Wikipedia のエントリ一覧があるとして、 Weaviate に次のように尋ねられます。 + +:::note We asked Weaviate: +When was Lewis Hamilton born? +::: + +すると、次のように回答します。 + +:::note Weaviate responded: +Lewis Hamilton was born on January 7, 1985. ([check for yourself](https://en.wikipedia.org/wiki/Lewis_Hamilton)) +::: + +#### 生成検索 + +あるいは、 Weaviate で取得した情報を使って文章を合成することもできます。 + +次の例では、「レーシングドライバー」に関するエントリを検索し、以下の形式で結果を生成しています。 + +:::note We asked Weaviate: +Write a fun tweet encouraging people to read about this: ## \{title} by summarizing highlights from: ## \{wiki_summary} +::: + +生成された結果は以下のとおりです。 + +:::note Weaviate responded: +Check out the amazing story of Lewis Hamilton, the 7-time Formula One World Drivers' Championship winner! From his humble beginnings to becoming one of the world's most influential people, his journey is an inspiring one. #LewisHamilton #FormulaOne #Motorsport #Racing +::: + +これらに加え、ベクトライゼーション、要約、分類など、さらに多くの機能をユニットで取り上げます。 + +現時点では、 Weaviate はベクトル データベースを核とし、取得した情報に対して AI ツールを活用してより多くのことを実現できる、と覚えておいてください。 + +## まとめ + +このセクションでは、 Weaviate が何であるか、そして概要レベルでどのように機能するかを学びました。また、ベクトル検索とは「類似度ベースの検索方法」であるという高レベルの概念も紹介しました。 + +### 練習問題 + + + + + + +### 主なポイント + +- Weaviate はオープンソースのベクトルデータベースです。 +- Weaviate のコアライブラリは、ローカル、クラウド、または WCD で実行しても同じです。 +- ベクトル検索は類似度ベースの検索です。 +- Weaviate は、取得したデータを返す前に変換することもできます。 + +## 注記 + +(1) もちろん、ライセンス条件に従います。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const weaviateOpenSource = [ + { + questionText: 'What is the difference in the Weaviate codebase between local and cloud deployments?', + answerOptions: [ + { answerText: 'Cloud deployments always include additional modules.', isCorrect: false, feedback: 'Cloud deployments of Weaviate do not include any special, or additional, modules.'}, + { answerText: 'Local deployments are optimized for GPU use.', isCorrect: false, feedback: 'GPU usage can be enabled for inference whether locally or remotely deployed.'}, + { answerText: 'Cloud deployments are optimized for scalability.', isCorrect: false, feedback: 'We agree that cloud deployments should be optimized for scalability. But the Weaviate codebase is built for scalability regardless of deployment location.'}, + { answerText: 'None, they are the same.', isCorrect: true, feedback: 'They are the same, open-source codebase available on GitHub.'}, + ], + }, +]; +export const vectorSearchDefinition = [ + { + questionText: 'What is the best description of vector search?', + answerOptions: [ + { answerText: 'Vector search is a directional search.', isCorrect: false, feedback: 'The definition of "vector" in this context is not direction-related.'}, + { answerText: 'Vector search is a similarity-based search.', isCorrect: true, feedback: 'It searches a data collection or database for proximity in its representation of "meaning".'}, + { answerText: 'Vector search is a number-based search.', isCorrect: false, feedback: 'This is partially true, but not the best answer. While there are numbers involved, that description does not quite capture the key concept of vector searches.'}, + ], + }, +]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/15_overview_vectors.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/15_overview_vectors.mdx new file mode 100644 index 000000000..3a53c61be --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/15_overview_vectors.mdx @@ -0,0 +1,110 @@ +--- +title: ベクトル - 概要 +description: Weaviate 理論におけるベクトルの概念 +--- + +## ベクトルとは + +import ReactPlayer from 'react-player/lazy' + + +
+ +Weaviate が [ベクトルデータベース](https://weaviate.io/blog/what-is-a-vector-database) であり、ベクトル検索が類似度ベースであることはすでに説明しました。では、ベクトルとは何でしょうか。 + +ここで言うベクトルとは、 `[1, 0]` や `[0.513, 0.155, 0.983, ..., 0.001, 0.932]` のように数字を並べたものです。これらのベクトルは「意味」を捉えるために使われます。 + +少し奇妙に思えるかもしれませんが、実は知らずにベクトルを使って意味を表現したことがあるかもしれません。たとえば写真編集ソフトや MS Paint を使ったことがあれば、RGB カラーシステムに触れたはずです。 + +### 数値による意味の表現 + +RGB システムでは 3 つの数字の組み合わせで色を表します。例: + +- ( 255, 0, 0 ) = 赤 +- ( 80, 200, 120 ) = エメラルド + +ここでは、各数字が「赤・緑・青」のダイヤルのような役割を果たしています。 + +これが数百、数千のダイヤルになったものを想像してみてください。それがベクトルで意味を表現するイメージです。GPT-x などの最新の機械学習モデルや Weaviate と連携するモデルは、テキスト・コード・画像・動画などあらゆるオブジェクトの「本質」や「意味」をベクトルで表現します。 + +## Weaviate におけるベクトル埋め込み + + + +オブジェクトの意味を表すベクトルは「ベクトル埋め込み」と呼ばれます。 + +Weaviate はデータオブジェクトと対応するベクトル埋め込みをインデックス化・保存することでベクトル検索を実現します。ベクトル埋め込みは機械学習モデルから得られます。 + +平たく言えば、Weaviate はデータを「クエリと似ている順」に取り出せるよう整理します。これを高速に行うために Weaviate は従来のデータベースにはない 2 つの処理を行います。 + +- 類似度の定量化 +- ベクトルデータのインデックス化 + +これらが Weaviate の高速ベクトル検索を支えています。 + +### 類似度の定量化 + +ベクトル検索は類似度ベースと述べましたが、実際にはどのように「似ている」を判断するのでしょうか。2 つのテキストや画像、オブジェクト全般が似ているとはどういう意味でしょうか。 + +これは一見シンプルですが、掘り下げると非常に奥深いテーマです。 + +ここでは大まかに、機械学習 (ML) モデルがこのプロセスの鍵であると覚えておいてください。テキスト生成モデルと共通点を持つこれらのベクトライザー (vectorizer) モデルは、新しいテキストを生成する代わりに、テキストや他のメディアの「意味」を捉えます。詳細は後ほど扱います。 + +### (ベクトル)データのインデックス化 + +ベクトル検索は計算負荷が高くなりがちです。 + +そこで Weaviate は、おおよその最近傍探索 (ANN) インデックスと転置インデックスを組み合わせて使用します。ANN インデックスにより超高速なベクトル検索が可能になり、転置インデックスにより Boolean 条件でのフィルタリングが行えます。 + +詳しくは後のセクションで説明しますが、ここでは Weaviate が高速なベクトル検索とフィルタリングを同時に実現していると理解しておけば十分です。 + +## 振り返り + +このセクションでは、ベクトルとは何か、そして Weaviate がどのようにベクトルを活用しているかを俯瞰しました。また、高速なベクトル検索を支える Weaviate の 2 つの重要な機能にも触れました。 + +### 復習課題 + +:::tip Self-reflection +自分の言葉で「ベクトル」とは何か説明できますか? +::: + + + +### 重要なポイント + +- ベクトルは、オブジェクトの意味や本質を捉える数値列です。 +- 機械学習モデルは、異なるオブジェクト間の類似度を定量化し、ベクトル検索に不可欠です。 +- Weaviate は ANN インデックスと転置インデックスを組み合わせ、高速なベクトル検索とフィルタリングを実現します。 + +## Questions and feedback + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + +import Quiz from '/src/components/Academy/quiz.js' +export const howWeaviateWorks = [{ + questionText: '次のうち正しい文はどれですか?', + answerOptions: [ + { + answerText: 'Weaviate にはオブジェクト間の類似度を定量化する方法がない。', + isCorrect: false, + feedback: 'Weaviate は類似度ベースのベクトル検索を行います。', + }, + { + answerText: 'Weaviate にあるインデックスはベクトルインデックスのみである。', + isCorrect: false, + feedback: 'ベクトルインデックスに加えて、Weaviate は転置インデックスも使用します。', + }, + { + answerText: 'Weaviate は機械学習モデルである。', + isCorrect: false, + feedback: 'Weaviate は多様なモデルと連携して類似度を判断しますが、Weaviate 自体は機械学習モデルではなくベクトルデータベースです。', + }, + { + answerText: '上記のいずれでもない', + isCorrect: true, + feedback: 'すべて誤りです!', + }, + ] +}]; \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/20_examples_1.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/20_examples_1.mdx new file mode 100644 index 000000000..eca7c1b73 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/20_examples_1.mdx @@ -0,0 +1,96 @@ +--- +title: 例 1 - クエリ +description: Hello Weaviate Theory - 例 パート 1 +--- + +## ベクトルの活用 + +import ReactPlayer from 'react-player/lazy' + + +
+ +ここでは、Weaviate でできることをいくつか例示します。 + +まず、デモデータベースを使ってベクトル検索を試してみましょう。入力テキスト・ベクトル・オブジェクトなど、さまざまなクエリ方法で類似オブジェクトを取得する方法を学びます。 + +さらに、ベクトル検索とキーワード検索を比較し、両者の違いを確認したうえで、フィルターを使って両方を組み合わせる方法も紹介します。 + +### ベクトル検索デモ + +最初の例として、デモデータセットを検索してみます。これはクイズ番組 *Jeopardy!* から抜粋した少量の質問を含んでいます。 + +たとえばクイズナイトを開催するとして、「映画に登場する動物」に関する問題が欲しいとします。従来のデータベースなら、次のように単語一致で探すことになるでしょう。 + +```sql +SELECT question, answer +FROM jeopardy_questions +WHERE ( + question LIKE '%animal%' + OR question LIKE '%creature%' + OR question LIKE '%beast%' + ) +AND ( + question LIKE '%movie%' + OR question LIKE '%film%' + OR question LIKE '%picture%' + OR question LIKE '%cinema%' + ) + +``` + +このクエリを書くのは大変です。しかも特定の動物名まで条件に追加する必要があるかもしれません。 + +Weaviate のクエリはもっと直感的です。次のクエリを実行するとどうなるか見てみましょう。 + +:::note We searched Weaviate for: +animals in movies +::: + +Weaviate は次の回答を上位に返しました。 + +:::note Weaviate retrieved: +- **meerkats**: *The Lion King* に登場するティモンのような哺乳類のグループ +- **dogs**: スクービー・ドゥー、グーフィー、プルートは漫画版 +- **The Call of the Wild Thornberrys**: 犬のバックを描いたジャック・ロンドンの物語が、動物と話せるエリザが主人公のニックのカートゥーンと合体 +::: + +どの結果にも「animal」や「movie」という語がまったく含まれていないのに、関連性が高いことに注目してください。 + +これこそがベクトル検索の強みです。完全一致せずとも関連オブジェクトを見つけられます。 + +### ベクトルの類似度 + +ベクトル検索では、クエリと返却オブジェクト間の定量的な類似度を取得できます。これは `distance` と呼ばれます。 + +`distance` は、返却オブジェクトとクエリの類似度合いを示します。 + +「それは具体的にどういう意味なのか」「誰が類似度を決めるのか」と疑問に思われるかもしれません。良い質問です! 詳しくは後ほど説明します。 + +ここでは、「値が小さいほど 2 つのオブジェクトが互いに似ている」と覚えておいてください。 + +## まとめ + + + + + +### 重要ポイント + +- ベクトル検索は、テキストを完全一致させなくても関連オブジェクトを見つけられます。 +- ベクトル検索では、distance 値がクエリと返却オブジェクトの類似度を示します。 +- distance が小さいほど類似度が高くなります。 +- ベクトル検索は、キーワード検索やフィルターと組み合わせて、より精緻な検索結果を得ることができます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/25_examples_2.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/25_examples_2.mdx new file mode 100644 index 000000000..1e08ba2b5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/25_examples_2.mdx @@ -0,0 +1,109 @@ +--- +title: 例 2 - 検索を超えて +description: Hello Weaviate Theory - 例 パート 2 +sidebar_position: 25 +--- + +## ベクトル検索のその先 + +import ReactPlayer from 'react-player/lazy' + + +
+ +Weaviate では、静的な情報を取得するだけでなく、さらに多くのことができます。 + +データベースからオブジェクトを単に取得するだけでなく、さらに活用する例をいくつか見てみましょう。 + +この Wikipedia エントリから情報を抽出します。 + +
+ 「シドニー・オペラハウス」Wikipedia サマリー + +シドニー・オペラハウスは、シドニーにある複数会場型の舞台芸術センターです。シドニー湾の海岸沿いに位置し、世界で最も有名かつ独特な建築物の一つであり、20 世紀建築の傑作と広く評価されています。デンマーク人建築家ヨーン・ウツソンが設計し、ピーター・ホール率いるオーストラリアの建築チームが完成させました。1957 年に国際設計コンペでウツソン案が選ばれて以降プロジェクトが始動し、1973 年 10 月 20 日にエリザベス 2 世女王によって正式に開館しました。ニューサウスウェールズ州政府(首相ジョセフ・ケーヒル)が 1958 年に建設を承認し、ウツソンが工事を指揮しました。建設決定後にはコストやスケジュールの超過、そして最終的なウツソンの辞任などの事情がたびたび取り沙汰されています。建物とその周辺は、シドニー湾のベネロン・ポイント全体を占め、シドニー・コーブとファーム・コーブの間、シドニー中心業務地区と王立植物園に隣接し、シドニー・ハーバーブリッジの近くに位置します。 + +複数の公演会場を備える建物では年間 1,500 件以上の公演が行われ、120 万人以上が来場します。オペラ・オーストラリア、シドニー・シアター・カンパニー、シドニー交響楽団という 3 つの常駐団体を含む多数のアーティストが公演を行います。オーストラリアでも最も人気のある観光名所の一つで、年間 800 万人以上が訪れ、約 35 万人がガイド付きツアーに参加します。建物はニューサウスウェールズ州政府機関のシドニー・オペラハウス・トラストによって管理されています。 + +2007 年 6 月 28 日、シドニー・オペラハウスはユネスコ世界遺産に登録されました。それ以前にも 1980 年から国定遺産リスト(現在は廃止)、1983 年からオーストラリア国民信託、2000 年からシドニー市ヘリテージ・インベントリ、2003 年からニューサウスウェールズ州ヘリテージ登録、2005 年からオーストラリア国定遺産リストに登録されていました。また、世界新七不思議キャンペーンのファイナリストにも選ばれています。 + +
+ +Weaviate は、この Wikipedia エントリを処理する際に [データオブジェクト](/weaviate/concepts/data) を生成します。オブジェクトはクラスに保存され、クラスはリレーショナルデータベースにおけるテーブルに概ね相当します。オブジェクトはそのテーブルのエントリに類似しています。 + + +### 生成検索 + +Weaviate はこれらのエントリをさらに活用できます。データストアからオブジェクトを取り出し、そのオブジェクトを使って新しい文章を生成するよう依頼できます。たとえば、シドニー・オペラハウスのエントリを含むオブジェクトを用いて新しいテキストを作成できます。 + +以下は `GraphQL` クエリによる生成検索の例です。 + +```graphql +{ + Get { + WikiArticle( + nearText: { + concepts: ["Sydney Opera House"] + } + limit: 1 + ) { + title + wiki_summary + _additional { + generate( + singleResult: { + prompt: """ + Write a fun tweet encouraging people to read about this: ## {title} + by summarizing highlights from: ## {wiki_summary} + """ + } + ) { + singleResult + error + } + } + } + } +} +``` + +このサンプルコードは Wikipedia エントリを基にツイートを生成します。 + +
+ レスポンスを見る + +:::note Weaviate の返答: +Explore the world-famous Sydney Opera House and its incredible architecture! From the iconic design to the amazing performances, there's something for everyone to enjoy. #SydneyOperaHouse #Explore #Architecture #Performances #Experience +::: + +
+ +このプロセスは `generative search`(生成検索)の一例です。生成検索では、Weaviate が情報を取得し、それを大規模言語モデル(LLM)で再構成します。これは情報の取り扱い方を大きく変える強力な機能です。 + +プロンプトを変えることで、異なる結果を生成できます。 + +### 次のステップ + +Q&A や生成検索のようなツールを使うと、情報がまさに生き生きと活用できるようになります。 + +## レビュー + + + +### 主なポイント + +- Weaviate は質疑応答機能を用いてテキストから知識を抽出し、与えられたテキストに基づいて最も関連性の高いオブジェクトと実際の解答を特定できます。 +- 生成検索を利用すると、情報を取得して内容を再形成・再利用でき、たとえば Wikipedia エントリからツイートを生成できます。 +- Weaviate のこれら高度な機能により、データ内の情報との対話方法や活用方法が大きく変革します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/90_next_steps.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/90_next_steps.mdx new file mode 100644 index 000000000..c0b6693ef --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/90_next_steps.mdx @@ -0,0 +1,40 @@ +--- +title: 次のステップ +--- + +Weaviate の理論的な概要をお読みいただいた後は、実際に手を動かしてみたくなるかもしれません。そんなときは、Academy に用意されている Python または TypeScript/JavaScript のコースをぜひご覧ください。 + +Python 向けの初心者コースは次のとおりです: +- [101T: テキスト データを扱う](../../py/starter_text_data/index.md) +- [101V: 独自のベクトルを扱う](../../py/starter_custom_vectors/index.md) +- [101T: マルチモーダル データを扱う](../../py/starter_multimodal_data/index.md) + +TypeScript/JavaScript 向け: +- [TypeScript で始める Weaviate 入門](/academy/js/starter_text_data) + +### アカデミー + +- [名前付きベクトル](../../py/named_vectors/index.md): Weaviate でデータを柔軟に表現するために名前付きベクトルを使用する方法を学びます。 +- [どの検索が最適か?](../../py/standalone/which_search/index.mdx): Weaviate のさまざまな検索タイプと、その使い分けを学びます。 +- [チャンク化](../../py/standalone/chunking/index.mdx): 長いドキュメントの検索を最適化するためにチャンク化を活用する方法を学びます。 + +### ドキュメンテーション + +- How-to guides + - [How-to: Manage collections](/weaviate/manage-collections/index.mdx) と [How-to: Manage objects](/weaviate/manage-objects/index.mdx) では、コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除といったデータ操作方法を解説しています。 + - [How-to: search](/weaviate/search/index.mdx): すべての検索操作のコード例を掲載しています。 + - [How-to: configure Weaviate](/weaviate/configuration/index.mdx): Weaviate の設定方法を解説しています。たとえば [PQ](/weaviate/configuration/compression/pq-compression.md) や [BQ](/weaviate/configuration/compression/bq-compression.md) の圧縮、[backups](/deploy/configuration/backups.md)、[replication](/deploy/configuration/replication.md) などです。 +- [Concepts guides](/weaviate/concepts/index.md): Weaviate のアーキテクチャと概念を理解するためのガイドです。 +- [API reference](/weaviate/api/index.mdx): Weaviate の API についての詳細情報です。 + +import CTASocials from '../../py/_snippets/cta_socials.mdx'; + + + +またお会いしましょう! 👋 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/index.mdx new file mode 100644 index 000000000..f4e299580 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/101_hello_weaviate/index.mdx @@ -0,0 +1,42 @@ +--- +title: 101 Hello, Weaviate +description: Weaviate とそのデータ管理機能の基本的な紹介 +sidebar_position: 101 # Like a subject number (e.g. CS101) +--- + +## ユニット概要 + +import ReactPlayer from 'react-player/lazy' + + +
+ + + +ようこそ! + +ここから、Weaviate とともにベクトルの世界を旅していきます。このユニットでは、Weaviate の基本について概観します。 + +まず、Weaviate が何であり、何ができるのかを理解します。次に、ベクトルデータベースとベクトル検索について学んだ後、実際に Weaviate を起動し、ベクトル検索を実行します。 + +このユニットを終える頃には、コース全体をスムーズに学習し、さらに自身のプロジェクトで Weaviate を活用するための強固な基盤が身につきます。 + +### 前提条件 + +- なし + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/150_search_types/_index.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/150_search_types/_index.md new file mode 100644 index 000000000..61adb97f4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/150_search_types/_index.md @@ -0,0 +1,27 @@ +--- +title: 150 種類の検索 +description: Weaviate におけるさまざまな検索タイプの概要 +sidebar_position: 150 # Like a subject number (e.g. CS101) +--- + +## ユニット概要 + +### 前提条件 + +- なし + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/150_search_types/_notes.md b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/150_search_types/_notes.md new file mode 100644 index 000000000..108badd08 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/150_search_types/_notes.md @@ -0,0 +1,52 @@ +### ベクトル埋め込み + +ベクトル埋め込みとは、高次元空間におけるオブジェクトの数値表現です。これらのベクトルは、オブジェクトの意味を捉えるように訓練されたモデルによって生成されます。 + +ベクトル埋め込みは次のようになります: + +```json +[0, 1, 0, 0, 1] +``` + +または次のようになります: + +```json +[0.158, 0.011, 0.840, 0.577, 0.897, ..., 0.144] +``` + +ベクトル埋め込みは一般的に 300 から 2048 次元の間ですが、正確な次元数はモデルによって異なります。ベクトルが長いほど、オブジェクトについてより多くの情報を保持できます。しかしその一方で、保存・インデックス作成・検索に必要なリソースも増えます。 + +同じモデルから生成されたベクトル埋め込みは「互換性がある」あるいは「同じベクトル空間にある」と言われます。 + +:::tip 類推: 言語としてのベクトル埋め込み +ベクトル埋め込みを直感的に理解する方法として、言語にたとえることができます。 2 人が意思疎通するには同じ言語を話す必要があるのと同様に、 2 つのベクトルを比較するには同じベクトル空間に属している必要があります。同じベクトル空間にない場合、たとえ長さが同じでも、それらの値を比較しても意味がありません。 +::: + +## ベクトル距離 + +ベクトル距離は、高次元空間において 2 つのベクトルがどれだけ近いか、または離れているかを示します。これは、ベクトル埋め込みに基づいて、オブジェクトがクエリと「意味的」にどれだけ類似しているかを測る指標です。 + +簡単な例として、色「SkyBlue」「LightSteelBlue」「DarkOrange」を考えてみましょう。これらの色は、RGB の値を成分とする 3 次元空間のベクトルとして表現できます。 + +| 色 | ベクトル (R,G,B) | +|-----------------|------------------| +| SkyBlue | (135, 206, 235) | +| LightSteelBlue | (176, 196, 222) | +| DarkOrange | (255, 140, 0) | + +「SkyBlue」と「LightSteelBlue」のベクトルは、「DarkOrange」のベクトルより互いにずっと近く、これは淡い青色同士とオレンジ色との差を反映しています。 + +ベクトルデータベースに「SkyBlue」と「DarkOrange」のベクトルが保存されている場合、「LightSteelBlue」のクエリベクトルで検索すると、最も近い結果として「SkyBlue」が返されます。 + +テキスト・画像・音声など、より複雑なオブジェクトに対するベクトル検索も同じ原理で動作します。オブジェクトを高次元空間で表現するように訓練されたモデルがベクトルを生成し、ベクトル間の距離がオブジェクト同士の類似度を表します。 + +### 距離と検索品質 + +互換性のあるベクトルは、程度の差はあれどれも互いに似ているため、クエリがデータセット内のオブジェクトとあまり似ていなくても検索結果の「上位」が返ってきます。 + +「Red」「Crimson」「LightCoral」のベクトルだけが格納されたデータベースに「SkyBlue」のクエリベクトルで検索しても、検索は(たとえば「Red」といった)結果を返します。これはクエリと意味的に似ていなくても、相対的に最も近いベクトルを返すだけだからです。 + +検索結果を有意義なものにするために、次のような対策を検討してください: + +- **しきい値を設定する**: 結果に対して最小の類似度スコアを設け、クエリと十分に似ていない結果を除外します。 +- **フィルターを適用する**: [フィルター](../filtering.md) を使用して、メタデータやプロパティなど他の条件に基づいて結果を除外します。 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/10_introduction.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/10_introduction.mdx new file mode 100644 index 000000000..f1dbe3c6a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/10_introduction.mdx @@ -0,0 +1,107 @@ +--- +title: 概要 +description: 埋め込みモデル選択の重要性 +--- + +import ThemedImage from '@theme/ThemedImage'; + +## 埋め込みモデル選択の重要性 + +Embedding モデルとは、オブジェクトの「意味」を捉える AI モデルです。 この [以前の AI モデルに関するモジュール](../010_ai_models_deep_dive/index.mdx) では、Embedding モデルがテキスト・画像・音声などを数値の列へ変換することで意味を表現できることを紹介しました。 + +import NNEmbeddingModels from '../010_ai_models_deep_dive/_img/nn_explained_50_embedding_models.png'; +import NNEmbeddingModelsDark from '../010_ai_models_deep_dive/_img/nn_explained_50_embedding_models_dark.png'; + + + +ご想像のとおり、これは容易なタスクではありません。そして過去 10 年ほどで劇的な進歩がありました。 例として、その期間の両端に位置する 2 つのモデル性能の違いを見てみましょう。 + +### 評価例 + +こちらは [サンプルデモアプリ](https://github.com/databyjp/emb_eval_toybox) のスクリーンショットで、Embedding 評価を行っています。 + +この例では、`“How do I make chocolate chip cookies from scratch”` というクエリに最も一致するドキュメントを、20 件の候補ドキュメントから検索します。 + +20 件の各ドキュメントには `“score”` 属性があり、値が高いほど関連性が高いことを示しています。 + +候補ドキュメント + +では、2 つの異なる Embedding モデルを用いて最適なオブジェクトを取得するとどうなるでしょうか。以下の 2 つのモデルを使用します。 + +- `FastText (fasttext-en-vectors)`( 2015 年;[モデルカード](https://huggingface.co/facebook/fasttext-en-vectors)) +- `snowflake-arctic-embed-l-v2.0`( 2024 年;[モデルカード](https://huggingface.co/Snowflake/snowflake-arctic-embed-l-v2.0)) + +まず、 2015 年の `FastText` モデルで検索した結果の概要です。 + +FastText の検索結果 + +FastText が特定した最上位の結果は、クッキー作りの問題点を修正する方法を扱っており、ある程度関連しています。しかし理想的なのは手順を示すレシピですので、完全には一致していません。 + +残り 2 件はクエリと無関係です。レシピではありますがクッキー用ではありません。 + +改善の余地が大きいと言えるでしょう。 + +続いて、 2025 年の `snowflake-arctic-embed-l-v2.0` モデルでの結果です。 + +Snowflake Arctic の検索結果 + +`arctic` の Embedding は理想的な最上位結果を正しく特定しました。実際、期待された上位 2 件が 3 位以内に入っています。残り 1 件もチョコチップクッキーに関連しており、多少トピックがずれている程度です。 + +### 評価基準 + +これらのモデルを `nDCG@k` などの標準指標で比較することもできます。 + +今回のシナリオでは、 2 つのモデルのスコアは以下のとおりです。 + +| モデル | nDCG@10 | +| --- | --- | +| `FastText` | 0.595 | +| `snowflake-arctic-embed-l-v2.0` | 0.908 | + +
+ nDCG@k とは? + +`nDCG` は情報検索で返された結果を評価する指標です。最も関連性の高い結果をリストの上位に配置するほど高く評価されます。`@k` は上位 `k` 件のみを対象とすることを示します。 + +[詳しくはこちら](https://weaviate.io/blog/retrieval-evaluation-metrics#normalized-discounted-cumulative-gain-ndcg) + +
+ +生成される Embedding のサイズも重要な要素です。 + +Embedding の次元数はおよそ 300 から数千まで大きく異なります。たとえば、法律事例に関する質問に回答する AI ボットを提供するサービス事業者を考えてみましょう。 100 万件のドキュメントを持つベクトルデータベースでは、`nv-embed-v2` というモデルを使うと 3.3 TB ものメモリが必要になる可能性がありますが、`embed-english-light-v3.0` なら 300 GB で済むかもしれません。 (下図は人気モデルをいくつか取り上げ、それぞれがメモリ要件にどのように影響するかを比較したものです。) + +100 万ドキュメントの推定メモリ要件 + +これらの簡単な例からも、Embedding モデル選択が検索品質やリソース要件などに大きな影響を与えることが分かります。 + +過去 10〜15 年で Embedding モデルの世界は大きく進歩しました。実際、革新は現在も続いています。word2vec、FastText、GloVe、BERT、CLIP、OpenAI ada、Cohere multi-lingual、Snowflake Arctic、ColBERT、ColPali といった名前を聞いたことがあるかもしれません。 + +各モデル(またはアーキテクチャ)は、モデル構造・学習データ・学習手法・モダリティ・効率性など、何らかの面で改良をもたらします。 + +それでは次のセクションから、Embedding モデル選定のワークフローを探っていきましょう。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/20_workflow_selection.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/20_workflow_selection.mdx new file mode 100644 index 000000000..51be2806c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/20_workflow_selection.mdx @@ -0,0 +1,53 @@ +--- +title: モデル選定のワークフロー +description: 埋め込みモデル選定のワークフロー +--- + +import ThemedImage from '@theme/ThemedImage'; + +## 概要 + +適切な埋め込みモデルを選択することは複雑な作業です。その大きな理由は、各モデルがトレードオフを伴う強みと弱みを持っているためです。 + +明らかなトレードオフの 1 つは、モデルの性能・サイズ・コストの関係です。下の図は、埋め込みモデルにおけるモデルサイズと検索性能の一般的な相関を示しています。 + +埋め込みモデル評価 + +図からは、モデルサイズが大きいほど性能が高いという明確な正の相関が見て取れます。つまり、性能の高いモデルは一般的にサイズも大きくなります。その結果、より多くのメモリと計算資源を必要とし、コストが高くなり速度も遅くなります。 + +言い換えると、 `nv-embed-v2` のような大型モデルは、 `snowflake-arctic-embed-m-v1.5` のような小型モデルより検索性能が優れているかもしれませんが、実行や利用にかかる費用は高くなる可能性があります。 + +しかし、検討すべき観点はほかにも多数あります。例として以下が挙げられます。 + +- `gemini` のようなプロプライエタリモデルは高い性能を示すかもしれませんが、ローカル推論を希望するユーザーの要件を満たさない場合があります。 +- モデルが標準ベンチマークで高い性能を示していても、法律・医療・コーディングなどの専門領域のデータでは性能が落ちることがあります。 +- ローカルモデルは運用コストが低い場合がありますが、組織に長期的なインフラ保守のための専門知識やリソースが不足しているかもしれません。 + +このように複雑な状況では、体系的なアプローチによって自分の要件に基づく適切な意思決定が可能になります。以下はその一例です。 + + + +このワークフローは、上図のように 4 つの主要なステージで構成されています。 + +1. **ニーズの特定**: 要件や好みを明確にし、今後の指針となるガイドラインを策定します。 +2. **候補モデルのリストアップ**: 特定したニーズと公開情報を基に、適合しそうなモデルをスクリーニングします。 +3. **詳細評価の実施**: 自分のユースケースに合わせて、選択したデータでモデルを評価します。 +4. **定期的な再評価**: 要件(データ・アプリケーション)や環境(新モデル・プロバイダー)の変化を継続的に監視します。 + +次に、各ステージを順番に確認します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/22_identify_needs.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/22_identify_needs.mdx new file mode 100644 index 000000000..be52c6b2e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/22_identify_needs.mdx @@ -0,0 +1,138 @@ +--- +title: 要件の特定と候補モデルの収集 +description: ニーズを特定し、候補モデルのリストを作成して、埋め込みモデル選定を始めましょう。 +--- + +import ThemedImage from '@theme/ThemedImage'; + +## ニーズの特定 + +体系的なモデル選定を行うには、まず要件を明確にすることが重要です。要件をカテゴリーごとに整理すると、埋め込みモデルを評価する際に関連する要素を漏れなく検討できます。 + +以下に主な検討ポイントを示します。 + +Identify your needs + +### データの特性 + +| 要素 | 主な質問 | 重要な理由 | +| --- | --- | --- | +| **モダリティ** | テキスト、画像、音声、それともマルチモーダル? | モデルは特定のモダリティ向けに構築されています。 | +| **言語** | どの言語をサポートする必要がありますか? | モデルは特定の言語向けに学習・最適化されており、性能にトレードオフが生じます。 | +| **ドメイン** | データは一般的か、それともドメイン特化(法律、医療、技術など)ですか? | ドメイン特化モデル(例: [医療](https://huggingface.co/blog/abhinand/medembed-finetuned-embedding-models-for-medical-ir))は専門用語や概念を理解できます。 | +| **長さ** | ドキュメントやクエリの平均的な長さは? | 入力トークンのコンテキストウィンドウはモデルごとに異なり、 256 トークンから 8192 トークンまでさまざまです。ただし、長いコンテキストウィンドウは計算量と待ち時間が指数的に増加します。 | +| **非対称性** | クエリとドキュメントに大きな違いがありますか? | 一部のモデルは非対称なクエリ‐ドキュメント比較向けに設計されています。たとえば `laptop won't turn on` というクエリで `Troubleshooting Power Issues: If your device fails to boot...` のようなドキュメントを容易に特定できます。 | + +### パフォーマンス要件 + +| 要素 | 主な質問 | 重要な理由 | +| --- | --- | --- | +| **精度**(リコール) | 上位結果をすべて取得することはどれほど重要ですか? | 高い精度を求める場合、より高価またはリソース集約的なモデルを選択する価値があります。 | +| **レイテンシ** | クエリはどれくらい速く処理する必要がありますか? | 大規模モデルは性能が高い一方で推論が遅くなることがあります。推論サービスでは、高速化はコスト増につながります。 | +| **スループット** | 想定クエリ量やトラフィックスパイクは? | 大規模モデルは処理能力が低い傾向があります。推論サービスではスループット増加がコスト増加を招きます。 | +| **ボリューム** | 処理するドキュメント数は? | 埋め込み次元が大きいほどベクトルストアのメモリ要件が増え、大規模運用時のリソースとコストに影響します。 | +| **タスクタイプ** | 検索のみか、それともクラスタリングや分類も行いますか? | モデルには得意不得意があります。検索に優れたモデルがクラスタリングでも優秀とは限りません。評価・選定基準に影響します。 | + +### 運用上の要素 + +| 要素 | 主な質問 | 重要な理由 | +| --- | --- | --- | +| **ハードウェア制限** | ホスティング・推論に利用可能な計算資源は? | ハードウェアの入手性(コスト、GPU/TPU の有無)が選択肢に大きく影響します。 | +| **API レート制限** | ホステッドモデルの場合、プロバイダーの制限は? | レート制限はアプリケーションのボトルネックや成長の妨げになります。 | +| **デプロイと保守** | 必要な技術的専門知識とリソースは? | 自前ホスティングが可能か、API ベースのホステッドオプションを検討すべきかを判断します。 | + +### ビジネス要件 + +| 要素 | 主な質問 | 重要な理由 | +| --- | --- | --- | +| **ホスティングオプション** | 自前ホスティングが必要か、クラウド API でもよいか? | 自前ホスティング ➡️ 操作性は高いが運用が複雑、API ➡️ 導入は簡単だが依存度が高い。 | +| **ライセンス** | 商用利用時のライセンス制限は? | 一部のモデルは特定のユースケースを禁止しています。 | +| **長期サポート** | モデルの継続利用に関する保証は? | モデルや企業が廃止された場合、アプリケーションの大幅な改修が必要になることがあります。 | +| **予算** | コスト上限や支出方針は? | 埋め込みコストは継続的に発生しますが、自前ホスティングは初期費用が高額です。 | +| **プライバシーとコンプライアンス** | データプライバシー要件や業界規制は? | 特定業界では専用モデルが必須となり、プライバシー要件がホスティング手段を制限する場合があります。 | + +これらの要件を文書化すると、理想的な埋め込みモデルの明確なプロファイルが作成され、選定プロセスで情報に基づくトレードオフを行いやすくなります。 + +## 候補モデルの収集 + +ニーズを特定したら、評価対象となる埋め込みモデルのリストを作成します。この作業により、詳細評価を有望な候補に絞り込めます。 + +現在、埋め込みモデルは数百種類あり、日々新しいモデルが発表されています。これだけ多くのモデルを単純なスクリーニングでさえ評価するのは時間がかかりすぎます。 + +そのため、次のような簡単なヒューリスティックを使って、まず初期リストを絞り込むことをお勧めします。 + +### モダリティで絞り込む + +これは最初に行うべき重要なフィルターです。モデルは設計・学習されたモダリティのみをサポートします。 + +たとえば Cohere の `embed-english-v3.0` はマルチモーダルですが、Snowflake の `snowflake-arctic-embed-l-v2.0` は単一モダリティです。 + +どれほど優れたモデルでも、 `snowflake-arctic-embed-l-v2.0` のようなテキスト専用モデルでは画像検索はできません。同様に `ColQwen` モデルはプレーンテキスト検索には使えません。 + +### すでに利用可能なモデルを優先する + +組織内で他のアプリケーションに埋め込みモデルを既に使用している場合、それらは優れた出発点になります。既に審査・評価・承認され、アカウントや請求も設定済みである可能性が高いからです。ローカルモデルの場合、インフラも整っているはずです。 + +これは他のサービスプロバイダー経由で利用できるモデルにも当てはまります。 + +たとえば Cohere、Mistral、OpenAI などのプロバイダーを通じて生成 AI モデルを既に使用している場合があります。また AWS、Microsoft Azure、Google Cloud などのハイパースケーラーが埋め込みモデルを提供していることもあります。 + +多くの場合、これらのプロバイダーから埋め込みモデルにもアクセスできるため、新しい組織のモデルより採用しやすいでしょう。 + +### 有名モデルを試す + +一般に、よく知られたモデルが人気なのには理由があります。 + +Alibaba、Cohere、Google、NVIDIA、OpenAI などの AI 業界のリーダー企業は、さまざまなモダリティ、言語、サイズの埋め込みモデルを提供しています。以下は各社の代表的なモデルファミリーです。 + +| プロバイダー | モデルファミリー | +| --- | --- | +| Alibaba | `gte`, `Qwen` | +| Cohere | `embed-english`, `embed-multilingual` | +| Google | `gemini-embedding`, `text-embedding` | +| NVIDIA | `NV-embed` | +| OpenAI | `text-embedding`, `ada` | + +他にも検討できるファミリーがあります。 + +たとえば、画像埋め込み用の `ColPali` ファミリー、マルチモーダル(画像とテキスト)向けの `CLIP` / `SigLIP` ファミリーが有名です。また `nomic`, `snowflake-arctic`, `MiniLM`, `bge` は言語検索モデルの代表例です。 + +これらの人気モデルはドキュメントや情報交換が豊富で、サポートも広く提供されています。 + +そのため、あまり知られていないモデルよりも導入・評価・トラブルシュートが容易です。 + +### ベンチマーク上位モデル + +標準ベンチマークで優れた性能を示すモデルも検討する価値があります。 [MTEB Leaderboard](https://huggingface.co/spaces/mteb/leaderboard) などのリソースで高性能モデルを確認できます。 + +以下のスクリーンショットは、 1 billion 未満のパラメータで `retrieval` 性能順に並べた MTEB の例です。 + +MTEB example - sorted by retrieval performance + +ここには既に紹介した `snowflake-arctic`、Alibaba の `gte`、BAAI の `bge` などのモデルが含まれています。 + +加えて、Microsoft Research の `intfloat/multilingual-e5-large-instruct` や JinaAI の `jinaai/jina-embeddings-v3` など、まだ紹介していない高性能モデルも簡単に見つかります。 + +2025 年時点で、MTEB には言語やモダリティの要件を評価する複数のベンチマークが含まれています。 + +ベンチマークを見る際は、適切なベンチマークセットと列を確認してください。以下の例では、画像検索用の MIEB で *Any to Any Retrieval* 列を基準にソートしています。 + +MIEB example - sorted by any to any retrieval + +MTEB はさまざまな指標でフィルタリングやソートができます。好みに合わせて並べ替え、リストにモデルを追加してください。 + +これらの手法を用いれば、短時間で扱いやすいモデルリストを作成できるはずです。このリストを手動で精査し、詳細なスクリーニングへと進みましょう。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/24_initial_screening.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/24_initial_screening.mdx new file mode 100644 index 000000000..d607bfe0a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/24_initial_screening.mdx @@ -0,0 +1,139 @@ +--- +title: 初期スクリーニングの実施 +description: 入手可能な情報を利用してモデル一覧を絞り込む +--- + +import ThemedImage from '@theme/ThemedImage'; + +## 概要 + +候補モデルのリストを適切なサイズ(最大で 10-20 件程度)まで絞り込めたら、手動でのレビューを開始できます。 + +この段階では、まとめた要件を利用可能なモデルの詳細と照らし合わせてスクリーニングを行います。多くの場合、公開モデルにはモデルカードやドキュメント、関連論文などを通じて概要情報が提供されています。 + +モデルカード + +すぐに確認できる要素と、そのチェック方法を以下に示します。 + +## スクリーニング要素 + +### コンテキスト長 + +入力コンテキスト長は、ドキュメントのチャンク全体の意味を考慮できるかどうかを左右する重要な要素です。最大入力コンテキスト長はモデルによって大きく異なります。例を挙げると次のとおりです。 + +- `all-MiniLM-L6-v2`: 256 トークン +- Cohere `embed-english-v3.0`: 512 トークン +- `snowflake-arctic-embed-l-v2.0`: 8192 トークン + +コンテキスト長を超える入力テキストは無視されます。一方、許容コンテキスト長が長くなるほど計算量とレイテンシは指数関数的に増加するのが一般的です。そのため、この点はテキストのチャンク化戦略とも相互に影響し合う重要なトレードオフとなります。 + +:::tip +ご自身のユースケースで取得したい「チャンク」がどの程度の大きさかを検討してください。一般的には 512 トークン以上のモデルであれば、ほとんどのユースケースで十分です。 +::: + +### モデルの目的と学習方法論 + +各種埋め込みモデルはそれぞれ異なるユースケースに最適化されています。これはモデルアーキテクチャ、学習データ、学習手法の設計に反映されています。 + +モデル提供者が公開している説明や学習過程の詳細を確認すると、そのモデルがユースケースに適しているかどうかを判断するうえで重要な手掛かりになります。 + +- **言語対応能力**: Snowflake の `snowflake-arctic-embed-l-v2.0` のように多言語に対応しているモデルもあれば、Cohere の `embed-english-v3.0` のように主に単一言語に対応しているモデルもあります。これらの言語能力は主に学習データと手法の選択に由来します。 +- **ドメイン露出**: 専門ドメイン(法務、医療、金融など)で学習されたモデルは、ドメイン固有のアプリケーションで一般に高い性能を発揮します。 +- **主なタスク**: プロバイダーによっては汎用埋め込みモデルを提供している場合もあれば、特定タスクに特化したモデルを提供している場合もあります。Google の `gemini-embedding` モデルは、あらゆるタスクとドメインで最先端性能を目指す万能型モデルとして設計されているようです([リリースブログ](https://developers.googleblog.com/en/gemini-embedding-text-model-now-available-gemini-api/))。一方、Snowflake の `arctic-embed` 2.0 モデルは検索タスクに焦点を当てています([リリースブログ](https://www.snowflake.com/en/engineering-blog/snowflake-arctic-embed-2-multilingual/))。 +- **ベースモデル**: 多くの場合、埋め込みモデルは既存モデルを元にして学習されます。元のモデルが持つ利点や欠点、とくにコンテキストウィンドウサイズやプーリング戦略といったアーキテクチャ上の特徴は、最終モデルにも引き継がれることがよくあります。 +- **学習手法(上級)**: モデルの学習技術について知識がある場合は、これもヒューリスティックとして役立ちます。たとえば、コントラスト学習で訓練されたモデルは検索タスクで高性能を示すことが多いです。さらに、ハードネガティブマイニングはコントラスト学習を強化する有用なテクニックです。 + +:::tip +目標に合致した能力を持つモデルを選びましょう。たとえば、アプリケーションで英語・フランス語・ドイツ語・中国語・日本語のテキストチャンクを検索する必要がある場合は、モデルカードと学習情報を確認し、検索性能や学習コーパスにこれらの言語が含まれているかをチェックしてください。 +::: + +### 次元数と最適化オプション + +埋め込みの次元数は、性能とリソース要件の両方に影響します。 + +経験則として、ベクトルデータベースに必要なメモリ量(量子化を考慮しない場合)は、`4 bytes` × `n dimensions` × `m objects` × `1.5` となります。ここで、`m` はデータベース内オブジェクト数、`n` はベクトルの次元数で、`1.5` はオーバーヘッドを見込んでいます。 + +つまり、1,000 万オブジェクトの場合、各モデルのフル出力を保存するには次のメモリが必要になります。 + +- NVIDIA `NV-embed-v2`: `246 GB` +- OpenAI `text-embedding-3-large`: `184 GB` +- `snowflake-arctic-embed-l-v2.0`: `61 GB` +- `all-MiniLM-L6-v2`: `23 GB` + +ご想像のとおり、これはベクトルデータベースのインフラコストを大幅に押し上げる可能性があります。 + +データベース側には、フットプリントとコストを削減するための量子化戦略が存在しますが、これについては別のコースで取り上げます。 + +しかし、モデル側でこの問題を緩和できる場合もあります。Matryoshka Representation Learning (MRL) に基づく `jina-embeddings-v2` や `snowflake-arctic-embed-l-v2.0` などのモデルは、ベクトルを途中で切り詰めるだけで柔軟に次元数を削減できます。たとえば `snowflake-arctic-embed-l-v2.0` では、元の 1024 次元を 256 次元まで削減しても、性能の損失はわずかです。 + +:::tip +データセットが将来的にどれくらいの規模になるかを想定し、それに見合うモデルを選定してください。システム要件が大きくなり過ぎて予算を超えるようであれば、本番環境へのスケールアップ時に振り出しに戻る恐れがあります。 +::: + +### モデルサイズと推論速度 + +モデルサイズは推論速度に直接影響し、レイテンシ要件のあるアプリケーションでは極めて重要です。一般に、大きなモデルほど高性能ですが、その分計算負荷も増大します。 + +モデルをスクリーニングするときは、次の観点を考慮してください。 + +| 要素 | 影響 | +| --- | --- | +| パラメータ数 | パラメータが多いほど一般に品質は向上しますが、推論が遅くなりメモリ使用量が増えます | +| アーキテクチャ効率 | 一部のモデルはサイズが大きくても高速推論に最適化されています | +| ハードウェア要件 | 大規模モデルは GPU や TPU といった専用ハードウェアを必要とする場合があります | + +:::tip +推論速度はモデルそのもの、推論用ハードウェア、さらにネットワークレイテンシの関数で決まります。モデルの適合性を評価するときは、これらをシステム全体として確認しましょう。 +::: + +### 価格、可用性、ライセンス + +モデルを採用する際の実務的な側面は、技術的要件を超えて多岐にわたります。 + +プロバイダーはさまざまな料金体系を提供しています。 + +- **API ベースの料金体系**: 1 トークンあたり課金 (OpenAI, Cohere) +- **コンピュートベースの料金体系**: ハードウェア使用量に応じて課金 (クラウドプロバイダー) +- **階層型ライセンス**: 価格に応じて機能・性能が異なる +- **オープンソース**: 無料で利用できますが、セルフホスティングのコストが発生します + +モデルと推論形態の選択は、モデルの可用性にも影響します。 + +- **地理的可用性**: 一部のプロバイダーはすべての地域でサービスを提供していません +- **SLA 保証**: 稼働率のコミットメントおよびサポートレベル +- **レートリミット**: スループットの制限がアプリケーションに影響する可能性 +- **バージョンの安定性**: モデルがどの程度の頻度で非推奨または更新されるか + +さらに、ライセンス条項も大きく異なります。 + +- **商用利用制限**: 一部のオープンモデルは商用利用を禁止しています +- **データ使用ポリシー**: 提供者があなたのデータをどのように利用できるか +- **輸出規制**: 地域規制への準拠 +- **デプロイ柔軟性**: オンプレミスやエッジデバイスへのデプロイが可能かどうか + +必ず各モデルの具体的な利用条件を確認してください。たとえば、CLIP のようなモデルは公開されていますが、利用制限がアプリケーションに影響する場合があります。 + +:::tip +こうした実務的な要因は、性能上のメリットより重要になることもあります。ライセンス条件が良好でコストが低い、やや精度の劣るモデルのほうが、本番運用では好ましい場合があります。 +::: +### 候補ショートリストの作成 + +これらの要素を考慮した後、詳細に評価するモデルの優先ショートリストを作成できます。良いアプローチとして、次を組み合わせると効果的です。 + +1. **ベンチマーク上位**:標準メトリクスで高い性能を示すモデル +2. **リソース効率の高いオプション**:フットプリントが小さい、または推論が高速なモデル +3. **特化型モデル**:特定のドメインに特に適している可能性があるモデル +4. **異なるアーキテクチャ**:多様なアプローチを含めることで、最適な適合を見つけられる可能性が高まります + +詳細な評価を行うために、初期ショートリストには 3~5 個のモデルを目安にしましょう。モデルが多すぎると、評価プロセスが扱いづらく時間もかかります。 + +次のセクションでは、これらの候補モデルを詳細に評価し、特定の要件を最も満たすモデルを決定する方法を説明します。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/26_detailed_eval.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/26_detailed_eval.mdx new file mode 100644 index 000000000..1a3ab9914 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/26_detailed_eval.mdx @@ -0,0 +1,169 @@ +--- +title: 詳細評価 +description: モデルの候補を絞り込んだら、詳細に評価できます。 +--- + +import ThemedImage from '@theme/ThemedImage'; + +## 概要 + +ニーズを明確にし、候補モデルのショートリストを作成したら、次は徹底的な評価を行えます。この段階の目的は、ご自身のユースケースに適した埋め込みモデルを選定するための具体的な根拠を集めることです。 + +埋め込みモデルを評価する際には、次の 2 種類の評価を区別することが重要です。 + +1. **モデル評価**: ベクトル埋め込みモデル自体を直接的な指標で評価します。通常、標準ベンチマークや特定のユースケースに合わせて設計したカスタムタスクで性能を測定します。 +2. **ダウンストリーム評価**: エンベディングモデルが RAG パイプラインやレコメンデーションエンジンなど、より大きなシステムやアプリケーション内でどのように機能するかを確認します。 + +どちらの評価も重要ですが、目的は異なります。モデル評価は各モデルの本来の能力を理解するのに役立ちます。一方、ダウンストリーム評価は、それらの能力がシステムとしての実際のアプリケーション性能にどのように反映されるかを示します。 + +このガイドでは、まずモデル評価に焦点を当てます。ダウンストリーム、つまりシステムレベルの評価については、後ほど扱います。 + +まずは標準ベンチマークを用いたモデル評価から始めましょう。 + +## 標準ベンチマーク + +標準ベンチマークは、詳細なモデル評価を始める際の良い出発点になります。専門家によって作成されており、多くの場合、最小限の労力で結果を参照できます。 + +ベンチマーク結果を確認する際は、ご自身のユースケースに最も関連するタスクと指標に注目してください。 + +前述のとおり、 Massive Text Embedding Benchmark ( MTEB ) は業界標準として広く使われており、出発点として優れています。 + +ここでは、詳細な評価のためにベンチマーク結果をどのように解釈するかを掘り下げます。 MTEB は 100 以上の個別タスクで構成されており、タスクタイプごとにモデル性能を示します。テキストモデルの一般的なタスクタイプは次のとおりです。 + +- **検索 ( Retrieval )**: クエリに基づいて関連ドキュメントを見つける +- **分類 ( Classification )**: テキストをあらかじめ定義されたクラスに分類する +- **クラスタリング ( Clustering )**: 類似したテキストをグループ化する +- **再ランキング ( Reranking )**: 関連性で結果を並べ替える +- **セマンティック・テキスト類似度 ( STS )**: 2 つのテキストが意味的にどれだけ類似しているかを測定する + +多くの AI アプリケーションで最も一般的なタスクタイプは検索かもしれません。実際、すでに MTEB の検索スコアについては触れました。しかし、 MTEB では個別タスクのスコアも取得できるため、総合スコア以上に掘り下げる価値があります。 + +### MTEB スコアの詳細確認 + + MTEB における各タスクタイプのスコアは、複数タスクのスコアを組み合わせて構成されています。例えば 2025 年 4 月時点で、検索スコアは 17 種類のタスクベンチマークのスコアで成り立っています。 + +以下の図では、いくつかのモデル性能をスコアの可視化で比較します。これらの図は、読みやすさのために多言語タスクセットを 2 つのサブセットに分割しています。 + +この最初の画像は、ニュースや百科事典など一般ドメインのデータを使用するタスクを含みます。 + +MTEB ベンチマーク(一般タスク別) + +次の画像は、より専門的なドメインデータを使用するタスクを含みます。法務、医療、プログラミング、政府データなど、さまざまな分野をカバーしています。 + +MTEB ベンチマーク(専門タスク別) + +チャートから、表の上位に位置する `gemini-embedding-exp-03-07` などのエンベディングモデルは、他モデルと比べて幅広いタスクで良好な性能を示していることがわかります。しかし、これだけでは全体像を語れません。モデルによっては平均スコア以上に特定タスクで高い性能を発揮する場合があります。 + +たとえば、 `snowflake-arctic-embed` モデルは、長いテキスト中に埋もれた特定の語句のリコールを試す `LEMBPasskeyRetrieval` タスクで非常に優れた結果を出しています。また、 Cohere の `Cohere-embed-multilingual-v3.0` は、多言語性が高い MIRACL タスクで良好な性能を示しています。 + +興味深いことに、 MTEB の多言語タスクセットを見ていても、英語のみ(または英語が大部分)で構成されたタスクが含まれている場合があります。 + +MTEB 多言語タスク例 + +そのため、各タスクがニーズにどれだけ対応しているかに基づき、タスクスコアを組み合わせて独自の指標を導出すると役立つかもしれません。 + +考慮すべきポイントは次のとおりです。 + +1. **タスクの関連性**: タスクはユースケースに合致していますか? +2. **データ分布**: データはドメインを代表していますか? +3. **指標の関連性**: 報告されている指標は要件に合っていますか? +4. **最新性**: 結果は現在のモデル性能を反映するほど新しいですか? +5. **公平性**: すべてのモデルが同等の条件で評価されていますか? + +たとえば、データが複数言語を確実に含む場合は、多言語データセットの重みを単言語データセットより高く設定するかもしれません。法務、医療、プログラミングなど、ドメイン固有データでも同様です。 + +その結果得られるスコアは公式の総合スコアとは異なるかもしれませんが、特定のユースケースにはより適切な指標となり得ます。 + +### 標準ベンチマークの限界 + +これらのサードパーティベンチマークは非常に有用ですが、いくつかの限界があることも念頭に置く必要があります。主な 2 つの限界はデータ漏洩とニーズとの相関性です。 + +**データ漏洩 ( Data leakage )** + +ベンチマークが公開されているため、一部のベンチマークデータがモデルの学習データに含まれてしまうリスクがあります。特に、大量のデータが学習に使用される現在では、この問題が起こりやすくなっています。 +その結果、モデルが「記憶」した内容を答えてしまい、ベンチマーク結果がモデル本来の性能を正しく表さない可能性があります。 + +**ニーズとの相関性** + +もう 1 つの限界は、標準ベンチマークが必ずしも自分のニーズを正確に反映していない点です。ニーズに最も近いベンチマークを選ぶことはできますが、タスク、データ分布、指標が完全に一致することは稀です。 + +**緩和策 ( Mitigation )** + +そのため、標準ベンチマークの結果はあくまで参考程度に留めることが大切です。追加の手掛かりとして、自分でベンチマークを作成して試す方法が有効です。次のセクションで詳しく見ていきましょう。 + +## モデル評価: カスタムベンチマーク + +標準ベンチマークが貴重な参考情報を提供してくれる一方で、独自の評価を作成することは、その限界を補う優れた手段になります。 + + MTEB のような大規模ベンチマークを考えると、自分でベンチマークを走らせるのは難しく思えるかもしれません。しかし、以下のステップを踏めば、それほど難しくありません。 + +### ベンチマーク目標の設定 + +ここまでで、知識ギャップや具体的なタスクが把握できているはずです。たとえば、次のような疑問があるかもしれません。 + +- どのモデルが、主に英語・フランス語・韓国語で書かれたコーヒーに関する顧客レビューを最適に検索できるか? +- Python と Golang のバックエンド Web コードチャンク、およびそれに関連するドキュメントスニペットを対象としたコード検索で、どのモデルが一貫して優れた性能を示すか? + +カスタムベンチマークは、こうした具体的な疑問を解決できるように設計する必要があります。 +### 使用指標の決定 + +全体目標が定義されると、それに対応する指標を決定できます。 + +たとえば、検索性能は一般的に precision、recall、 MAP、 MRR、 NDCG のいずれか、または複数で測定されます。 + +これらはそれぞれ検索性能の異なる側面を測定しますが、 NDCG を使うのがよい出発点になります。 + +NDCG は関連性に基づいてアイテムを正しく並べ替える能力を測定します。クエリと、そのクエリに対してランク付けされたデータセットが与えられると、 NDCG は上位にランク付けされたアイテムが検索結果でも上位に配置されているほど高く評価します。 + +スコアは 0 から 1 で表され、0 はランク付けされたアイテムがまったく取得できなかった状態、1 はすべてのトップランクアイテムを取得し、正しい順序で並べ替えられた状態を意味します。 + +### ベンチマーク用データセットの作成 + +適切なデータセットは、ベンチマークを有意義にするうえで不可欠です。既存のデータセットが使える場合もありますが、ベンチマークの目的や指標に合わせてデータセットを構築・再構成することが一般的です。 + +データセットは次の点を目指すべきです。 + +- 検索タスクを反映する +- タスクの難易度を反映する +- データ分布を捉える +- 十分なボリュームを含む + +これがプロセスで最も時間がかかる部分かもしれません。しかし、実用的なアプローチを取れば管理しやすくなります。オブジェクトが 20 件ほど、クエリが数件のベンチマークでも意味のある結果を得られる場合があります。 + +### ベンチマークの実行 + +ここで、候補モデルを使ってベンチマークを実行します。 + +多くの科学的プロジェクトと同様に、再現性と一貫性が鍵となります。また、後から新しいモデルを評価したり、ニーズに関する知見が更新されたりした際に戻ってくる可能性があることも念頭に置きましょう。 + +プログラミング上は、埋め込み生成、データセット読み込み、指標評価、結果表示などの要素をモジュール化するとよいでしょう。 + +### 結果の評価 + +ベンチマークを実行したら、定量的(例: NDCG@k の数値)および定性的(例:どのオブジェクトがどこで取得されたか)手段で結果を評価することが重要です。 + +定量的結果は、モデルを並べ替えるなどの際に使用できる決定的なランキングを提供します。ただし、これはデータセット構成や使用している指標など多くの要因の影響を受けます。 + +一方、定性的結果はより重要な洞察を与えてくれる場合があります。たとえば、ある埋め込みモデルが次のような傾向を示すことがあります。 + +- 非常に関連性が高いが短いテキストを取得できず、長いテキストを優先する +- 肯定的な文では性能が高いが、否定文では性能が低い +- ドメイン固有の専門用語が苦手 +- 英語と中国語(普通話)では良好だが、あなたのデータにとって重要なハンガリー語ではうまく機能しない + +これらの洞察の多くは、ドメインに精通した人や構築中のシステムの文脈を理解している人にしか発見できない場合があります。そのため、定性的評価は極めて重要です。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/28_benchmark_example.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/28_benchmark_example.mdx new file mode 100644 index 000000000..dce283504 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/28_benchmark_example.mdx @@ -0,0 +1,266 @@ +--- +title: "カスタム ベンチマークの例" +description: 埋め込みモデル評価のために独自ベンチマークを実行する例 +--- + +import ThemedImage from '@theme/ThemedImage'; + +## カスタム ベンチマークの例 + +ここでは、カスタム ベンチマークを実行する方法を示します。 + +最終的な目的として、会社の技術ドキュメント(製品ドキュメント、コード例、サポートフォーラムのログなど)に対して [RAG(検索拡張生成)](https://weaviate.io/blog/introduction-to-rag) システムを実装すると想像してください。 + +MTEB スコアと実用面を考慮して、埋め込みモデルを 2 つ(Model A と Model B)候補に挙げました。ここでは前述した手順を追っていきます。 + +### ベンチマーク目標の設定 + +データが複数のソースから来ているため、ターゲットの多様性が気になるかもしれません。たとえば、文体(カジュアルなフォーラム投稿 vs 公式ドキュメント)、テキスト長(詳細なスニペット vs 短い回答)、言語(コード vs 英語)などです。 + +そこで、*各モデルが文体・長さ・言語のばらつきにどのように対処するか* をテストすることを目標に設定できます。 + +### 使用するメトリクスの決定 + +これは古典的な検索問題であり、結果には関連度の高低があります。そのため、NDCG@k メトリックを使用できます。NDCG@k は次のように計算されます。 + +```python +def calculate_dcg(relevance_scores: list[int], k: Optional[int] = None) -> float: + """ + Args: + relevance_scores: List of relevance scores (0, 1, or 2) + k: Number of results to consider. If None, uses all results. + """ + if k is not None: + relevance_scores = relevance_scores[:k] + + gains = [2**score - 1 for score in relevance_scores] + dcg = 0 + for i, gain in enumerate(gains): + dcg += gain / np.log2(i + 2) if i > 0 else gain + + return dcg + +def calculate_ndcg( + actual_scores: list[int], ideal_scores: list[int], k: Optional[int] = None +) -> float: + """ + Args: + actual_scores: List of relevance scores in predicted order + ideal_scores: List of relevance scores in ideal order + k: Number of results to consider + """ + dcg = calculate_dcg(actual_scores, k) + idcg = calculate_dcg(ideal_scores, k) + return dcg / idcg if idcg > 0 else 0.0 +``` + +注: [scikit-learn には組み込み実装](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.ndcg_score.html) の NDCG が用意されています。 + +### ベンチマーク データセットの作成 + +ベンチマーク データセットは、設定した目的を達成できるものであるべきです。*各モデルが文体・長さ・言語のばらつきにどのように対処するか* を評価したいので、データセットは次のようになるかもしれません。 + +```python +dataset = { + # Search query + "query": "How to set up a vector index with binary quantization", + # Candidate document set, with scores on a scale of 0-3 + "documents": [ + { + "id": "doc001", + # Highly relevant documentation text + "text": "Each collection can be configured to use BQ compression. BQ can enabled at collection creation time, before data is added to it. This can be done by setting the vector_index_config of the collection to enable BQ compression.", + "score": 3 + }, + { + "id": "doc002", + # Highly relevant, long code example + "text": "from weaviate.classes.config import Configure, Property, DataType, VectorDistances, VectorFilterStrateg\n\nclient.collections.create(\n 'Article',\n # Additional configuration not shown\n vector_index_config=Configure.VectorIndex.hnsw(\n quantizer=Configure.VectorIndex.Quantizer.bq(\n cache=True,\n rescore_limit=1000\n ),\n ef_construction=300,\n distance_metric=VectorDistances.COSINE,\n filter_strategy=VectorFilterStrategy.SWEEPING # or ACORN (Available from Weaviate v1.27.0)\n ),)", + "score": 3 + }, + { + "id": "doc003", + # Highly relevant, short code example + "text": "client.collections.create(\nname='Movie',\nvector_index_config=wc.Configure.VectorIndex.flat(\nquantizer=wc.Configure.VectorIndex.Quantizer.bq()\n))", + "score": 3 + }, + { + "id": "doc004", + # Less relevant forum post, even though the right words appear + "text": "No change in vector size after I set up Binary Quantization\nHello! I was curious to try out how binary quantization works. To embed data I use gtr-t5-large model, which creates 768-dimensional vectors. My database stores around 2k of vectors. My python code to turn PQ on is following: client.schema.update_config(\n 'Document',\n {\n 'vectorIndexConfig': {\n 'bq': {\n 'enabled': True, \n }\n }\n },\n)", + "score": 1 + }, + # And so on ... + { + "id": "doc030", + # Irrrelevant documentation text + "text": "Weaviate stores data objects in collections. Data objects are represented as JSON-documents. Objects normally include a vector that is derived from a machine learning model. The vector is also called an embedding or a vector embedding.", + "score": 0 + }, + ] +} +``` + +この例のデータセットには、さまざまな関連スコアを持つドキュメントが混在しています。同じくらい重要なのは、ドキュメントの種類・長さ・言語も混在している点です。理想的には各変数が十分に表現されており、検索性能の差異が顕在化するようになっています。 + +### ベンチマークの実行 + +各埋め込みモデルについて、次の手順を実行します。 + +1. 各ドキュメントとクエリの埋め込みを作成 +2. これらの埋め込みを使って上位 `k` 件を検索 +3. 定量的メトリクス(例: NDCG@k)を計算 +4. 定性的分析のために結果(上位 k 件と真のラベル)をまとめる + +擬似コードで表すと、次のようになります。 + +```python +import numpy as np +from typing import List, Dict, Any + +class Document: + """Document with text and relevance score""" + def __init__(self, id, text, relevance_score): + self.id = id + self.text = text + self.relevance_score = relevance_score + +class EmbeddingModel: + """Abstract embedding model interface""" + def __init__(self, name): + self.name = name + + def embed(self, text): + """Generate embedding for text""" + return embedding + +class BenchmarkRunner: + """Runs embedding model benchmarks""" + def __init__(self, queries, documents, models): + self.queries = queries + self.documents = documents + self.models = models + + def run(self, k=10): + """Run benchmark for all models + + Returns: Dict mapping model names to metrics + """ + results = {} + + for model in self.models: + # Get embeddings for all texts + query_embeddings = {q: model.embed(q) for q in self.queries} + doc_embeddings = {doc.id: model.embed(doc.text) for doc in self.documents} + + # Calculate metrics for each query + ndcg_scores = [] + for query, query_emb in query_embeddings.items(): + # Get top k documents by similarity + top_docs = self._retrieve_top_k(query_emb, doc_embeddings, k) + + # Calculate NDCG + ndcg = self._calculate_ndcg(top_docs, query, k) + ndcg_scores.append(ndcg) + + # Store results + results[model.name] = { + 'avg_ndcg': np.mean(ndcg_scores), + 'all_scores': ndcg_scores + } + + return results + + def _retrieve_top_k(self, query_emb, doc_embeddings, k): + """Retrieve top k docs by similarity""" + # Implementation: calculate similarities and return top k + pass + + def _calculate_ndcg(self, retrieved_docs, query, k): + """Calculate NDCG@k for retrieved documents""" + # Implementation: calculate DCG and IDCG + pass + +# Example usage +def run_benchmark_example(): + # 1. Initialize data + queries = ["How to set up binary quantization"] + documents = [ + Document("doc1", "BQ can be enabled at collection creation...", 3), + # other documents ... + Document("doc2", "Weaviate stores data objects in collections...", 0) + ] + + # 2. Initialize models + models = [ + # Model implementations... + ] + + # 3. Run benchmark + runner = BenchmarkRunner(queries, documents, models) + results = runner.run(k=5) + + # 4. Print results + for model_name, metrics in results.items(): + print(f"{model_name}: NDCG@5 = {metrics['avg_ndcg']:.4f}") +``` + +### 結果の評価 + +ベンチマークを実行すると、一連の結果が得られます。定量的メトリクスと定性的な観察を組み合わせて、モデル性能を総合的に把握しましょう。 + +#### 定量的分析 + +まず、各モデルの全体的なメトリクスを比較します。 + +```python +# Example benchmark results +results = { + 'Model A': {'avg_ndcg': 0.87, 'all_scores': [0.92, 0.85, 0.84]}, + 'Model B': {'avg_ndcg': 0.79, 'all_scores': [0.95, 0.72, 0.70]} +} + +# Print summary +for model_name, metrics in results.items(): + print(f"{model_name}: NDCG@10 = {metrics['avg_ndcg']:.4f}") +``` + +平均値だけでなく、次の点にも目を向けます。 + +- **スコア分布**: モデルは一貫して高性能なのか、一部の領域だけ優れているのか +- **クエリタイプ別の性能**: クエリの特徴(長さ、複雑さ、ドメイン)ごとにスコアを分類 +- **統計的有意性**: ベンチマークが大規模な場合、違いが統計的に有意かどうか + +#### 定性的分析 + +実際の検索結果を確認すると、より実践的な洞察が得られます。 + +1. **成功と失敗のパターンを特定** + - あるモデルは特定のドキュメントタイプで苦戦しているか?(コード、長文テキスト など) + - クエリと取得ドキュメントの間に一貫したミスマッチがあるか? +2. **モデル間で結果を比較** + - モデルごとに関連度の判断基準が異なるか? + - モデル間で大きく意見が分かれる部分はどこか? +3. **ドメイン固有の観点** + - 専門用語や業界用語は適切に扱われているか? + - モデルはドメイン文脈をどれだけ理解しているか? + +### 最終決定 + +定量的・定性的な洞察を組み合わせて、次のバランスを取りながら判断します。 + +- **純粋な性能**: どのモデルが最も高いメトリクスを達成しているか +- **特定の強み**: アプリケーションで特に重要な領域で優れているモデルはどれか +- **実用面**: コスト、レイテンシ、デプロイ要件などの要素 + +標準ベンチマークの結果も、この評価プロセスに組み込むことを忘れないでください。 + +理想のモデルは、必ずしも平均スコアが最も高いモデルとは限りません。特定の要件を最もよく満たし、アプリケーションにとって重要なクエリとドキュメントタイプで良好に機能するモデルが最適です。 + +この評価プロセスは、モデルを選定するだけでなく、その強みと限界を理解するためのものでもあります。この知識は、埋め込みモデルを中心としたより効果的なシステム設計や、適切な性能期待の設定に役立ちます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/40_periodic_re_evaluation.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/40_periodic_re_evaluation.mdx new file mode 100644 index 000000000..23fb7c17b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/40_periodic_re_evaluation.mdx @@ -0,0 +1,28 @@ +--- +title: 定期的な再評価 +description: 埋め込みモデルを定期的に再評価する +--- + +import ThemedImage from '@theme/ThemedImage'; + +最適な埋め込みモデルを選定することは大きなマイルストーンですが、これは一度きりの作業ではない点にご注意ください。 + +この分野は急速に進化しており、画期的な改善をもたらす新しいモデルが定期的にリリースされています。さらに、システムレベルへ統合した際には、埋め込みモデルが想定とは異なる挙動を示す場合があります。 + +そのため、埋め込みモデルの選択を次のように定期的、あるいは必要に応じて再評価することをご検討ください。 + +- **ベンチマークのリーダーボードを監視する**: MTEB などのリソースを確認し、有望な新モデルを特定します +- **パフォーマンス指標を追跡する**: アプリケーションで性能低下が見られた場合、レビューを行うきっかけになります +- **要件の変化を確認する**: データ分布、対応言語、ドメインが変化した場合、当初のモデル選定基準を更新する必要があります + +要件や利用可能なモデルに大きな変化があった場合は、本モジュールで説明した選定と評価のプロセスを繰り返してください。 + +これにより、アプリケーションと技術環境が進化しても、埋め込みモデル選定プロセスに一貫した再現可能な原則を適用し続けることができます。 + +モデル選定を固定的な決定ではなく継続的なプロセスとして扱うことで、 AI アプリケーションの品質と有効性を長期的に維持できます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/candidate_documents.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/candidate_documents.png new file mode 100644 index 000000000..5ddcee7b8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/candidate_documents.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_eval_example_1_fasttext.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_eval_example_1_fasttext.png new file mode 100644 index 000000000..d0b36975f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_eval_example_1_fasttext.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_eval_example_2_arctic2.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_eval_example_2_arctic2.png new file mode 100644 index 000000000..dd727ebbd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_eval_example_2_arctic2.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_evaluation.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_evaluation.png new file mode 100644 index 000000000..9c8bd240d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_evaluation.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_selection_workflow.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_selection_workflow.png new file mode 100644 index 000000000..fcf8ef739 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_selection_workflow.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_selection_workflow_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_selection_workflow_dark.png new file mode 100644 index 000000000..b845474c4 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/embedding_model_selection_workflow_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/identify_needs_overview.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/identify_needs_overview.png new file mode 100644 index 000000000..fbc8b725a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/identify_needs_overview.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/memory-reqs-1m-docs.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/memory-reqs-1m-docs.png new file mode 100644 index 000000000..c9752c43c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/memory-reqs-1m-docs.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mieb_by_any_to_any.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mieb_by_any_to_any.png new file mode 100644 index 000000000..4d0011f7a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mieb_by_any_to_any.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/model_cards.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/model_cards.png new file mode 100644 index 000000000..45ecf3d96 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/model_cards.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-benchmarks-by-task-general.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-benchmarks-by-task-general.png new file mode 100644 index 000000000..ccabab9ed Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-benchmarks-by-task-general.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-benchmarks-by-task-specialized.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-benchmarks-by-task-specialized.png new file mode 100644 index 000000000..70f115388 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-benchmarks-by-task-specialized.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-tasks-example.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-tasks-example.png new file mode 100644 index 000000000..0520cb51d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb-tasks-example.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb_by_retrieval.png b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb_by_retrieval.png new file mode 100644 index 000000000..28d6bbd79 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/_img/mteb_by_retrieval.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/index.mdx new file mode 100644 index 000000000..a524a7992 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/180_embedding_model_selection/index.mdx @@ -0,0 +1,33 @@ +--- +title: "180 埋め込みモデルの評価と選定" +description: "ご自身のユースケースに合わせて埋め込みモデルを評価・選定する方法を学びます。" +sidebar_position: 180 # Like a subject number (e.g. CS101) +--- + +## ユニット概要 + + + +埋め込みモデルは、現代の検索システムの礎となっています。近年の発展とモデルの急速な増加により、その性能は大きく向上しました。しかし選択肢が膨大かつ増え続けているため、適切なモデルを選定することは非常に困難です。 + +このモジュールでは、この複雑な状況を乗り越える方法を学び、モデルを絞り込み、評価し、選定するスキルを身に付けます。 + +### 前提条件 + +- なし + +## 学習目標 + +import LearningGoalsExp from '/src/components/Academy/learningGoalsExp.mdx'; + + + +import LearningGoals from '/src/components/Academy/learningGoals.jsx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/_category_.json new file mode 100644 index 000000000..e1eb208b3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/academy/theory/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Theory", + "position": 90 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/_force_pip_install.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/_force_pip_install.mdx new file mode 100644 index 000000000..45a1f04b5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/_force_pip_install.mdx @@ -0,0 +1,22 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +#### トラブルシューティング:`pip` で最新版をインストールする + +既存のインストール環境では、`pip install -U "weaviate-client[agents]"` を実行しても `weaviate-agents` が [最新バージョン](https://pypi.org/project/weaviate-agents/) に更新されない場合があります。このような場合は、`weaviate-agents` パッケージを明示的にアップグレードしてみてください。 + + + + +```shell +pip install -U weaviate-agents +``` + +または、[特定のバージョン](https://github.com/weaviate/weaviate-agents-python-client/tags) をインストールします: + +```shell +pip install -U weaviate-agents==||site.weaviate_agents_version|| +``` + + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_coming_soon_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_coming_soon_dark.png new file mode 100644 index 000000000..7ccba120e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_coming_soon_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_coming_soon_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_coming_soon_light.png new file mode 100644 index 000000000..f9c051526 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_coming_soon_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_tech_preview_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_tech_preview_dark.png new file mode 100644 index 000000000..cd4986dd0 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_tech_preview_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_tech_preview_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_tech_preview_light.png new file mode 100644 index 000000000..9392a5aa6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/agents_tech_preview_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent.excalidraw.zip b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent.excalidraw.zip new file mode 100644 index 000000000..2c97624eb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent.excalidraw.zip differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent.py b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent.py new file mode 100644 index 000000000..3ee91aa79 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent.py @@ -0,0 +1,374 @@ +# START ConnectToWeaviate +import os +import weaviate +from weaviate.classes.init import Auth +# END ConnectToWeaviate +# START InstantiatePersonalizationAgent # START CreateOrConnectToAgent +from weaviate.agents.personalization import PersonalizationAgent +from weaviate.classes.config import DataType +# END InstantiatePersonalizationAgent # END CreateOrConnectToAgent +# START AddUserPersona +from weaviate.agents.classes import Persona +# END AddUserPersona +# START AddUserInteractions +from weaviate.agents.classes import PersonaInteraction +# END AddUserInteractions + +# Additional helpers (not shown in the docs) +from tqdm import tqdm +from datasets import load_dataset +from weaviate.classes.config import Configure, Property, DataType +from typing import Dict, Any + +# START ConnectToWeaviate + +# Provide your required API key(s), e.g. for the configured vectorizer(s) +headers = { + # END ConnectToWeaviate + "X-Cohere-API-Key": os.environ.get("COHERE_API_KEY", ""), + # START ConnectToWeaviate + # Provide your required API key(s), e.g. Cohere, OpenAI, etc. for the configured vectorizer(s) + "X-INFERENCE-PROVIDER-API-KEY": os.environ.get("YOUR_INFERENCE_PROVIDER_KEY", ""), +} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=Auth.api_key(os.environ.get("WEAVIATE_ADMIN_API_KEY")), + headers=headers, +) + +# END ConnectToWeaviate # END InstantiatePersonalizationAgent + +# Delete the collection if we want to start fresh +client.collections.delete("Movie") + +client.collections.create( + "Movie", + description="A dataset of movies including their metadata.", + vector_config=Configure.Vectors.text2vec_weaviate( + model="Snowflake/snowflake-arctic-embed-m-v1.5" + ), + properties=[ + Property( + name="release_date", + data_type=DataType.TEXT, + description="release date of the movie", + skip_vectorization=True, + ), + Property( + name="title", data_type=DataType.TEXT, description="title of the movie" + ), + Property( + name="overview", + data_type=DataType.TEXT, + description="overview of the movie", + ), + Property( + name="genres", + data_type=DataType.TEXT_ARRAY, + description="genres of the movie", + ), + Property( + name="vote_average", + data_type=DataType.NUMBER, + description="vote average of the movie", + ), + Property( + name="vote_count", + data_type=DataType.INT, + description="vote count of the movie", + ), + Property( + name="popularity", + data_type=DataType.NUMBER, + description="popularity of the movie", + ), + Property( + name="poster_url", + data_type=DataType.TEXT, + description="poster path of the movie", + skip_vectorization=True, + ), + Property( + name="original_language", + data_type=DataType.TEXT, + description="Code of the language of the movie", + skip_vectorization=True, + ), + ], +) + +# Load the movies dataset +movies_dataset = load_dataset("Pablinho/movies-dataset", split="train", streaming=True) + +# Get the Movies collection +movies_collection = client.collections.use("Movie") + +def load_movie_row(item: Dict[str, Any]) -> Dict[str, Any]: + """ + Load movie data to output matching Weaviate object + + Args: + item: Dictionary containing movie data with original keys + + Returns: + Dictionary matching Weaviate data schema + """ + if item.get("Genre"): + genres = [genre.strip() for genre in item["Genre"].split(",") if genre.strip()] + else: + genres = [] + + if item.get("Original_Language"): + original_language = item["Original_Language"].lower() + else: + original_language = "" + + if item.get("Vote_Average"): + try: + vote_average = float(item["Vote_Average"]) + except ValueError: + vote_average = 0.0 + else: + vote_average = 0.0 + + if item.get("Vote_Count"): + try: + vote_count = int(item["Vote_Count"]) + except ValueError: + vote_count = 0 + else: + vote_count = 0 + + if item.get("Popularity"): + try: + popularity = float(item["Popularity"]) + except ValueError: + popularity = 0.0 + else: + popularity = 0.0 + + return { + "release_date": item["Release_Date"], + "title": item["Title"], + "overview": item["Overview"], + "genres": genres, + "vote_average": vote_average, + "vote_count": vote_count, + "popularity": popularity, + "poster_url": item["Poster_Url"], + "original_language": original_language, + } + +# Batch import the appropriate data +with movies_collection.batch.fixed_size(batch_size=200) as batch: + for i, item in tqdm(enumerate(movies_dataset)): + data_object = load_movie_row(item) + batch.add_object(properties=data_object) + +# START CreateOrConnectToAgent + +if PersonalizationAgent.exists(client, "Movie"): + # Connect to an existing agent + pa = PersonalizationAgent.connect(client=client, reference_collection="Movie") +else: + # Instantiate a new agent, and specify the collection to query + # The Personalization Agent will automatically also connect to the user data collection + pa = PersonalizationAgent.create( + client=client, + reference_collection="Movie", + user_properties={ + "age": DataType.NUMBER, + "favorite_genres": DataType.TEXT_ARRAY, + "favorite_years": DataType.NUMBER_ARRAY, + "language": DataType.TEXT, + }, + ) +# END CreateOrConnectToAgent + +# START CreatePersona +from weaviate.util import generate_uuid5 +from uuid import uuid4 # If you want to generate a random UUID + +persona_id = generate_uuid5("sebawita") # To generate a deterministic UUID +# persona_id = uuid4() # To generate a random UUID + +# END CreatePersona + +# START DeletePersona +from weaviate.util import generate_uuid5 + +persona_id = generate_uuid5("sebawita") # To generate a deterministic UUID + +# Delete the persona +pa.delete_persona(persona_id) +# END DeletePersona + +# START CreatePersona +pa.add_persona( + Persona( + persona_id=persona_id, + properties={ + "age": 74, + "favorite_genres": ["Action", "Horror", "Romance"], + "favorite_years": [1979, 1981, 1984, 1985], + "language": "Hungarian", + }, + ) +) +# END CreatePersona + +# START UpdatePersona +from weaviate.util import generate_uuid5 + +persona_id = generate_uuid5("sebawita") # To generate a deterministic UUID + +# Update the persona +pa.update_persona( + Persona( + persona_id=persona_id, + properties={ + "age": 35, + "favorite_genres": ["Action", "Adventure", "Drama", "Sci-Fi"], + "favorite_years": [1999, 2005, 2010, 2014, 2016], + "language": "English", + }, + )) +# END UpdatePersona + +# START CheckPersonaExists +from weaviate.util import generate_uuid5 + +persona_id = generate_uuid5("sebawita") # To generate a deterministic UUID + +# Check if the persona exists +try: + assert pa.has_persona(persona_id) + print(f"Persona with ID {persona_id} exists.") +except AssertionError: + print(f"Persona with ID {persona_id} does not exist.") +# END CheckPersonaExists + +# START GetPersona +from weaviate.util import generate_uuid5 + +persona_id = generate_uuid5("sebawita") # To generate a deterministic UUID + +# Get the persona +persona = pa.get_persona(persona_id) +print(persona) +# END GetPersona + +from weaviate.classes.query import Filter + +movie_titles = [ + "Avatar 2", + "Big Daddy", + "White House Down", + "Tales from the Crypt", + "Twister", + "West Side Story", + "The Howling", + "The Emoji Movie", + "Magic Mike", + "Godzilla: Planet of the Monsters", +] + +movies_collection = client.collections.use("Movie") + +movie_dict = { + movie.properties["title"]: movie + for movie in movies_collection.query.fetch_objects( + filters=Filter.by_property("title").contains_any(movie_titles), limit=20 + ).objects +} + +# START AddUserInteractions +# Note: `movie_dict` is a dictionary of movie titles to their corresponding objects +interactions = [ + PersonaInteraction( + persona_id=persona_id, item_id=movie_dict["Avatar 2"].uuid, weight=0.8 + ), # Strongly positive + PersonaInteraction( + persona_id=persona_id, item_id=movie_dict["Twister"].uuid, weight=0.5 + ), # Somewhat positive + PersonaInteraction( + persona_id=persona_id, item_id=movie_dict["The Howling"].uuid, weight=0.1 + ), # Almost neutral + PersonaInteraction( + persona_id=persona_id, item_id=movie_dict["Magic Mike"].uuid, weight=-0.3 + ), # Somewhat negative + PersonaInteraction( + persona_id=persona_id, item_id=movie_dict["The Emoji Movie"].uuid, weight=-1.0 + ), # Strongly negative +] + +pa.add_interactions(interactions=interactions) +# END AddUserInteractions + +# START BasicQuery +response = pa.get_objects(persona_id) + +for i, obj in enumerate(response.objects): + print(obj.properties) +# END BasicQuery + +# START QueryParameters +response = pa.get_objects( + persona_id=persona_id, + limit=10, + recent_interactions_count=100, + exclude_interacted_items=False, + decay_rate=0.1, + exclude_items=[], + use_agent_ranking=True, + explain_results=True, + instruction=None, +) + +for i, obj in enumerate(response.objects): + print(obj.properties) +# END QueryParameters + +# START InspectResults +print(response.ranking_rationale) +for i, obj in enumerate(response.objects): + print(obj.properties) + print(f"original rank: {obj.original_rank}") + print(f"Personalized rank: {obj.personalized_rank}") +# END InspectResults + +# START PersonalizedWeaviateQuery +personalized_query = pa.query(persona_id=persona_id, strength=0.95) + +response = personalized_query.near_text( # Or .bm25 / .hybrid + query="A movie about a giant monster", + limit=20, + # Other normal `near_text` parameters can be added here + # e.g. filter, auto_limit, distance, include_vector, include_metadata, etc. +) + +for i, obj in enumerate(response.objects): + print(obj.properties) +# END PersonalizedWeaviateQuery + +# START ParamsPersonalizedWeaviateQuery +personalized_query = pa.query( + persona_id=persona_id, # The ID of the persona to use for personalization + strength=0.95, # The strength of the personalization (0.0 = none, 1.0 = full) + overfetch_factor=2, # The number of objects to fetch before personalization + recent_interactions_count=50, # The number of recent interactions to consider + decay_rate=0.2 # The decay rate for the interactions +) + +response = personalized_query.hybrid( # Or .near_text / .bm25 + query="A movie about a giant monster", + limit=20, + # Other normal `hybrid` parameters can be added here +) + +for i, obj in enumerate(response.objects): + print(obj.properties) +# END ParamsPersonalizedWeaviateQuery + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture.png new file mode 100644 index 000000000..c6a34f32f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture_dark.png new file mode 100644 index 000000000..c9c39fb6a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture_light.png new file mode 100644 index 000000000..33222b363 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_architecture_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview.png new file mode 100644 index 000000000..4b20cbe5c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview_dark.png new file mode 100644 index 000000000..910066e19 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview_light.png new file mode 100644 index 000000000..4b20cbe5c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_overview_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank.png new file mode 100644 index 000000000..ad1c4f7ab Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank_dark.png new file mode 100644 index 000000000..7d18f8d17 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank_light.png new file mode 100644 index 000000000..f50f9fdb7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_rank_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search.png new file mode 100644 index 000000000..7f55ed0b1 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search_dark.png new file mode 100644 index 000000000..bfcf8e0a2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search_light.png new file mode 100644 index 000000000..49b8d2f57 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_search_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender.py b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender.py new file mode 100644 index 000000000..9098fa00d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender.py @@ -0,0 +1,215 @@ +# 1. Set up Weaviate +# 1.1 Connect to Weaviate Cloud +# START ConnectToWeaviate +import os +import weaviate +from weaviate.auth import Auth + +# Best practice: store your credentials in environment variables +weaviate_url = os.environ["WEAVIATE_URL"] +weaviate_api_key = os.environ["WEAVIATE_API_KEY"] + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=Auth.api_key(weaviate_api_key), +) + +print(client.is_ready()) # Should print: `True` + +# Your work goes here! + +client.close() # Free up resources +# END ConnectToWeaviate + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=Auth.api_key(weaviate_api_key), +) + +client.collections.delete("Recipes") + +# 2. Prepare the Collection +# 2.1 Define the Collection +# START DefineCollection +from weaviate.classes.config import Configure, DataType, Property + + +client.collections.create( + "Recipes", + description="A dataset that lists recipes with titles, descriptions, and labels indicating cuisine", + vector_config=Configure.Vectors.text2vec_weaviate(), + properties=[ + Property( + name="title", data_type=DataType.TEXT, description="title of the recipe" + ), + Property( + name="labels", + data_type=DataType.TEXT, + description="the cuisine the recipe belongs to", + ), + Property( + name="description", + data_type=DataType.TEXT, + description="short description of the recipe", + ), + ], +) +# END DefineCollection + +# 2.2 Populate the database +# START PopulateDatabase +from datasets import load_dataset + +# Ensure datasets library is installed: pip install datasets +dataset = load_dataset( + "weaviate/agents", + "personalization-agent-recipes", + split="train", + streaming=True, +) +recipes_collection = client.collections.use("Recipes") + +with recipes_collection.batch.fixed_size(batch_size=200) as batch: + for item in dataset: + batch.add_object(properties=item["properties"]) + +failed_objects = recipes_collection.batch.failed_objects +if failed_objects: + print(f"Number of failed imports: {len(failed_objects)}") + print(f"First failed object: {failed_objects[0]}") + +# END PopulateDatabase + + +# 2.3 Check the number of objects +# START CheckCollectionSize +print(f"Size of the Recipes dataset: {len(recipes_collection)}") +# END CheckCollectionSize + +# 3. Set up the Personalization Agent +# 3.1 Create or connect to the agent and define user_properties +# START CreateOrConnectAgent +from weaviate.agents.personalization import PersonalizationAgent +from weaviate.classes.config import DataType + + +agent_exists = PersonalizationAgent.exists(client, "Recipes") +if agent_exists: + print("Connecting to existing Personalization Agent for 'Recipes' collection...") + agent = PersonalizationAgent.connect( + client=client, + reference_collection="Recipes", + ) + print("Connected to existing agent.") +else: + print("Creating new Personalization Agent for 'Recipes' collection...") + agent = PersonalizationAgent.create( + client=client, + reference_collection="Recipes", + user_properties={ + "favorite_cuisines": DataType.TEXT_ARRAY, + "likes": DataType.TEXT_ARRAY, + "dislikes": DataType.TEXT_ARRAY, + }, + ) + print("New agent created.") +# END CreateOrConnectAgent + +# 4. Use the Personalization Agent +# 4.1 Add a New Persona +# START AddPersona +from uuid import uuid4 +from weaviate.agents.classes import Persona + + +persona_id = uuid4() +print(f"Adding persona with ID: {persona_id}") +agent.add_persona( + Persona( + persona_id=persona_id, + properties={ + "favorite_cuisines": ["Italian", "Thai"], + "likes": ["chocolate", "salmon", "pasta", "most veggies"], + "dislikes": ["okra", "mushroom"], + }, + ) +) +# END AddPersona + +# 4.2 Add Interactions +# START AddInteractions +from weaviate.agents.classes import PersonaInteraction +from weaviate.collections.classes.filters import Filter + + +reviewed_foods = [ + "Coq au Vin", + "Chicken Tikka Masala", + "Gnocchi alla Sorrentina", + "Matcha Ice Cream", + "Fiorentina Steak", + "Nabe", + "Duck Confit", + "Pappardelle with Porcini", +] + +# Fetch the recipe objects to get their UUIDs +reviews_dict = { + recipe.properties["title"]: recipe + for recipe in recipes_collection.query.fetch_objects( + filters=Filter.by_property("title").contains_any(reviewed_foods), + limit=len(reviewed_foods), # Use len for limit + ).objects +} + +# Define the mapping of food titles to interaction weights +interaction_map = { + "Coq au Vin": 0.8, + "Chicken Tikka Masala": 0.8, + "Matcha Ice Cream": 0.8, + "Gnocchi alla Sorrentina": 0.5, + "Fiorentina Steak": 0.8, + "Nabe": 0.5, + "Duck Confit": 1.0, + "Pappardelle with Porcini": -1.0, +} + +interactions = [] +for food_title, weight in interaction_map.items(): + if food_title in reviews_dict: + # If the recipe was found, create the interaction object + interaction = PersonaInteraction( + persona_id=persona_id, + item_id=reviews_dict[food_title].uuid, # Get UUID from fetched recipe + weight=weight, + ) + interactions.append(interaction) + +# Add the created interactions list to the agent +agent.add_interactions(interactions=interactions) +# END AddInteractions + + +# 4.3 Get Recommendations +# START GetRecommendations +print(f"\nGetting recommendations for persona {persona_id}...") +response = agent.get_objects(persona_id, limit=10, use_agent_ranking=True) + +print("\nRanking Rationale:") +print( + response.ranking_rationale + if response.ranking_rationale + else "No rationale provided." +) +print("\nRecommended Recipes:") +if response.objects: + for i, obj in enumerate(response.objects): + print(f"----- Recommendation {i+1} -----") + print(f" Title: {obj.properties.get('title', 'N/A')}") + print(f" Cuisine: {obj.properties.get('labels', 'N/A')}") + print(f" UUID: {obj.uuid}") +else: + print("No recommendations found.") +# END GetRecommendations + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_dataset.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_dataset.png new file mode 100644 index 000000000..e0dd08d57 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_dataset.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_flowchart.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_flowchart.png new file mode 100644 index 000000000..5b4d9f5f7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_flowchart.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_user.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_user.png new file mode 100644 index 000000000..e4c0c0fb8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_tutorial_food_recommender_user.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users.png new file mode 100644 index 000000000..9fe3c057c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users_dark.png new file mode 100644 index 000000000..02840ff75 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users_light.png new file mode 100644 index 000000000..9fe3c057c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/personalization_agent_users_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.excalidraw.zip b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.excalidraw.zip new file mode 100644 index 000000000..4a8a0add2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.excalidraw.zip differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.mts b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.mts new file mode 100644 index 000000000..2f2eaf25a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.mts @@ -0,0 +1,569 @@ +import 'dotenv/config' + +interface DatasetItem { + properties: any; + vector?: number[]; + } + +async function populateWeaviate(client: WeaviateClient, overwriteExisting: boolean = false): Promise { + if (overwriteExisting) { + try { + await client.collections.delete('ECommerce'); + await client.collections.delete('Weather'); + await client.collections.delete('FinancialContracts'); + } catch (error) { + // Collections may not exist, continue + } + } + + // Create ECommerce collection + if (!(await client.collections.exists('ECommerce'))) { + await client.collections.create({ + name: 'ECommerce', + description: 'A dataset that lists clothing items, their brands, prices, and more.', + vectorizers: [ + vectors.text2VecWeaviate({ + name: 'description_vector', + sourceProperties: ['description'], + vectorIndexConfig: configure.vectorIndex.hnsw() + }), + vectors.text2VecWeaviate({ + name: 'name_description_brand_vector', + sourceProperties: ['name', 'description', 'brand'], + vectorIndexConfig: configure.vectorIndex.hnsw() + }) + ], + properties: [ + { + name: 'collection', + dataType: dataType.TEXT + }, + { + name: 'category', + dataType: dataType.TEXT, + description: 'The category to which the clothing item belongs' + }, + { + name: 'tags', + dataType: dataType.TEXT_ARRAY, + description: 'The tags that are associated with the clothing item' + }, + { + name: 'subcategory', + dataType: dataType.TEXT + }, + { + name: 'name', + dataType: dataType.TEXT + }, + { + name: 'description', + dataType: dataType.TEXT, + description: 'A detailed description of the clothing item' + }, + { + name: 'brand', + dataType: dataType.TEXT, + description: 'The brand of the clothing item' + }, + { + name: 'product_id', + dataType: dataType.UUID + }, + { + name: 'colors', + dataType: dataType.TEXT_ARRAY, + description: 'The colors on the clothing item' + }, + { + name: 'reviews', + dataType: dataType.TEXT_ARRAY + }, + { + name: 'image_url', + dataType: dataType.TEXT + }, + { + name: 'price', + dataType: dataType.NUMBER, + description: 'The price of the clothing item in USD' + } + ] + }); + } + + // Create Weather collection + if (!(await client.collections.exists('Weather'))) { + await client.collections.create({ + name: 'Weather', + description: 'Daily weather information including temperature, wind speed, precipitation, pressure etc.', + vectorizers: vectors.text2VecWeaviate(), + properties: [ + { + name: 'date', + dataType: dataType.DATE + }, + { + name: 'humidity', + dataType: dataType.NUMBER + }, + { + name: 'precipitation', + dataType: dataType.NUMBER + }, + { + name: 'wind_speed', + dataType: dataType.NUMBER + }, + { + name: 'visibility', + dataType: dataType.NUMBER + }, + { + name: 'pressure', + dataType: dataType.NUMBER + }, + { + name: 'temperature', + dataType: dataType.NUMBER, + description: 'temperature value in Celsius' + } + ] + }); + } + + // Create FinancialContracts collection + if (!(await client.collections.exists('FinancialContracts'))) { + await client.collections.create({ + name: 'FinancialContracts', + description: 'A dataset of financial contracts between individuals and/or companies, as well as information on the type of contract and who has authored them.', + vectorizers: vectors.text2VecWeaviate() + }); + } + + // Load datasets from Hugging Face + console.log('Loading datasets from Hugging Face...'); + + // Helper function to load dataset from HF Datasets Viewer API + async function loadHFDataset(repo: string, config: string, split: string = 'train'): Promise { + const url = `https://datasets-server.huggingface.co/rows?dataset=${repo}&config=${config}&split=${split}&limit=1000`; + + try { + const response = await fetch(url); + if (!response.ok) { + throw new Error(`Failed to fetch dataset: ${response.statusText}`); + } + + const data = await response.json(); + return data.rows.map((row: any) => row.row); + } catch (error) { + console.error(`Error loading dataset ${repo}/${config}:`, error); + return []; + } + } + + const ecommerceCollection = client.collections.use('ECommerce'); + const weatherCollection = client.collections.use('Weather'); + const financialCollection = client.collections.use('FinancialContracts'); + + try { + // Load datasets from Hugging Face + const [ecommerceData, weatherData, financialData] = await Promise.all([ + loadHFDataset('weaviate/agents', 'query-agent-ecommerce', 'train'), + loadHFDataset('weaviate/agents', 'query-agent-weather', 'train'), + loadHFDataset('weaviate/agents', 'query-agent-financial-contracts', 'train') + ]); + + console.log(`Loaded ${ecommerceData.length} ecommerce items`); + console.log(`Loaded ${weatherData.length} weather items`); + console.log(`Loaded ${financialData.length} financial items`); + + // Batch insert ecommerce data + if (ecommerceData.length > 0) { + await ecommerceCollection.data.insertMany( + ecommerceData.map(item => ({ properties: item.properties || item })) + ); + } + + // Batch insert weather data + if (weatherData.length > 0) { + await weatherCollection.data.insertMany( + weatherData.map(item => ({ + properties: item.properties || item, + vectors: item.vector ? { default: item.vector } : undefined + })) + ); + } + + // Batch insert financial data + if (financialData.length > 0) { + await financialCollection.data.insertMany( + financialData.map(item => ({ + properties: item.properties || item, + vectors: item.vector ? { default: item.vector } : undefined + })) + ); + } + } catch (error) { + console.error('Error loading or inserting data:', error); + } + + // Get collection sizes + const ecommerceCount = await ecommerceCollection.aggregate.overAll(); + const weatherCount = await weatherCollection.aggregate.overAll(); + const financialCount = await financialCollection.aggregate.overAll(); + + console.log(`Size of the ECommerce dataset: ${ecommerceCount.totalCount}`); + console.log(`Size of the Weather dataset: ${weatherCount.totalCount}`); + console.log(`Size of the Financial dataset: ${financialCount.totalCount}`); +} + + +// START InstantiateQueryAgent +import weaviate, { WeaviateClient, vectors, dataType, configure } from 'weaviate-client'; +import { QueryAgent, ChatMessage } from 'weaviate-agents'; + +// END InstantiateQueryAgent + +async function main() { +// START InstantiateQueryAgent +const headers = { + // END InstantiateQueryAgent + 'X-Cohere-API-Key': process.env.COHERE_API_KEY as string, + 'X-OpenAI-API-Key': process.env.OPENAI_API_KEY as string, + // START InstantiateQueryAgent + // Provide your required API key(s), e.g. Cohere, OpenAI, etc. for the configured vectorizer(s) + // "X-INFERENCE-PROVIDER-API-KEY": process.env.YOUR_INFERENCE_PROVIDER_KEY, +}; + +const client = await weaviate.connectToWeaviateCloud(process.env.WEAVIATE_URL as string, { + authCredentials: new weaviate.ApiKey(process.env.WEAVIATE_ADMIN_KEY as string), + headers +}); +// END InstantiateQueryAgent + +// Populate Weaviate with data +await populateWeaviate(client); + +// START InstantiateQueryAgent +// Instantiate a new agent object +const queryAgent = new QueryAgent( + client, { + collections: ['ECommerce', 'FinancialContracts', 'Weather'], + +}); +// END InstantiateQueryAgent + +// START SystemPromptExample +// Define a custom system prompt to guide the agent's behavior +const systemPrompt = `You are a helpful assistant that can answer questions about the products and + users in the database. When you write your response use standard markdown + formatting for lists, tables, and other structures. Emphasize key insights + and provide actionable recommendations when relevant.` + +const qaWithPrompt = new QueryAgent( + client, { + collections: [{ + name: 'ECommerce', + targetVector: ['name_description_brand_vector'], + viewProperties: ['description'] + // tenant: 'tenantA' // Optional for multi-tenancy + }, "FinancialContracts", "Weather"], + systemPrompt: systemPrompt +}) + +const responseWithPrompt = await qaWithPrompt.ask("What are the most expensive items in the store?") + +responseWithPrompt.display() +// END SystemPromptExample + +// START QueryAgentCollectionConfiguration +const qaWithConfig = new QueryAgent(client, { + collections: [ + { + name: 'ECommerce', + targetVector: ['name_description_brand_vector'], + viewProperties: ['description'] + // tenant: 'tenantA' // Optional for multi-tenancy + }, + { name: 'FinancialContracts' }, + { name: 'Weather' } + ] +}); +// END QueryAgentCollectionConfiguration + +// START UserDefinedFilters +// Apply persistent filters that will always be combined with agent-generated filters + +const eCommerceCollection = client.collections.use("ECommerce") + +const qaWithFilter = new QueryAgent( + client, { + collections: [{ + name: "ECommerce", + // This filter ensures only items above $50 are considered + additionalFilters: eCommerceCollection.filter.byProperty("price").greaterThan(50), + targetVector:[ + "name_description_brand_vector" + ], // Required target vector name(s) for collections with named vectors + }], +}) + +// The agent will automatically combine these filters with any it generates +const responseWithFilter = await qaWithFilter.ask("Find me some affordable clothing items") + +responseWithFilter.display() + +// You can also apply filters dynamically at runtime +const runtimeConfig = { + name: "ECommerce", + additionalFilters: eCommerceCollection.filter.byProperty("category").equal("Footwear"), + targetVector:["name_description_brand_vector"] +} + +const responseWithRuntimeFilter = await queryAgent.ask("What products are available?", { + collections: [runtimeConfig] +}) + +responseWithRuntimeFilter.display() +// END UserDefinedFilters + + +// Reset qa to original configuration for following examples +const qa = new QueryAgent( + client, { + collections: [ + { + name:"ECommerce", + targetVector: ["name_description_brand_vector"], + viewProperties: ["name", "description", "price"], + }, + "FinancialContracts", + "Weather", + ], +}) + +// START QueryAgentAskBasicCollectionSelection +const contractResponse = await qa.ask( + "What kinds of contracts are listed? What's the most common type of contract?", { + collections: ['FinancialContracts'] +}); + +contractResponse.display(); +// END QueryAgentAskBasicCollectionSelection + +// START QueryAgentAskCollectionConfig +const clothingResponse = await qaWithConfig.ask( + "I like vintage clothes and nice shoes. Recommend some of each below $60.", { + collections: [ + { + name: 'ECommerce', + targetVector: ['name_description_brand_vector'], + viewProperties: ['name', 'description', 'category', 'brand'] + }, + { + name: 'FinancialContracts' + } + ] +}); + +clothingResponse.display(); +// END QueryAgentAskCollectionConfig + +// START BasicSearchQuery +// Perform a search using Search Mode (retrieval only, no answer generation) +const basicSearchResponse = await qa.search("Find me some vintage shoes under $70", { + limit: 10 +} ) + +// Access the search results +for (const obj of basicSearchResponse.searchResults.objects) { + console.log(`Product: ${obj.properties['name']} - ${obj.properties['price']}`) +} +// END BasicSearchQuery + + +// START BasicAskQuery +// Perform a query +const basicQuery = "I like vintage clothes and nice shoes. Recommend some of each below $60." +const basicResponse = await qaWithConfig.ask(basicQuery); + +basicResponse.display(); +// END BasicAskQuery + +// START SearchModeResponseStructure +// SearchModeResponse structure for TypeScript +const searchResponse = await qa.search("winter boots for under $100", { + limit: 5 +}) + +// Access different parts of the response +console.log("Original query:", basicQuery) +console.log("Total time:", searchResponse.totalTime) + +// Access usage statistics +console.log("Usage statistics:", searchResponse.usage) + +// Access the searches performed (if any) +if (searchResponse.searches) { + for (const search in searchResponse.searches) { + console.log("Search performed:", search) + } +} +// Access the search results (QueryReturn object) +for (const obj of searchResponse.searchResults.objects){ + console.log("Properties:", obj.properties) + console.log("Metadata:", obj.metadata) +} +// END SearchModeResponseStructure + +// START SearchPagination +// Search with pagination +const responsePage1 = await qa.search( + "Find summer shoes and accessories between $50 and $100 that have the tag 'sale'", { + limit: 3, +}) + +// Get the next page of results +const responsePage2 = await responsePage1.next({ + limit: 3, + offset: 3, +}) + +// Continue paginating +const responsePage3 = await responsePage2.next({ + limit: 3, + offset: 6, +}) + +const pages = [responsePage1, responsePage2, responsePage3]; + +pages.forEach((pageResponse, index) => { + const pageNum = index + 1; + console.log(`Page ${pageNum}:`); + + pageResponse.searchResults.objects.forEach(obj => { + // Safely access properties in case they don't exist + const name = obj.properties.name || "Unknown Product"; + const price = obj.properties.price || "Unknown Price"; + console.log(`${name} - $${price}`); + }); +}); +// END SearchPagination + + +// START FollowUpQuery +// Perform a follow-up query and include the answer from the previous query + +const basicConversation: ChatMessage[] = [ + { role: "assistant", content: basicResponse.finalAnswer }, + { + role: "user", + content: "I like the vintage clothes options, can you do the same again but above $200?", + }, +] + +const followingResponse = await qaWithConfig.ask(basicConversation) + +// Print the response +followingResponse.display() +// END FollowUpQuery + +// START ConversationalQuery +// Create a conversation with multiple turns +const conversation: ChatMessage[] = [ + { role: "user", content: "Hi!"}, + { role: "assistant", content: "Hello! How can I assist you today?"}, + { + role: "user", + content: "I have some questions about the weather data. You can assume the temperature is in Fahrenheit and the wind speed is in mph.", + }, + { + role: "assistant", + content: "I can help with that. What specific information are you looking for?", + }, +] + +// Add the user's query +conversation.push( + { + role: "user", + content: "What's the average wind speed, the max wind speed, and the min wind speed", + } +) + +// Get the response +const response = await qaWithConfig.ask(conversation) +console.log(response.finalAnswer) + +// Continue the conversation +conversation.push({role: "assistant", content: response.finalAnswer}) +conversation.push({role: "user", content: "and for the temperature?"}) + +const followUpResponse = await qaWithConfig.ask(conversation) +console.log(followUpResponse.finalAnswer) +// END ConversationalQuery + +var query = "What is the weather like in San Francisco?"; + +// START StreamResponse +// Setting includeProgress to false will skip progressMessages, and only stream +// the streamedTokens / the final response. +for await (const event of qa.askStream(query, { + includeProgress: true, // Default: True + includeFinalState: true, // Default: True +})) { + if (event.outputType === "progressMessage") { + // The message is a human-readable string, structured info available in event.details + console.log(event.message); + } else if (event.outputType === "streamedTokens") { + // The delta is a string containing the next chunk of the final answer + process.stdout.write(event.delta); + } else { + // This is the final response, as returned by queryAgent.ask() + event.display(); + } +} +// END StreamResponse + +// START InspectResponseExample +console.log('\n=== Query Agent Response ==='); +console.log(`Original Query: ${basicQuery}\n`); // Pre-defined by user + +console.log('🔍 Final Answer Found:'); +console.log(`${basicResponse.finalAnswer}\n`); + +console.log('🔍 Searches Executed:'); +for (const collectionSearches of basicResponse.searches) { + console.log(`- ${collectionSearches.query}\n`); +} + +if (basicResponse.aggregations) { + console.log('📊 Aggregation Results:'); + for (const collectionAggs of basicResponse.aggregations) { + for (const agg in collectionAggs) { + console.log(`- ${agg}\n`); + } + } +} + +if (basicResponse.missingInformation && basicResponse.missingInformation.length > 0) { + if (basicResponse.isPartialAnswer) { + console.log('⚠️ Answer is Partial - Missing Information:'); + } else { + console.log('⚠️ Missing Information:'); + } + for (const missing of basicResponse.missingInformation) { + console.log(`- ${missing}`); + } +} +// END InspectResponseExample + +if (!basicResponse.finalAnswer || basicResponse.finalAnswer === '') { + throw new Error('Final answer is empty or null'); +} +await client.close() + +} + +void main(); diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.py b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.py new file mode 100644 index 000000000..418c819ad --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent.py @@ -0,0 +1,642 @@ +from weaviate.classes.config import Configure, Property, DataType + + +def populate_weaviate(client, overwrite_existing=False): + + if overwrite_existing: + client.collections.delete("ECommerce") + client.collections.delete("Weather") + client.collections.delete("FinancialContracts") + + if not client.collections.exists("ECommerce"): + client.collections.create( + "ECommerce", + description="A dataset that lists clothing items, their brands, prices, and more.", + vector_config=[ + Configure.Vectors.text2vec_weaviate( + name="description_vector", + source_properties=[ + "description", + ], + ), + Configure.Vectors.text2vec_weaviate( + name="name_description_brand_vector", + source_properties=[ + "name", + "description", + "brand", + ], + ), + ], + properties=[ + Property(name="collection", data_type=DataType.TEXT), + Property( + name="category", + data_type=DataType.TEXT, + description="The category to which the clothing item belongs", + ), + Property( + name="tags", + data_type=DataType.TEXT_ARRAY, + description="The tags that are assocciated with the clothing item", + ), + Property(name="subcategory", data_type=DataType.TEXT), + Property(name="name", data_type=DataType.TEXT), + Property( + name="description", + data_type=DataType.TEXT, + description="A detailed description of the clothing item", + ), + Property( + name="brand", + data_type=DataType.TEXT, + description="The brand of the clothing item", + ), + Property(name="product_id", data_type=DataType.UUID), + Property( + name="colors", + data_type=DataType.TEXT_ARRAY, + description="The colors on the clothing item", + ), + Property(name="reviews", data_type=DataType.TEXT_ARRAY), + Property(name="image_url", data_type=DataType.TEXT), + Property( + name="price", + data_type=DataType.NUMBER, + description="The price of the clothing item in USD", + ), + ], + ) + overwrite_existing = True + + if not client.collections.exists("Weather"): + client.collections.create( + "Weather", + description="Daily weather information including temperature, wind speed, precipitation, pressure etc.", + vector_config=Configure.Vectors.text2vec_weaviate(), + properties=[ + Property(name="date", data_type=DataType.DATE), + Property(name="humidity", data_type=DataType.NUMBER), + Property(name="precipitation", data_type=DataType.NUMBER), + Property(name="wind_speed", data_type=DataType.NUMBER), + Property(name="visibility", data_type=DataType.NUMBER), + Property(name="pressure", data_type=DataType.NUMBER), + Property( + name="temperature", + data_type=DataType.NUMBER, + description="temperature value in Celsius", + ), + ], + ) + overwrite_existing = True + + if not client.collections.exists("FinancialContracts"): + client.collections.create( + "FinancialContracts", + description="A dataset of financial contracts between individuals and/or companies, as well as information on the type of contract and who has authored them.", + vector_config=Configure.Vectors.text2vec_weaviate(), + ) + overwrite_existing = True + + from datasets import load_dataset + + if not overwrite_existing: + print("Data already exists in Weaviate, skipping import.") + return + + ecommerce_dataset = load_dataset( + "weaviate/agents", "query-agent-ecommerce", split="train", streaming=True + ) + weather_dataset = load_dataset( + "weaviate/agents", "query-agent-weather", split="train", streaming=True + ) + financial_dataset = load_dataset( + "weaviate/agents", + "query-agent-financial-contracts", + split="train", + streaming=True, + ) + + ecommerce_collection = client.collections.use("ECommerce") + weather_collection = client.collections.use("Weather") + financial_collection = client.collections.use("FinancialContracts") + + print("\nImport `query-agent-ecommerce` dataset into Weaviate") + with ecommerce_collection.batch.fixed_size(batch_size=200) as batch: + for item in ecommerce_dataset: + batch.add_object(properties=item["properties"]) + if batch.number_errors > 0: + print("Batch import stopped due to excessive errors.") + break + + failed_objects = ecommerce_collection.batch.failed_objects + if failed_objects: + print(f"Number of failed imports: {len(failed_objects)}") + print(f"First failed object: {failed_objects[0]}") + + print("\nImport `query-agent-weather` dataset into Weaviate") + with weather_collection.batch.fixed_size(batch_size=200) as batch: + for item in weather_dataset: + batch.add_object(properties=item["properties"], vector=item["vector"]) + if batch.number_errors > 0: + print("Batch import stopped due to excessive errors.") + break + + failed_objects = weather_collection.batch.failed_objects + if failed_objects: + print(f"Number of failed imports: {len(failed_objects)}") + print(f"First failed object: {failed_objects[0]}") + + print("\nImport `query-agent-financial-contracts` dataset into Weaviate") + with financial_collection.batch.fixed_size(batch_size=200) as batch: + for item in financial_dataset: + batch.add_object(properties=item["properties"], vector=item["vector"]) + if batch.number_errors > 0: + print("Batch import stopped due to excessive errors.") + break + + failed_objects = financial_collection.batch.failed_objects + if failed_objects: + print(f"Number of failed imports: {len(failed_objects)}") + print(f"First failed object: {failed_objects[0]}") + + print("\nData import complete!") + print(f"Size of the ECommerce dataset: {len(ecommerce_collection)}") + print(f"Size of the Weather dataset: {len(weather_collection)}") + print(f"Size of the Financial dataset: {len(financial_collection)}") + + client.close() # Free up resources + + +# START InstantiateQueryAgent +import os +import weaviate +from weaviate.classes.init import Auth +from weaviate.agents.query import QueryAgent + +# END InstantiateQueryAgent + +# START InstantiateQueryAgent + +headers = { + # END InstantiateQueryAgent + "X-Cohere-API-Key": os.environ.get("COHERE_API_KEY"), + "X-OpenAI-API-Key": os.environ.get("OPENAI_API_KEY"), + # START InstantiateQueryAgent + # Provide your required API key(s), e.g. Cohere, OpenAI, etc. for the configured vectorizer(s) + "X-INFERENCE-PROVIDER-API-KEY": os.environ.get("YOUR_INFERENCE_PROVIDER_KEY", ""), +} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=Auth.api_key(os.environ.get("WEAVIATE_API_KEY")), + headers=headers, +) +# END InstantiateQueryAgent + +populate_weaviate( + client, overwrite_existing=False +) # Populate the Weaviate instance with data + +# START InstantiateQueryAgent + +# Instantiate a new agent object +qa = QueryAgent( + client=client, collections=["ECommerce", "FinancialContracts", "Weather"] +) +# END InstantiateQueryAgent + +# START SystemPromptExample +from weaviate.agents.query import QueryAgent + +# Define a custom system prompt to guide the agent's behavior +system_prompt = """You are a helpful assistant that can answer questions about the products and users in the database. +When you write your response use standard markdown formatting for lists, tables, and other structures. +Emphasize key insights and provide actionable recommendations when relevant.""" + +qa = QueryAgent( + client=client, + collections=["ECommerce", "FinancialContracts", "Weather"], + system_prompt=system_prompt, +) + +response = qa.ask("What are the most expensive items in the store?") +response.display() +# END SystemPromptExample + +# START QueryAgentCollectionConfiguration +from weaviate.agents.query import QueryAgent +from weaviate.agents.classes import QueryAgentCollectionConfig + +qa = QueryAgent( + client=client, + collections=[ + QueryAgentCollectionConfig( + name="ECommerce", # The name of the collection to query + target_vector=[ + "name_description_brand_vector" + ], # Target vector name(s) for collections with named vectors + view_properties=[ + "name", + "description", + "price", + ], # Optional list of property names the agent can view + # Optional tenant name for collections with multi-tenancy enabled + # tenant="tenantA" + ), + QueryAgentCollectionConfig(name="FinancialContracts"), + QueryAgentCollectionConfig(name="Weather"), + ], +) +# END QueryAgentCollectionConfiguration + +# START UserDefinedFilters +from weaviate.agents.query import QueryAgent +from weaviate.agents.classes import QueryAgentCollectionConfig +from weaviate.classes.query import Filter + +# Apply persistent filters that will always be combined with agent-generated filters +qa = QueryAgent( + client=client, + collections=[ + QueryAgentCollectionConfig( + name="ECommerce", + # This filter ensures only items above $50 are considered + additional_filters=Filter.by_property("price").greater_than(50), + target_vector=[ + "name_description_brand_vector" + ], # Required target vector name(s) for collections with named vectors + ), + ], +) + +# The agent will automatically combine these filters with any it generates +response = qa.ask("Find me some affordable clothing items") +response.display() + +# You can also apply filters dynamically at runtime +runtime_config = QueryAgentCollectionConfig( + name="ECommerce", + additional_filters=Filter.by_property("category").equal("Footwear"), +) + +response = qa.ask("What products are available?", collections=[runtime_config]) +response.display() +# END UserDefinedFilters + +# Reset qa to original configuration for following examples +qa = QueryAgent( + client=client, + collections=[ + QueryAgentCollectionConfig( + name="ECommerce", + target_vector=["name_description_brand_vector"], + view_properties=["name", "description", "price"], + ), + QueryAgentCollectionConfig(name="FinancialContracts"), + QueryAgentCollectionConfig(name="Weather"), + ], +) + +# START QueryAgentAskBasicCollectionSelection +response = qa.ask( + "What kinds of contracts are listed? What's the most common type of contract?", + collections=["FinancialContracts"], +) + +response.display() +# END QueryAgentAskBasicCollectionSelection + +# START QueryAgentAskCollectionConfig +from weaviate.agents.classes import QueryAgentCollectionConfig + +response = qa.ask( + "I like vintage clothes and nice shoes. Recommend some of each below $60.", + collections=[ + # Use QueryAgentCollectionConfig class to provide further collection configuration + QueryAgentCollectionConfig( + name="ECommerce", # The name of the collection to query + target_vector=[ + "name_description_brand_vector" + ], # Required target vector name(s) for collections with named vectors + view_properties=[ + "name", + "description", + "category", + "brand", + ], # Optional list of property names the agent can view + ), + QueryAgentCollectionConfig( + name="FinancialContracts", # The name of the collection to query + # Optional tenant name for collections with multi-tenancy enabled + # tenant="tenantA" + ), + ], +) + +response.display() +# END QueryAgentAskCollectionConfig + +# START BasicAskQuery +# Perform a query using Ask Mode (with answer generation) +response = qa.ask( + "I like vintage clothes and nice shoes. Recommend some of each below $60." +) + +# Print the response +response.display() +# END BasicAskQuery + +# START BasicSearchQuery +# Perform a search using Search Mode (retrieval only, no answer generation) +search_response = qa.search("Find me some vintage shoes under $70", limit=10) + +# Access the search results +for obj in search_response.search_results.objects: + print(f"Product: {obj.properties['name']} - ${obj.properties['price']}") +# END BasicSearchQuery + +# START SearchModeResponseStructure +# SearchModeResponse structure for Python +search_response = qa.search("winter boots for under $100", limit=5) + +# Access different parts of the response +print(f"Original query: {search_response.original_query}") +print(f"Total time: {search_response.total_time}") + +# Access usage statistics +print(f"Usage statistics: {search_response.usage}") + +# Access the searches performed (if any) +if search_response.searches: + for search in search_response.searches: + print(f"Search performed: {search}") + +# Access the search results (QueryReturn object) +for obj in search_response.search_results.objects: + print(f"Properties: {obj.properties}") + print(f"Metadata: {obj.metadata}") +# END SearchModeResponseStructure + +# START SearchPagination +# Search with pagination +response_page_1 = qa.search( + "Find summer shoes and accessories between $50 and $100 that have the tag 'sale'", + limit=3, +) + +# Get the next page of results +response_page_2 = response_page_1.next(limit=3, offset=3) + +# Continue paginating +response_page_3 = response_page_2.next(limit=3, offset=3) + +# Access results from each page +for page_num, page_response in enumerate( + [response_page_1, response_page_2, response_page_3], 1 +): + print(f"Page {page_num}:") + for obj in page_response.search_results.objects: + # Safely access properties in case they don't exist + name = obj.properties.get("name", "Unknown Product") + price = obj.properties.get("price", "Unknown Price") + print(f" {name} - ${price}") + print() +# END SearchPagination + +# START FollowUpQuery +# Perform a follow-up query and include the answer from the previous query +from weaviate.agents.classes import ChatMessage + +conversation = [ + ChatMessage(role="assistant", content=response.final_answer), + ChatMessage( + role="user", + content="I like the vintage clothes options, can you do the same again but above $200?", + ), +] + +following_response = qa.ask(conversation) + +# Print the response +following_response.display() +# END FollowUpQuery + +# START ConversationalQuery +from weaviate.agents.classes import ChatMessage + +# Create a conversation with multiple turns +conversation = [ + ChatMessage(role="user", content="Hi!"), + ChatMessage(role="assistant", content="Hello! How can I assist you today?"), + ChatMessage( + role="user", + content="I have some questions about the weather data. You can assume the temperature is in Fahrenheit and the wind speed is in mph.", + ), + ChatMessage( + role="assistant", + content="I can help with that. What specific information are you looking for?", + ), +] + +# Add the user's query +conversation.append( + ChatMessage( + role="user", + content="What's the average wind speed, the max wind speed, and the min wind speed", + ) +) + +# Get the response +response = qa.ask(conversation) +print(response.final_answer) + +# Continue the conversation +conversation.append(ChatMessage(role="assistant", content=response.final_answer)) +conversation.append(ChatMessage(role="user", content="and for the temperature?")) + +response = qa.ask(conversation) +print(response.final_answer) +# END ConversationalQuery + +query = "What are the top 5 products sold in the last 30 days?" + +# START StreamResponse +from weaviate.agents.classes import ProgressMessage, StreamedTokens + +for output in qa.ask_stream( + query, + # Setting this to false will skip ProgressMessages, and only stream + # the StreamedTokens / the final QueryAgentResponse + include_progress=True, # Default is True + include_final_state=True, # Default is True +): + if isinstance(output, ProgressMessage): + # The message is a human-readable string, structured info available in output.details + print(output.message) + elif isinstance(output, StreamedTokens): + # The delta is a string containing the next chunk of the final answer + print(output.delta, end="", flush=True) + else: + # This is the final response, as returned by QueryAgent.ask() + output.display() +# END StreamResponse + +# START InspectResponseExample +print("\n=== Query Agent Response ===") +print(f"Original Query: {response.original_query}\n") + +print("🔍 Final Answer Found:") +print(f"{response.final_answer}\n") + +print("🔍 Searches Executed:") +for collection_searches in response.searches: + for result in collection_searches: + print(f"- {result}\n") + +if len(response.aggregations) > 0: + print("📊 Aggregation Results:") + for collection_aggs in response.aggregations: + for agg in collection_aggs: + print(f"- {agg}\n") + +if response.missing_information: + if response.is_partial_answer: + print("⚠️ Answer is Partial - Missing Information:") + else: + print("⚠️ Missing Information:") + for missing in response.missing_information: + print(f"- {missing}") +# END InspectResponseExample + +assert response.final_answer != "" and response.final_answer is not None + +client.close() + +# START UsageAsyncQueryAgent +import asyncio +import os +import weaviate +from weaviate.agents.query import AsyncQueryAgent + + +async_client = weaviate.use_async_with_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=os.environ.get("WEAVIATE_API_KEY"), + headers=headers, +) + + +async def query_vintage_clothes(async_query_agent: AsyncQueryAgent): + response = await async_query_agent.ask( + "I like vintage clothes and nice shoes. Recommend some of each below $60." + ) + return ("Vintage Clothes", response) + + +async def query_financial_data(async_query_agent: AsyncQueryAgent): + response = await async_query_agent.ask( + "What kinds of contracts are listed? What's the most common type of contract?", + ) + return ("Financial Contracts", response) + + +async def run_concurrent_queries(): + try: + await async_client.connect() + + async_qa = AsyncQueryAgent( + async_client, + collections=[ + QueryAgentCollectionConfig( + name="ECommerce", # The name of the collection to query + target_vector=[ + "name_description_brand_vector" + ], # Optional target vector name(s) for collections with named vectors + view_properties=[ + "name", + "description", + "category", + "brand", + ], # Optional list of property names the agent can view + ), + QueryAgentCollectionConfig( + name="FinancialContracts", # The name of the collection to query + # Optional tenant name for collections with multi-tenancy enabled + # tenant="tenantA" + ), + ], + ) + + # Wait for both to complete + vintage_response, financial_response = await asyncio.gather( + query_vintage_clothes(async_qa), query_financial_data(async_qa) + ) + + # Display results + print(f"=== {vintage_response[0]} ===") + vintage_response[1].display() + + print(f"=== {financial_response[0]} ===") + financial_response[1].display() + + finally: + await async_client.close() + + +asyncio.run(run_concurrent_queries()) +# END UsageAsyncQueryAgent + + +# START StreamAsyncResponse +async def stream_query(async_query_agent: AsyncQueryAgent): + async for output in async_query_agent.ask_stream( + "What are the top 5 products sold in the last 30 days?", + # Setting this to false will skip ProgressMessages, and only stream + # the StreamedTokens / the final QueryAgentResponse + include_progress=True, # Default is True + ): + if isinstance(output, ProgressMessage): + # The message is a human-readable string, structured info available in output.details + print(output.message) + elif isinstance(output, StreamedTokens): + # The delta is a string containing the next chunk of the final answer + print(output.delta, end="", flush=True) + else: + # This is the final response, as returned by QueryAgent.ask() + output.display() + + +async def run_streaming_query(): + try: + await async_client.connect() + async_qa = AsyncQueryAgent( + async_client, + collections=[ + QueryAgentCollectionConfig( + name="ECommerce", # The name of the collection to query + target_vector=[ + "name_description_brand_vector" + ], # Optional target vector name(s) for collections with named vectors + view_properties=[ + "name", + "description", + "category", + "brand", + ], # Optional list of property names the agent can view + ), + QueryAgentCollectionConfig( + name="FinancialContracts", # The name of the collection to query + # Optional tenant name for collections with multi-tenancy enabled + # tenant="tenantA" + ), + ], + ) + await stream_query(async_qa) + + finally: + await async_client.close() + + +asyncio.run(run_streaming_query()) +# END StreamAsyncResponse diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_architecture_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_architecture_dark.png new file mode 100644 index 000000000..8c2523001 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_architecture_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_architecture_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_architecture_light.png new file mode 100644 index 000000000..c0835c453 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_architecture_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_info_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_info_dark.png new file mode 100644 index 000000000..f7d400505 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_info_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_info_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_info_light.png new file mode 100644 index 000000000..f5c8e4f99 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_info_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce.py b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce.py new file mode 100644 index 000000000..655cc677b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce.py @@ -0,0 +1,195 @@ +# START ConnectToWeaviate +import os +import weaviate +from weaviate.auth import Auth + +# Best practice: store your credentials in environment variables +weaviate_url = os.environ["WEAVIATE_URL"] +weaviate_api_key = os.environ["WEAVIATE_API_KEY"] + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=Auth.api_key(weaviate_api_key), +) + +print(client.is_ready()) # Should print: `True` + +# Your work goes here! + +client.close() # Free up resources +# END ConnectToWeaviate + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=Auth.api_key(weaviate_api_key), +) + +client.collections.delete("Brands") +client.collections.delete("ECommerce") + +# START DefineCollections +from weaviate.classes.config import Configure, Property, DataType + +# Using `auto-schema` to infer the data schema during import +client.collections.create( + "Brands", + description="A dataset that lists information about clothing brands, their parent companies, average rating and more.", + vector_config=Configure.Vectors.text2vec_weaviate(), +) + +# Explicitly defining the data schema +client.collections.create( + "ECommerce", + description="A dataset that lists clothing items, their brands, prices, and more.", + vector_config=Configure.Vectors.text2vec_weaviate(), + properties=[ + Property(name="collection", data_type=DataType.TEXT), + Property( + name="category", + data_type=DataType.TEXT, + description="The category to which the clothing item belongs", + ), + Property( + name="tags", + data_type=DataType.TEXT_ARRAY, + description="The tags that are assocciated with the clothing item", + ), + Property(name="subcategory", data_type=DataType.TEXT), + Property(name="name", data_type=DataType.TEXT), + Property( + name="description", + data_type=DataType.TEXT, + description="A detailed description of the clothing item", + ), + Property( + name="brand", + data_type=DataType.TEXT, + description="The brand of the clothing item", + ), + Property(name="product_id", data_type=DataType.UUID), + Property( + name="colors", + data_type=DataType.TEXT_ARRAY, + description="The colors on the clothing item", + ), + Property(name="reviews", data_type=DataType.TEXT_ARRAY), + Property(name="image_url", data_type=DataType.TEXT), + Property( + name="price", + data_type=DataType.NUMBER, + description="The price of the clothing item in USD", + ), + ], +) +# END DefineCollections + +# START PopulateDatabase +from datasets import load_dataset + +brands_dataset = load_dataset( + "weaviate/agents", "query-agent-brands", split="train", streaming=True +) +ecommerce_dataset = load_dataset( + "weaviate/agents", "query-agent-ecommerce", split="train", streaming=True +) + +brands_collection = client.collections.use("Brands") +ecommerce_collection = client.collections.use("ECommerce") + +with brands_collection.batch.fixed_size(batch_size=200) as batch: + for item in brands_dataset: + batch.add_object(properties=item["properties"], vector=item["vector"]) + +with ecommerce_collection.batch.fixed_size(batch_size=200) as batch: + for item in ecommerce_dataset: + batch.add_object(properties=item["properties"], vector=item["vector"]) + +failed_objects = brands_collection.batch.failed_objects +if failed_objects: + print(f"Number of failed imports: {len(failed_objects)}") + print(f"First failed object: {failed_objects[0]}") + +print(f"Size of the ECommerce dataset: {len(ecommerce_collection)}") +print(f"Size of the Brands dataset: {len(brands_collection)}") +# END PopulateDatabase + +# START BasicQueryAgent +from weaviate.agents.query import QueryAgent + +qa = QueryAgent( + client=client, + collections=["ECommerce", "Brands"], +) +# END BasicQueryAgent + +# START CustomizedQueryAgent +multi_lingual_qa = QueryAgent( + client=client, + collections=["ECommerce", "Brands"], + system_prompt="You are a helpful assistant that always generates the final response in the user's language." + "You may have to translate the user query to perform searches. But you must always respond to the user in their own language.", +) +# END CustomizedQueryAgent + +# START AskQuestions +response = qa.ask( + "I like vintage clothes, can you list me some options that are less than $200?" +) + +response.display() +# END AskQuestions + +# START FinalAnswerAskQuestions +# Only print the final answer of the response +print(response.final_answer) +# END FinalAnswerAskQuestions + +# START PrintQueryAgentResponseAskQuestions +# Print the whole response in a user-friendly format +response.display() +# END PrintQueryAgentResponseAskQuestions + +# START FollowUpAskQuestions +from weaviate.agents.classes import ChatMessage + +# Create a conversation with the previous response +conversation = [ + ChatMessage( + role="user", + content="I like vintage clothes, can you list me some options that are less than $200?", + ), + ChatMessage(role="assistant", content=response.final_answer), + ChatMessage( + role="user", content="What about some nice shoes, same budget as before?" + ), +] + +new_response = qa.ask(conversation) + +new_response.display() +# END FollowUpAskQuestions + +# START Aggregation +response = qa.ask("What is the the name of the brand that lists the most shoes?") + +response.display() +# END Aggregation + +# START SearchOverMultipleCollections +response = qa.ask( + "Does the brand 'Loom & Aura' have a parent brand or child brands and what countries do they operate from? " + "Also, what's the average price of a shoe from 'Loom & Aura'?" +) + +response.display() +# END SearchOverMultipleCollections + +# START MoreQuestions +response = multi_lingual_qa.ask( + '"Eko & Stitch"は英国に支店または関連会社がありますか?' +) + +print(response.final_answer) +# END MoreQuestions + +client.close() # Free up resources diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce_dataset.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce_dataset.png new file mode 100644 index 000000000..d8e31fab9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce_dataset.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce_flowchart.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce_flowchart.png new file mode 100644 index 000000000..494c65421 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_tutorial_ecommerce_flowchart.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_usage_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_usage_dark.png new file mode 100644 index 000000000..331f5ca2d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_usage_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_usage_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_usage_light.png new file mode 100644 index 000000000..8f10e20aa Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/query_agent_usage_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent.excalidraw.zip b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent.excalidraw.zip new file mode 100644 index 000000000..7c4d33a6c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent.excalidraw.zip differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent.py b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent.py new file mode 100644 index 000000000..2deeae77f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent.py @@ -0,0 +1,144 @@ +# START-ANY +# [🚧 CAUTION 🚧] DO NOT USE ON PRODUCTION DATA. +# The Transformation Agent will modify your data in place. +# While the Transformation Agent is in technical preview, +# it is recommended to only use it on test data. + +# END-ANY + +# START SimpleTransformationAgentExample # START ConnectToWeaviate +import os +import weaviate +from weaviate.classes.init import Auth +# START SimpleTransformationAgentExample # START StartTransformationOperations # END ConnectToWeaviate +from weaviate.agents.transformation import TransformationAgent +# START SimpleTransformationAgentExample # END StartTransformationOperations +from weaviate.agents.classes import Operations + +# END SimpleTransformationAgentExample + +# START DefineOperationsAppend # START DefineOperationsUpdate +from weaviate.agents.classes import Operations + +# END DefineOperationsAppend # END DefineOperationsUpdate + +from weaviate.classes.config import Configure, Property, DataType +from datasets import load_dataset + +# START SimpleTransformationAgentExample # START ConnectToWeaviate + +headers = { + # END SimpleTransformationAgentExample + "X-Cohere-API-Key": os.environ.get("COHERE_API_KEY"), + # START SimpleTransformationAgentExample + # Provide your required API key(s), e.g. Cohere, OpenAI, etc. for the configured vectorizer(s) + "X-INFERENCE-PROVIDER-API-KEY": os.environ.get("YOUR_INFERENCE_PROVIDER_KEY", ""), +} + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=Auth.api_key(os.environ.get("WEAVIATE_API_KEY")), + headers=headers, +) + +# END SimpleTransformationAgentExample # END ConnectToWeaviate + +client.collections.delete("ArxivPapers") + +client.collections.create( + "ArxivPapers", + description="A dataset that lists research paper titles and abstracts", + vector_config=Configure.Vectors.text2vec_weaviate(), +) + +dataset = load_dataset( + "weaviate/agents", "transformation-agent-papers", split="train", streaming=True +) + +papers_collection = client.collections.use("ArxivPapers") + +with papers_collection.batch.fixed_size(batch_size=100) as batch: + for i, item in enumerate(dataset): + if i < 10: + batch.add_object(properties=item["properties"]) + + +# START SimpleTransformationAgentExample +add_topics = Operations.append_property( + property_name="topics", + data_type=DataType.TEXT_ARRAY, + view_properties=["abstract", "title"], + instruction="""Create a list of topic tags based on the title and abstract. + Topics should be distinct from eachother. Provide a maximum of 5 topics. + Group similar topics under one topic tag.""", +) + +agent = TransformationAgent( + client=client, + collection="ArxivPapers", + operations=[add_topics], +) + +response = agent.update_all() # The response is a TransformationResponse object + +agent.get_status(workflow_id=response.workflow_id) # Use the workflow_id to check the status of each workflow +# END SimpleTransformationAgentExample + +# START DefineOperationsAppend +add_french_abstract = Operations.append_property( + property_name="french_abstract", + data_type=DataType.TEXT, + view_properties=["abstract"], + instruction="Translate the abstract to French", +) + +add_nlp_relevance = Operations.append_property( + property_name="nlp_relevance", + data_type=DataType.INT, + view_properties=["abstract"], + instruction="""Give a score from 0-10 based on how relevant the abstract is to Natural Language Processing. + The scale is from 0 (not relevant at all) to 10 (very relevant)""", +) + +is_survey_paper = Operations.append_property( + property_name="is_survey_paper", + data_type=DataType.BOOL, + view_properties=["abstract"], + instruction="""Determine if the paper is a "survey". + A paper is considered survey it's a surveys existing techniques, and not if it presents novel techniques""", +) +# END DefineOperationsAppend + +# START DefineOperationsUpdate +update_topics = Operations.update_property( + property_name="topics", + view_properties=["abstract", "title"], + instruction="""Create a list of topic tags based on the title and abstract. + Topics should be distinct from eachother. Provide a maximum of 3 topics. + Group similar topics under one topic tag.""", +) +# END DefineOperationsUpdate + +# START StartTransformationOperations + +agent = TransformationAgent( + client=client, + collection="ArxivPapers", + operations=[ + add_french_abstract, + add_nlp_relevance, + is_survey_paper, + update_topics, + ], +) + +response = agent.update_all() + +print(response) # The response is a TransformationResponse object, including the workflow_id +# END StartTransformationOperations + +# START MonitorJobStatus +print(agent.get_status(workflow_id=response.workflow_id)) # Use the workflow_id to check the status of each operation +# END MonitorJobStatus + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_append_example_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_append_example_dark.png new file mode 100644 index 000000000..3e7efe5cb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_append_example_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_append_example_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_append_example_light.png new file mode 100644 index 000000000..aa42eb13a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_append_example_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_append_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_append_dark.png new file mode 100644 index 000000000..23c5e01ac Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_append_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_append_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_append_light.png new file mode 100644 index 000000000..86d629c6e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_append_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_update_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_update_dark.png new file mode 100644 index 000000000..15c9b289a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_update_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_update_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_update_light.png new file mode 100644 index 000000000..eba918ef9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_existing_update_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_overview_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_overview_dark.png new file mode 100644 index 000000000..491ab8d74 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_overview_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_overview_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_overview_light.png new file mode 100644 index 000000000..e28a2c3b9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_overview_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_arxiv_dataset.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_arxiv_dataset.png new file mode 100644 index 000000000..b4da0eaf3 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_arxiv_dataset.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_arxiv_flowchart.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_arxiv_flowchart.png new file mode 100644 index 000000000..75d264522 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_arxiv_flowchart.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_enrich_dataset.py b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_enrich_dataset.py new file mode 100644 index 000000000..50c43a5ed --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_enrich_dataset.py @@ -0,0 +1,139 @@ +# START ConnectToWeaviate +import os +import time +import weaviate +from weaviate.auth import Auth + +# Best practice: store your credentials in environment variables +weaviate_url = os.environ["WEAVIATE_URL"] +weaviate_api_key = os.environ["WEAVIATE_API_KEY"] + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=Auth.api_key(weaviate_api_key), +) + +print(client.is_ready()) # Should print: `True` + +# Your work goes here! + +client.close() # Free up resources +# END ConnectToWeaviate + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, + auth_credentials=Auth.api_key(weaviate_api_key), +) + +client.collections.delete("ArxivPapers") + +# START DefineCollections +from weaviate.classes.config import Configure + +client.collections.create( + "ArxivPapers", + description="A dataset that lists research paper titles and abstracts", + vector_config=Configure.Vectors.text2vec_weaviate(), +) +# END DefineCollections + +# START PopulateDatabase +from datasets import load_dataset + +dataset = load_dataset( + "weaviate/agents", "transformation-agent-papers", split="train", streaming=True +) + +papers_collection = client.collections.use("ArxivPapers") + +with papers_collection.batch.fixed_size(batch_size=200) as batch: + for item in dataset: + batch.add_object(properties=item["properties"]) + +failed_objects = papers_collection.batch.failed_objects +if failed_objects: + print(f"Number of failed imports: {len(failed_objects)}") + print(f"First failed object: {failed_objects[0]}") + +print(f"Size of the ArxivPapers dataset: {len(papers_collection)}") +# END PopulateDatabase + +# START AddListOfTopics +from weaviate.agents.classes import Operations +from weaviate.collections.classes.config import DataType + +add_topics = Operations.append_property( + property_name="topics", + data_type=DataType.TEXT_ARRAY, + view_properties=["abstract"], + instruction="""Create a list of topic tags based on the abstract. + Topics should be distinct from each other. Provide a maximum of 5 topics. + Group similar topics under one topic tag.""", +) +# END AddListOfTopics + +# START AddFrenchAbstract +add_french_abstract = Operations.append_property( + property_name="french_abstract", + data_type=DataType.TEXT, + view_properties=["abstract"], + instruction="Translate the abstract to French.", +) +# END AddFrenchAbstract + +# START AddNlpRelevance +add_nlp_relevance = Operations.append_property( + property_name="nlp_relevance", + data_type=DataType.INT, + view_properties=["abstract"], + instruction="""Give a score from 0-10 based on how relevant the abstract is to Natural Language Processing. + The scale is from 0 (not relevant at all) to 10 (very relevant).""", +) +# END AddNlpRelevance + +# START IsSurveyPaper +add_is_survey_paper = Operations.append_property( + property_name="is_survey_paper", + data_type=DataType.BOOL, + view_properties=["abstract"], + instruction="""Determine if the paper is a "survey". + A paper is considered a survey if it surveys existing techniques and not if it presents novel techniques.""", +) +# END IsSurveyPaper + +# START UpdateProperty +update_title = Operations.update_property( + property_name="title", + view_properties=["abstract"], + instruction="""Insert the label MACHINE_LEARNING before the original title if the abstract mentions machine learning techniques.""", +) +# END UpdateProperty + +# START CreateTransformationAgent +from weaviate.agents.transformation import TransformationAgent + +agent = TransformationAgent( + client=client, + collection="ArxivPapers", + operations=[ + add_topics, + add_french_abstract, + add_nlp_relevance, + add_is_survey_paper, + update_title, + ], +) +# END CreateTransformationAgent + +# START ExecutingTransformations +response = agent.update_all() +print(response) +# END ExecutingTransformations + +time.sleep(5) + +# START GetStatus +print(agent.get_status(workflow_id=response.workflow_id)) +# END GetStatus + +client.close() # Free up resources diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_explorer_tool.png b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_explorer_tool.png new file mode 100644 index 000000000..4f5c1ef26 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/agents/_includes/transformation_agent_tutorial_explorer_tool.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/index.md new file mode 100644 index 000000000..fe58864fa --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/index.md @@ -0,0 +1,77 @@ +--- +title: 概要 +sidebar_position: 10 +description: "パーソナライゼーション、クエリ、データ変換用エージェント向け Weaviate AI エージェント ドキュメントの概要。" +image: og/docs/agents.jpg +# tags: ['agents', 'getting started'] +--- + +# Weaviate エージェント - 概要 + +Weaviate エージェントは、特定のタスク向けに設計された事前構築済みのエージェント型サービスです。Weaviate Cloud ユーザーはすぐに利用でき、Weaviate Cloud 内のデータと対話してデータエンジニアリングおよび AI 開発のワークフローを簡素化できます。 + +:::info Changelog and feedback +Weaviate エージェントの公式変更履歴は [こちら](https://weaviateagents.featurebase.app/changelog) でご覧いただけます。機能リクエスト、バグ報告、質問などのフィードバックは [こちら](https://weaviateagents.featurebase.app/) からご提出ください。フィードバックの状況を確認したり、他のフィードバックに投票したりできます。 +::: + +## Weaviate エージェントの仕組み + +Weaviate エージェントは Weaviate の API に関して事前学習されており、Weaviate 固有のデータタスクを実行するエキスパートです。 + +必要なのは入力を提供するだけで、対象のエージェントがデータを用いて必要なタスクを実行します。 + +:::info Weaviate Agents is not an agent framework +Weaviate エージェントはエージェントを構築するためのフレームワークではありません。Weaviate 用に事前構築されたエージェント型サービスのセットです。 +::: + +## クエリ エージェント + +[クエリ エージェント](./query/index.md) は、自然言語の質問に対して保存されたデータをクエリし、回答を提供します。 + +[![クエリ エージェントの詳細を読むにはクリック](./_includes/query_agent_usage_light.png#gh-light-mode-only "クエリ エージェントの詳細を読むにはクリック")](./query/index.md) +[![クエリ エージェントの詳細を読むにはクリック](./_includes/query_agent_usage_dark.png#gh-dark-mode-only "クエリ エージェントの詳細を読むにはクリック")](./query/index.md) + +[クエリ エージェントの詳細を読む](./query/index.md) + +## 変換 エージェント + +:::caution Technical Preview + +![Weaviate エージェントはテクニカルプレビューです。](./_includes/agents_tech_preview_light.png#gh-light-mode-only "Weaviate エージェントはテクニカルプレビューです。") +![Weaviate エージェントはテクニカルプレビューです。](./_includes/agents_tech_preview_dark.png#gh-dark-mode-only "Weaviate エージェントはテクニカルプレビューです。") + +[こちらから登録](https://events.weaviate.io/weaviate-agents) して Weaviate エージェントの通知を受け取るか、[このページ](https://weaviateagents.featurebase.app/) で最新情報の確認やフィードバックの提供ができます。 + +::: + +[変換 エージェント](./transformation/index.md) は、instructions に基づいてデータを操作し、データを強化します。 + +[![変換 エージェントの詳細を読むにはクリック](./_includes/transformation_agent_overview_light.png#gh-light-mode-only "変換 エージェントの詳細を読むにはクリック")](./transformation/index.md) +[![変換 エージェントの詳細を読むにはクリック](./_includes/transformation_agent_overview_dark.png#gh-dark-mode-only "変換 エージェントの詳細を読むにはクリック")](./transformation/index.md) + +[変換 エージェントの詳細を読む](./transformation/index.md) + +## パーソナライゼーション エージェント + +:::caution Technical Preview + +![Weaviate エージェントはテクニカルプレビューです。](./_includes/agents_tech_preview_light.png#gh-light-mode-only "Weaviate エージェントはテクニカルプレビューです。") +![Weaviate エージェントはテクニカルプレビューです。](./_includes/agents_tech_preview_dark.png#gh-dark-mode-only "Weaviate エージェントはテクニカルプレビューです。") + +[こちらから登録](https://events.weaviate.io/weaviate-agents) して Weaviate エージェントの通知を受け取るか、[このページ](https://weaviateagents.featurebase.app/) で最新情報の確認やフィードバックの提供ができます。 + +::: + +[パーソナライゼーション エージェント](./personalization/index.md) は、特定のペルソナ情報に基づいて出力をカスタマイズし、時間とともに学習することも可能です。 + +[![パーソナライゼーション エージェントの詳細を読むにはクリック](./_includes/personalization_agent_overview_light.png#gh-light-mode-only "パーソナライゼーション エージェントの詳細を読むにはクリック")](./personalization/index.md) +[![パーソナライゼーション エージェントの詳細を読むにはクリック](./_includes/personalization_agent_overview_dark.png#gh-dark-mode-only "パーソナライゼーション エージェントの詳細を読むにはクリック")](./personalization/index.md) + +[パーソナライゼーション エージェントの詳細を読む](./personalization/index.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/index.md new file mode 100644 index 000000000..09da355fb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/index.md @@ -0,0 +1,189 @@ +--- +title: パーソナライゼーション エージェント +sidebar_position: 10 +description: ユーザープロファイルとインタラクション履歴に基づき、パーソナライズされたレコメンデーションを提供する AI エージェントの概要。 +image: og/docs/agents.jpg +# tags: ['agents', 'getting started', 'personalization agent'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/docs/agents/_includes/personalization_agent.py'; + +# Weaviate パーソナライゼーション エージェント + +:::caution Technical Preview + +![この Weaviate エージェントはテクニカルプレビューです。](../_includes/agents_tech_preview_light.png#gh-light-mode-only "この Weaviate エージェントはテクニカルプレビューです。") +![この Weaviate エージェントはテクニカルプレビューです。](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only "この Weaviate エージェントはテクニカルプレビューです。") + +[こちらから登録してください](https://events.weaviate.io/weaviate-agents) Weaviate エージェントの通知を受け取るには、または[このページ](https://weaviateagents.featurebase.app/)で最新情報を確認し、フィードバックをお寄せください。 + +::: + +Weaviate パーソナライゼーション エージェントは、各ユーザーに合わせたレコメンデーションを返すために設計されたエージェントサービスです。パーソナライゼーション エージェントは、関連する Weaviate Cloud インスタンスのデータを利用してレコメンデーションを提供します。 + +:::tip 用語: ユーザーと開発者 +パーソナライゼーション エージェントは、特定の人に合わせたパーソナライズレコメンデーションを提供します。この文脈では、その人を `user` と呼びます。`user` に対してレコメンデーションを提供するためにパーソナライゼーション エージェントを使用する人が開発者です。 +::: + +開発者はユーザープロファイルを渡すだけで、パーソナライゼーション エージェントが途中の手順をすべて処理し、Weaviate から一連のパーソナライズレコメンデーションを返します。開発者視点でのワークフローは以下のとおりです。 + +![Weaviate Personalization Agent from a developer perspective](../_includes/personalization_agent_overview_light.png#gh-light-mode-only "Weaviate Personalization Agent from a developer perspective") +![Weaviate Personalization Agent from a developer perspective](../_includes/personalization_agent_overview_dark.png#gh-dark-mode-only "Weaviate Personalization Agent from a developer perspective") + +:::info 変更履歴とフィードバック +Weaviate エージェントの公式変更履歴は[こちら](https://weaviateagents.featurebase.app/changelog)にあります。機能要望・バグ報告・質問などのフィードバックは[こちら](https://weaviateagents.featurebase.app/)からお寄せください。フィードバックの状況を確認したり、他の提案に投票したりできます。 +::: + +## アーキテクチャ + +パーソナライゼーション エージェントは Weaviate Cloud 上のサービスとして提供されます。 + +ユーザー固有のレコメンデーション要求が行われると、パーソナライゼーション エージェントはユーザープロファイルおよび既知のコンテキストを解析し、自律的に検索を実行します。コンテキストには、以前のユーザーインタラクション、ユーザー自身に関する情報、その他関連情報が含まれます。 + +パーソナライゼーション エージェントはコンテキスト情報を活用して、最も関連性の高いレコメンデーションを取得するだけでなく、ユーザー向けにランキングも行います。 + +## パーソナライゼーション エージェント: ワークフローの可視化 + +![Weaviate Personalization Agent at a high level](../_includes/personalization_agent_architecture_light.png#gh-light-mode-only "Weaviate Personalization Agent at a high level") +![Weaviate Personalization Agent at a high level](../_includes/personalization_agent_architecture_dark.png#gh-dark-mode-only "Weaviate Personalization Agent at a high level") + +パーソナライゼーション エージェントは、高レベルでは以下のように動作します。 + +- Weaviate が管理するユーザーコレクションを作成し、各ユーザーのプロファイルと過去のインタラクションを保存します。 +- パーソナライゼーション レコメンデーションが要求されると、エージェントはユーザーデータを取得し、パターンや好みを解析します。 +- 解析結果に基づき、Weaviate で初期検索を実行して最も関連性の高いレコメンデーションを取得します。 +- 適切な生成モデルを使用して追加の検索戦略を決定し、必要に応じて取得データを再ランキングします。 +- 最終的なレコメンデーションを取得するために、必要に応じて Weaviate で追加検索を行います。 +- レコメンデーションをユーザープロファイルと好みに基づいて統合・ランキングします。 + +その後、パーソナライゼーション エージェントはユーザー固有のレコメンデーションをレスポンスとして返します。レスポンスには、Weaviate から得た基礎的な検索結果など、中間生成物も含まれます。 + +パーソナライゼーション エージェントについて、もう少し詳しく見ていきましょう。 + +### ユーザープロファイル + +パーソナライゼーション エージェントはユーザープロファイルを利用してパーソナライズレコメンデーションを提供します。この情報は特定の名前で、あなたの Weaviate インスタンス内のコレクションに保存されます。ユーザープロファイルには、ユーザーの好みや過去のインタラクション(例: 好き・嫌いなど)が含まれる場合があります。 + +![Weaviate Personalization Agent - User Data Collection](../_includes/personalization_agent_users_light.png#gh-light-mode-only "Weaviate Personalization Agent - User Data Collection") +![Weaviate Personalization Agent - User Data Collection](../_includes/personalization_agent_users_dark.png#gh-dark-mode-only "Weaviate Personalization Agent - User Data Collection") + +ここに示すように、ユーザーデータコレクションは時間とともに更新できます。新しいユーザーの情報を追加したり、既存ユーザーの新しい情報で更新したりできます。 + +これにより、パーソナライゼーション エージェントは学習を続け、各ユーザーに対して最も関連性が高く最新のレコメンデーションを提供し続けることができます。 + +### レコメンデーション + +パーソナライゼーション エージェントのレコメンデーションには大きく2つの要素があります。検索によるレコメンデーション取得と、レコメンデーションのランキングです。 + +#### 検索 + +パーソナライゼーション エージェントは Weaviate で検索を実行し、指定されたコレクションからユーザーに最も関連性の高いレコメンデーションを取得します。 + +![Weaviate Personalization Agent - Searches](../_includes/personalization_agent_search_light.png#gh-light-mode-only "Weaviate Personalization Agent - Searches") +![Weaviate Personalization Agent - Searches](../_includes/personalization_agent_search_dark.png#gh-dark-mode-only "Weaviate Personalization Agent - Searches") + +図が示すとおり、検索プロセスは複数の要素に基づく可能性があります。 + +- ユーザープロファイルと好み(ユーザーデータコレクションから取得) +- ユーザーの過去インタラクション(ユーザーデータコレクションから取得) +- レコメンデーションのコンテキスト(要求されたレコメンデーションの種類など) +- パーソナライゼーション エージェントが決定した追加検索戦略 + +パーソナライゼーション エージェントは、関連性の高いレコメンデーションを取得するために Weaviate で複数回の検索を行い、それらを統合・ランキングします。 + +#### (再)ランキング + +パーソナライゼーション エージェントは Weaviate から取得したレコメンデーションを、複数の要素を用いてランキングし、最終的な結果セットをユーザーの好みに合わせます。 + +![Weaviate Personalization Agent - (re)rank](../_includes/personalization_agent_rank_light.png#gh-light-mode-only "Weaviate Personalization Agent - (re)rank") +![Weaviate Personalization Agent - (re)rank](../_includes/personalization_agent_rank_dark.png#gh-dark-mode-only "Weaviate Personalization Agent - (re)rank") + +ランキングは以下の要素に基づく場合があります。 + +- ユーザープロファイルと好み(ユーザーデータコレクションから取得) +- ユーザーの過去インタラクション(ユーザーデータコレクションから取得) +- レコメンデーションのコンテキスト(要求されたレコメンデーションの種類など) +- パーソナライゼーション エージェントが決定した追加ランキング戦略 + +このプロセスにより統合された結果セット全体がランキングされ、レスポンスとして返されます。 + +## 基本的な使い方 + +ここでは、本 Weaviate エージェントの利用方法を概観します。詳細は[使用方法](./usage.md)ページをご覧ください。 + +### 前提条件 + +このエージェントは Weaviate Cloud インスタンスと、対応するバージョンの Weaviate クライアントライブラリでのみ利用可能です。 +### 利用例 + +Personalization エージェントを使用するには、次の入力でインスタンス化します: + +- Weaviate クライアントのインスタンス(例: Python の `WeaviateClient` オブジェクト)で、Weaviate Cloud インスタンスへ接続済みのもの。 +- パーソナライズされたアイテムを取得する対象コレクションの名前。 +- パーソナライズの基準となるユーザー属性のリスト。 + +Personalization エージェントは永続化される点にご注意ください。すでに Personalization エージェントを作成済みの場合、新規作成せずに再接続できます。 + + + + + + + +次に、推奨結果をパーソナイズするためのペルソナを追加します。 + + + + + + + +そのペルソナに対して一連のインタラクションを追加できます。 + + + + + + + +ユーザーデータを追加すると、Personalization エージェントを使用して Weaviate コレクションからパーソナライズされた推奨を取得できます。 + + + + + + + + +### 追加ドキュメント + +このエージェントの詳細な使用方法については、[使用方法](./usage.md) ページを参照してください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/tutorial-recipe-recommender.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/tutorial-recipe-recommender.mdx new file mode 100644 index 000000000..f36b28e59 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/tutorial-recipe-recommender.mdx @@ -0,0 +1,369 @@ +--- +title: Personalization Agent で作るレシピレコメンダー +sidebar_label: 'Tutorial: Recipe recommender' +description: "Personalization Agent を使用してレシピ推薦システムを作成するチュートリアル。" +sidebar_position: 40 +image: og/docs/tutorials.jpg +# tags: ['personalization', 'recommendation'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/docs/agents/_includes/personalization_agent_tutorial_food_recommender.py'; + +:::caution Technical Preview + +![This Weaviate Agent is in technical preview.](../_includes/agents_tech_preview_light.png#gh-light-mode-only 'This Weaviate Agent is in technical preview.') +![This Weaviate Agent is in technical preview.](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only 'This Weaviate Agent is in technical preview.') + +[こちらから登録](https://events.weaviate.io/weaviate-agents)して Weaviate Agents の最新情報を受け取るか、[このページ](https://weaviateagents.featurebase.app/)で最新のアップデートとフィードバックを確認してください。 + +::: + +:::info Data Storage Note +Weaviate Personalization Agent は、ユーザーパ ーソナプロファイルとインタラクションデータをメインのデータコレクションと同じくお客様の Weaviate インスタンス内に保存します。エージェントを実装する際は、データプライバシー規制にご注意ください。 +::: + +このチュートリアルでは、**[Weaviate Personalization Agent](./index.md)** を使用してシンプルなフードレコメンダーサービスを構築します。このエージェントは、ユーザーが定義したプロフィール(パーソナ)と過去のインタラクション(例: レシピのレビュー)を学習し、レシピコレクションからパーソナライズされた推薦を行います。 + +Personalization Agent を試すための公開データセットを用意しています。 +HuggingFace で入手可能です: + +- [**レシピ:**](https://huggingface.co/datasets/weaviate/agents/viewer/personalization-agent-recipes) レシピ名、短い説明、料理の種類を含むデータセット。 + +## 導入: Personalization Agent とは + +Weaviate Personalization Agent は、Weaviate コレクションからユーザーごとに最適化されたオブジェクトを取得するための、あらかじめ構築されたエージェントサービスです。ユーザーが定義したパーソナ(プロフィール)と、コレクション内アイテムとのインタラクション履歴を考慮して動作します。 + +import WeaviateAgentsPersonalizationFoodFlowchart from '/docs/agents/_includes/personalization_agent_tutorial_food_recommender_flowchart.png'; + +
+
+
+ Weaviate Personalization Agent flowchart +
+
+
+
+ +Personalization Agent の処理フロー: + +1. **リクエストを受信** — 特定ユーザー(パーソナ)への推薦要求を受け取ります。 +2. **ユーザーのパーソナプロファイル**(例: 好み、苦手、好きな料理)と **インタラクション履歴**(例: 好き/嫌いなレシピと重み付け)を取得します。 +3. **参照コレクションを検索**(例: 「Recipes」)し、候補アイテムを取得します。 +4. **(オプション)生成モデルを使用** — 大規模言語モデルなど適切な生成モデルで、パーソナ・インタラクション・指示に基づき候補を再ランク付けし、その理由を生成します。 +5. **パーソナライズされた順位付きリスト** をユーザーへ返します。 + +
+ +## 前提条件 + +Weaviate Agents と Weaviate Embedding サービスを使用するには、**[Weaviate Cloud](https://console.weaviate.cloud)** アカウントが必要です。 + +## ステップ 1: Weaviate のセットアップ + +ここから、チュートリアルで使用する Weaviate Cloud インスタンスを作成し、Python クライアントから接続します。 + +### 1.1 Weaviate Cloud クラスターの作成 + +1. Weaviate Cloud で[無料の Sandbox クラスター](/cloud/manage-clusters/create#sandbox-clusters)を作成します。 +1. クラスターに接続するための `REST Endpoint` と `Admin` API キーを控えておきます。(詳しくは [クイックスタート](/cloud/manage-clusters/connect.mdx) を参照) + +:::tip +このチュートリアルでは、ベクトライザーとして [Weaviate Embeddings](../../weaviate/model-providers/weaviate/index.md) サービスを使用するため、外部の埋め込みプロバイダー用の追加キーは不要です。Weaviate Embeddings では既定で `Snowflake/snowflake-arctic-embed-l-v2.0` モデルが使用されます。

+別のベクトライザーを使用したい場合は、サポートされている [モデルプロバイダー](../../weaviate/model-providers/index.md) の一覧をご覧ください。 +::: + +### 1.2 Python ライブラリのインストール + +Weaviate Python クライアントと `agents` コンポーネントをインストールするには、次のコマンドを実行します。 + + + + +``` +pip install "weaviate-client[agents]" +``` + + + + +HuggingFace 上の公開データセットにアクセスできる軽量ライブラリ `datasets` も必要です。 + + + + +``` +pip install datasets +``` + + + + +import ForcePipInstall from '../_includes/_force_pip_install.mdx'; + + + +### 1.3 インスタンスへの接続 + +先ほど取得したパラメータを使って、Weaviate Cloud インスタンスへ接続します。 + + + + + + + +このスニペットを実行し、`True` と表示されればインスタンスへの接続に成功しています。 +## 手順 2: コレクションの準備 + +以下のコードブロックでは、デモ用レシピ データセットを Hugging Face から取得し、 Weaviate Sandbox クラスター内の新しいコレクションに書き込みます。データをインポートする前に、コレクションを **定義** し、スキーマを設定してベクトライザーを選択する必要があります。 + +### 2.1 コレクションの定義 + +以下は、`Recipes` データセット内のオブジェクトの構造です。 + +import WeaviateAgentsPersonalizationFoodDataset from '/docs/agents/_includes/personalization_agent_tutorial_food_recommender_dataset.png'; + +
+
+
+ Recipes データセットの構造 +
+
+
+
+ +`Recipes` コレクションでは、プロパティを手動で定義し、説明を追加します。[`auto-schema`](../../weaviate/config-refs/collections.mdx#auto-schema) を利用することもできますが、明示的な説明を付けることで Personalization エージェント (特に再ランキングに使用される基盤 LLM) がデータの文脈をよりよく理解できます。 + + + + + + + +### 2.2 データベースの投入 + +次に、レシピ データ ([Recipes](https://huggingface.co/datasets/weaviate/agents/viewer/personalization-agent-recipes)) を Weaviate Cloud インスタンスにインポートします。 + + + + + + + +`len()` をコレクションに対して呼び出すことで、インポートが正常に完了したかを確認し、コレクションのサイズを確認できます。 + + + + + + + +``` +Size of the Recipes dataset: 5117 +``` + +## 手順 3: パーソナライゼーション エージェントのセットアップ + +それでは、`PersonalizationAgent` インスタンスを作成し、"Recipes" コレクションに紐付けます。 + +新しく `PersonalizationAgent` を作成する際には、まず `user_properties` を定義します。これは、各ユーザーのペルソナ プロフィールを構成するフィールドです。今回のフード レコメンダーでは、好みの料理、一般的な好き嫌いなどのプロパティが該当します。 + +このコレクション用のエージェントが既に存在する場合 (例: 以前の実行で作成済み)、`PersonalizationAgent.connect()` を使用して接続するだけで構いません。以下のコードは両方のケースに対応しています。 + + + + + + + +新しいエージェントが作成されたか、既存のエージェントに接続されたかを示すメッセージが表示されます。 + +## 手順 4: パーソナライゼーション エージェントの使用 + +エージェントの準備ができたので、ユーザー データを追加し、レコメンデーションを取得できます。 + +### 4.1 新しいペルソナの追加 + +「ペルソナ」はユーザー プロフィールを表します。`agent.add_persona()` メソッドを使用し、一意の `persona_id` (UUID を推奨) と、エージェント作成時に定義した `properties` を渡します。 + +以下の例はご自身の食の好みに合わせて自由に変更してください\! + + + + + + + +### 4.2 インタラクションの追加 + +「インタラクション」は、ユーザーがコレクション内のアイテムとどのように関わったかを表します。今回のレコメンダーでは、明示的なレビューや評価、レシピ ページを閲覧したといった暗黙的なシグナルなどが該当します。 + +`PersonaInteraction` では、`persona_id` と `item_id` (「Recipes」コレクション内オブジェクトの UUID) を関連付け、さらに -1.0 (強い嫌い) から 1.0 (強い好み) の範囲で `weight` を指定します。 + +import WeaviateAgentsPersonalizationFoodUser from '/docs/agents/_includes/personalization_agent_tutorial_food_recommender_user.png'; + +
+
+
+ Weaviate Personalization Agent User +
+
+
+
+ +まず、ユーザーがインタラクトした特定のレシピの UUID を取得します。次に、適切な `weight` を設定してインタラクションを定義します。最後に、`agent.add_interactions()` を使用してエージェントに追加します。 + + + + + + + +このブロックはインタラクション データを準備し、エージェントに送信します。 +### 4.3 レコメンデーションの取得 + +ここからは核心機能です。`agent.get_objects()` を使用してパーソナライズされたレコメンデーションを取得します。取得したい対象の `persona_id` を指定します。 + +`use_agent_ranking=True` を設定すると、LLM ベースのリランキングが有効になります。これにより、ペルソナのプロファイルとインタラクション履歴を活用して、よりきめ細かなランキングを提供し、さらにアイテムが推奨された _なぜ_ を説明する `ranking_rationale` も生成されます。 + + + + + + + +出力にはまず、エージェントの LLM が生成した `ranking_rationale` が表示され、その後にタイトル、説明、料理のラベルを含む推奨レシピの一覧が続きます。 + +
+ 例のレスポンス (persona / interactions と LLM によって変わります): + +``` +Getting recommendations for persona e7239e3f-97f5-41b3-939a-5fbf3e0c7f16... + +Ranking Rationale: +Because you love Italian dishes and have shown an interest in different cuisines, we've prioritized dishes with Italian, Japanese, and Indian labels, reflecting your preferences for Italian and Thai cuisines and prior positive interactions. We avoided items with mushroom content. + +Recommended Recipes: +----- Recommendation 1 ----- +Title: Chicken Tikka Masala +Cuisine: Indian +UUID: 5785f023-5ab2-49d8-bb43-0ab047083e16 +----- Recommendation 2 ----- +Title: Spicy Indian Tikka Masala +Cuisine: Indian +UUID: 753a036f-ec83-4efa-8a1a-5afa021acbc2 +----- Recommendation 3 ----- +Title: Paneer Tikka +Cuisine: Indian +UUID: 323b6f11-c026-4367-801b-b21f40e6591b +----- Recommendation 4 ----- +Title: Paneer Butter Masala +Cuisine: Indian +UUID: 3bd11bc9-d329-4039-9f4a-205f1719048d +----- Recommendation 5 ----- +Title: Butter Chicken +Cuisine: Indian +UUID: 4e056c59-e843-419a-8129-b6633fb8c2d3 +----- Recommendation 6 ----- +Title: Shabu-Shabu +Cuisine: Japanese +UUID: df0ae465-f724-42ed-9876-2c9b91516c13 +----- Recommendation 7 ----- +Title: Oden +Cuisine: Japanese +UUID: eb6088c1-05a6-46ed-9adc-477313c051d2 +----- Recommendation 8 ----- +Title: Tempura +Cuisine: Japanese +UUID: 625a5164-e150-4966-a3c6-0aed406db416 +----- Recommendation 9 ----- +Title: Ramen +Cuisine: Japanese +UUID: 708824b3-fc4a-4927-82bb-a8a4dbd5ee89 +----- Recommendation 10 ----- +Title: Udon Noodles +Cuisine: Japanese +UUID: 8d6a94b7-c9ae-4d1c-b29a-885717b9a55a +``` + +
+ +## 概要 + +本ガイドでは、 Weaviate の Personalization Agent を使用して、パーソナライズされたフードレコメンデーションサービスを構築する方法を示しました。以下を取り上げました: + +- Python クライアントを使用して Weaviate Cloud インスタンスをセットアップする方法。 +- 説明的プロパティを持つ「Recipes」コレクションを定義すること。 +- コレクションにデータをインポートすること。 +- コレクションにリンクした Personalization Agent を作成し、ユーザー プロファイルのプロパティ (`user_properties`) を定義すること。 +- 特定の好みを持つユーザー プロファイル (`personas`) を追加すること。 +- 重み付きスコアを使用してアイテムとのユーザー インタラクションを記録すること。 +- `get_objects` を使用してパーソナライズされたレコメンデーションを取得し、LLM ベースのリランキング (`use_agent_ranking=True`) を利用してカスタマイズされた結果と説明 (`ranking_rationale`) を得ること。 + +Personalization Agent を使用すると、 Weaviate 上で構築したアプリケーションに高度でパーソナライズされた取得機能を簡単に追加できます。 + +## 追加リソース + +- [Weaviate Agents - Personalization Agent](./index.md) + +## 質問とフィードバック + +:::info Changelog and feedback +Weaviate Agents の公式変更履歴は [こちら](https://weaviateagents.featurebase.app/changelog) でご覧いただけます。機能リクエスト、バグ報告、質問などのフィードバックがありましたら、[こちら](https://weaviateagents.featurebase.app/) からお送りください。フィードバックの状況を確認したり、他のフィードバックに投票したりできます。 +::: + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/usage.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/usage.md new file mode 100644 index 000000000..17ee6c9bf --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/personalization/usage.md @@ -0,0 +1,394 @@ +--- +title: 利用方法 +sidebar_position: 30 +description: " Personalization Agent を実装するための技術ドキュメントと使用例。" +image: og/docs/agents.jpg +# tags: ['agents', 'getting started', 'personalization agent'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/docs/agents/_includes/personalization_agent.py'; + +# Weaviate Personalization Agent:利用方法 + +:::caution Technical Preview + +![この Weaviate Agent はテクニカルプレビュー版です。](../_includes/agents_tech_preview_light.png#gh-light-mode-only "この Weaviate Agent はテクニカルプレビュー版です。") +![この Weaviate Agent はテクニカルプレビュー版です。](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only "この Weaviate Agent はテクニカルプレビュー版です。") + +[こちらから登録してください](https://events.weaviate.io/weaviate-agents) して Weaviate Agents の通知を受け取るか、[このページ](https://weaviateagents.featurebase.app/) で最新情報の確認とフィードバックを行ってください。 + +::: + +Weaviate Personalization Agent は、各ユーザーに合わせたパーソナライズドレコメンドを返すための エージェント型サービスです。 Personalization Agent は関連する Weaviate Cloud インスタンスのデータを使用してレコメンドを提供します。 + +:::tip 用語:ユーザーと開発者 +Personalization Agent は特定の人物に合わせたパーソナライズドレコメンドを提供することが目的です。ここではその人物を `user` と呼びます。`developer` は、これらのレコメンドを提供するために Personalization Agent を利用する人です。 +::: + +開発者はユーザープロファイルを渡すだけで、 Personalization Agent が途中のすべての処理を行い、 Weaviate からのパーソナライズドレコメンドを返します。開発者視点のワークフローは次のようになります。 + +![Weaviate Personalization Agent from a developer perspective](../_includes/personalization_agent_overview_light.png#gh-light-mode-only "Weaviate Personalization Agent from a developer perspective") +![Weaviate Personalization Agent from a developer perspective](../_includes/personalization_agent_overview_dark.png#gh-dark-mode-only "Weaviate Personalization Agent from a developer perspective") + +このページでは、 Weaviate に保存されたデータからパーソナライズドレコメンドを取得するための Weaviate Personalization Agent の使い方を説明します。 + +:::info Changelog and feedback +Weaviate Agents の公式変更履歴は [こちらで確認できます](https://weaviateagents.featurebase.app/changelog)。機能要望、バグ報告、質問などのフィードバックは [こちら](https://weaviateagents.featurebase.app/) から送信してください。フィードバックの状況を確認したり、他のフィードバックに投票したりできます。 +::: + +## 前提条件 + +### Weaviate インスタンス + +この Agent は Weaviate Cloud インスタンスでのみ利用可能です。 + +Weaviate Cloud インスタンスのセットアップ方法については [Weaviate Cloud のドキュメント](/cloud/index.mdx) を参照してください。 + +[Weaviate Cloud](https://console.weaviate.cloud/) で無料の Sandbox インスタンスを使って、この Weaviate Agent をお試しいただけます。 + +### クライアントライブラリ + +:::note 対応言語 +現時点では、この Agent は Python のみ対応しています。他の言語は今後追加予定です。 +::: + +Weaviate Agents を利用するには、オプション `agents` 付きで Weaviate クライアントライブラリをインストールします。これにより `weaviate-client` パッケージと合わせて `weaviate-agents` パッケージがインストールされます。 + +次のコマンドでクライアントライブラリをインストールしてください。 + + + + +```shell +pip install -U weaviate-client[agents] +``` + +#### トラブルシューティング:`pip` で最新バージョンを強制インストールする + +既にインストール済みの場合でも、`pip install -U "weaviate-client[agents]"` だけでは `weaviate-agents` が [最新バージョン](https://pypi.org/project/weaviate-agents/) に更新されないことがあります。その場合は `weaviate-agents` パッケージを明示的にアップグレードしてください。 + +```shell +pip install -U weaviate-agents +``` + +または [特定のバージョン](https://github.com/weaviate/weaviate-agents-python-client/tags) をインストールします。 + +```shell +pip install -U weaviate-agents==||site.weaviate_agents_version|| +``` + + + + + +## 使い方 + +Personalization Agent を使用するには、次のハイレベルな手順に従います。 + +- パーソナライズエージェントを作成または接続する +- ユーザーペルソナを作成または選択する +- そのペルソナに対するインタラクションを追加する +- パーソナライズドレコメンドを取得する + +オプションで、 Personalization Agent は以下を行えます。 +- 結果のリランキング +- さらにリランキング用のカスタム instructions を指定 + +以下に使用例を示します。 + +### 前提条件 + +Personalization Agent は Weaviate Cloud と密接に統合されています。そのため、 Personalization Agent は Weaviate Cloud インスタンスと対応クライアントライブラリでのみ利用可能です。 + +### Weaviate への接続 + +Personalization Agent を使用するには、 Weaviate Cloud インスタンスへ接続する必要があります。 Weaviate クライアントライブラリを使用して接続します。 + + + + + + + +### パーソナライズエージェントの作成または接続 + +Personalization Agent はステートフルで、ユーザーペルソナのデータが Weaviate に保持されます。そのため、新しい Personalization Agent を作成することも、既存の Agent に接続することもできます。 + + + + + + +### ユーザー パーソナの作成 + +Personalization Agent は、特定ユーザー向けにパーソナライズされたレコメンデーションを提供するよう設計されています。 + +これを実現するには、ユーザーの属性とインタラクションをまとめた `Persona` を作成します。 + +各パーソナには、ユーザー ID、ユーザー プロパティの集合、およびインタラクションの集合が含まれます。 + +パーソナを作成するには、ユーザー ID と、パーソナライズに使用するユーザー プロパティを指定します。 + + + + + + + + +### ユーザー パーソナの管理 + +既存のユーザー パーソナを削除・更新したり、存在を確認できます。 + +#### ユーザー パーソナの削除 + +ユーザー パーソナを削除するには、削除対象のユーザー ID を指定します。 + + + + + + +#### ユーザー パーソナの更新 + +ユーザー パーソナを更新するには、更新対象のユーザー ID と新しいユーザー プロパティのセットを指定します。 + + + + + + + +#### ユーザー パーソナの存在確認 + +ユーザー パーソナが存在するか確認するには、確認したいユーザー ID を指定します。 + + + + + + + +#### ユーザー パーソナの取得 + +ユーザー パーソナを取得するには、取得したいユーザー ID を指定します。 + + + + + + + +### インタラクションの追加 + +インタラクションはパーソナライズ処理の基礎データです。Personalization Agent はこれらのデータを用いてユーザーを学習し、パーソナライズされたレコメンデーションを提供します。 + +インタラクションを追加するには、ユーザー パーソナを選択し、インタラクションの詳細を指定します。 + +利用可能なパラメーターは次のとおりです。 + +- `persona_id`: ユーザー パーソナの ID +- `item_id`: インタラクション対象アイテムの ID +- `weight`: インタラクションの重み (例: 最も好む場合は 1、最も嫌う場合は -1) +- `replace_previous_interaction`: 同じ `item_id` の既存インタラクションを置き換えるかどうか +- `created_at`: インタラクションのタイムスタンプ (重みに影響) + + + + + + + + +### パーソナライズ済みオブジェクトの取得 + +ユーザー パーソナを作成したら、パーソナライズ済みオブジェクトを取得できます。 + +最低限、ユーザー ID を Personalization Agent に渡すだけで、Agent がユーザー ID を処理し、Weaviate で必要な検索を実行し、パーソナライズされたレコメンデーションを返します。 + + + + + + +#### オブジェクト取得:利用可能なランキング戦略 + +`get_objects` を使用する際、ランキング戦略を選択できます。 + +Personalization Agent は、 ベクトル検索 と LLM ベースのランキングを組み合わせて、パーソナライズされたレコメンデーションを提供できます。 ベクトル検索 はユーザー ペルソナのインタラクションセットの分析に基づいています。オプションで LLM を使用して結果を再ランキングできます。 + +次の 3 つのモードで利用できます。 + +- **エージェントベースの再ランキング**: Personalization Agent はまず ベクトル検索 を実行してアイテムを取得し、その後ユーザー ペルソナに基づいて LLM で再ランキングします。これがデフォルトモードです。 +- **カスタム instructions 付きエージェントベースの再ランキング**: カスタム instructions を指定した場合、Personalization Agent はその instructions を用いて結果を再ランキングします。これにより、特定のニーズに合わせてランキングプロセスをカスタマイズできます。 +- **ベクトル検索のみ**: エージェントランキングを使用せずに結果を取得する場合、結果は ベクトル検索 のみを基に返されます。 + +#### オブジェクト取得:パラメーター + +パーソナライズされたオブジェクト取得で利用可能なパラメーターは次のとおりです。 + +- `limit`: 返却する最大アイテム数 +- `recent_interactions_count`: パーソナライズに考慮する直近インタラクション数 +- `exclude_interacted_items`: すでにユーザーがインタラクションしたアイテムを除外するかどうか +- `decay_rate`: 古いインタラクションに対する減衰率 (1.0 = 古いインタラクションを大きく割引、0.0 = 割引なし) +- `exclude_items`: レコメンデーションから除外するアイテム ID のリスト +- `use_agent_ranking`: エージェントで再ランキングを行うかどうか +- `instruction`: 再ランキング用のカスタム instructions +- `explain_results`: 結果に説明を含めるかどうか + + + + + + + +#### オブジェクト取得:結果の確認 + +Personalization Agent のレスポンスには、パーソナライズされたレコメンデーションが含まれます。 + +オプションに応じて、レスポンスには次の情報も含まれる場合があります。 + +- レコメンデーションの根拠 +- 各オブジェクトについて + - アイテムの元の順位 + - パーソナライズ後の順位 + + + + + + + +### パーソナライズされた Weaviate クエリ + +Personalization Agent は、パーソナライズされた Weaviate クエリの実行にも利用できます。 + +[`get_objects` メソッド](#get-personalized-objects) とは異なり、パーソナライズされたクエリには追加の Weaviate クエリが含まれます。 + +Weaviate の `near_text`、`bm25`、`hybrid` クエリは、Personalization Agent と組み合わせてパーソナライズされた結果を提供できます。 + + + + + + + +Weaviate クエリの結果を Personalization Agent で再ランキングしたい場合に、パーソナライズされた Weaviate クエリを使用してください。 + +Personalization Agent はまず Weaviate クエリを実行してアイテムを取得し、その後ユーザーペルソナに基づいて LLM で再ランキングします。 + +#### パーソナライズされた Weaviate クエリ:パラメーター + +パーソナライズされた Weaviate クエリのパラメーターは、クエリメソッド (`near_text`、`bm25`、`hybrid`) の手前で指定します。 + +- `persona_id`: ユーザーペルソナの ID +- `strength`: パーソナライズの強度 (0.0 = パーソナライズなし、1.0 = 完全にパーソナライズしクエリ結果を無視) +- `overfetch_factor`: パーソナライズ前に取得するオブジェクト数 +- `recent_interactions_count`: パーソナライズに考慮する直近インタラクション数 +- `decay_rate`: 古いインタラクションに対する減衰率 (1.0 = 古いインタラクションを大きく割引、0.0 = 割引なし) + + + + + + + +## 制限事項とトラブルシューティング + +:::caution Technical Preview + +![This Weaviate Agent is in technical preview.](../_includes/agents_tech_preview_light.png#gh-light-mode-only "This Weaviate Agent is in technical preview.") +![This Weaviate Agent is in technical preview.](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only "This Weaviate Agent is in technical preview.") + +[こちらから登録](https://events.weaviate.io/weaviate-agents) して Weaviate エージェントの通知を受け取るか、[このページ](https://weaviateagents.featurebase.app/) で最新情報を確認しフィードバックをお寄せください。 + +::: + +### 使用制限 + +現在、エージェントベースの再ランキングを使用する場合、1 つの Weaviate Cloud の [組織](/cloud/platform/users-and-organizations.mdx#organizations) あたり 1 日 100 件の Personalization Agent クエリ制限があります。 + +ベクトル検索のみ(エージェントベースの再ランキングを行わない場合)のクエリ数には制限はありません。 + +この制限は Personalization Agent の将来のバージョンで変更される可能性があります。 +### 既知の問題 + +現在、 Weaviate クエリと personalization agent クエリを組み合わせた機能は named vectors ではご利用いただけません。これは既知の問題であり、近日中に解決される予定です。 + +## 質問とフィードバック + +:::info Changelog and feedback +Weaviate Agents の公式変更履歴は [こちら](https://weaviateagents.featurebase.app/changelog) からご覧いただけます。フィーチャーリクエスト、バグ報告、質問などのフィードバックがありましたら、[こちら](https://weaviateagents.featurebase.app/) からご送信ください。送信後は、ご自身のフィードバックのステータスを確認したり、他のユーザーのフィードバックに投票したりできます。 +::: + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/index.md new file mode 100644 index 000000000..9df0071b7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/index.md @@ -0,0 +1,165 @@ +--- +title: クエリ エージェント +description: 自然言語理解を用いて複数の Weaviate コレクションにわたる複雑なクエリを処理する AI エージェントの概要。 +image: og/docs/agents.jpg +# tags: ['agents', 'getting started', 'query agent'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/docs/agents/\_includes/query_agent.py'; +import TSCode from '!!raw-loader!/docs/agents/\_includes/query_agent.mts'; + +# Weaviate クエリ エージェント:概要 + +Weaviate クエリ エージェントは、Weaviate Cloud に保存されたデータを基に自然言語の問い合わせに回答するために設計された、あらかじめ構築済みのエージェント サービスです。 + +ユーザーは自然言語でプロンプトや質問を入力するだけで、`Query Agent` が回答を生成するまでのすべての工程を自動で実行します。 + +![ユーザー視点の Weaviate クエリ エージェント](../_includes/query_agent_usage_light.png#gh-light-mode-only "Weaviate Query Agent from a user perspective") +![ユーザー視点の Weaviate クエリ エージェント](../_includes/query_agent_usage_dark.png#gh-dark-mode-only "Weaviate Query Agent from a user perspective") + +## アーキテクチャ + +`Query Agent` は Weaviate Cloud 上のサービスとして提供されます。 + +ユーザーがプロンプトやクエリを送信すると、`Query Agent` はそれと既知のコンテキストを解析し、必要な検索を自律的に実行します。 + +:::tip Query Agent のコンテキスト +Query Agent は、コレクションやプロパティの説明を解析し、関連するクエリの構築方法をより深く理解します。
+ +また、コンテキストには以前の会話履歴やその他の関連情報が含まれる場合があります。 +::: + +## Query Agent:可視化されたワークフロー + +![Weaviate クエリ エージェントの全体像](../_includes/query_agent_architecture_light.png#gh-light-mode-only "Weaviate Query Agent at a high level") +![Weaviate クエリ エージェントの全体像](../_includes/query_agent_architecture_dark.png#gh-dark-mode-only "Weaviate Query Agent at a high level") + +`Query Agent` は次のような高レベルの手順で動作します。 + +- 適切な生成モデル(例: 大規模言語モデル)を使用してタスクと必要なクエリを解析し、実行すべき具体的なクエリを決定します。(ステップ 1 & 2) +- クエリを Weaviate に送信します。Weaviate は指定された ベクトライザー 連携を使用して、必要に応じてクエリをベクトル化します。(ステップ 3〜5) +- Weaviate から結果を受け取り、適切な生成モデルを使用してユーザーのプロンプト/クエリに対する最終的な回答を生成します。(ステップ 6) + +その後、`Query Agent` は回答に加えて、Weaviate から得られた検索結果などの中間成果物もユーザーに返します。 + +なお、`Query Agent` という用語はシステム全体を指します。`Query Agent` は、特定のタスクを担当する複数のマイクロサービスやエージェントなど、複数のサブシステムで構成されている場合があります。 + +![Weaviate クエリ エージェントは複数のエージェントで構成](../_includes/query_agent_info_light.png#gh-light-mode-only "Weaviate Query Agent comprises multiple agents") +![Weaviate クエリ エージェントは複数のエージェントで構成](../_includes/query_agent_info_dark.png#gh-dark-mode-only "Weaviate Query Agent comprises multiple agents") + +## クエリ実行 + +`Query Agent` は 2 種類のクエリをサポートします。 + +- **`Search`**: 自然言語を使って `Query Agent` 経由で Weaviate を検索します。`Query Agent` が質問を処理し、Weaviate で必要な検索を実行し、関連オブジェクトを返します。 +- **`Ask`**: 自然言語で `Query Agent` に質問します。`Query Agent` が質問を処理し、Weaviate で必要な検索を実行し、回答を返します。 + +## 基本的な使用方法 + +ここでは、この Weaviate エージェントの使い方を概観します。詳細は [Usage](./usage.md) ページをご覧ください。 + +:::note 前提条件 +このエージェントは、[Weaviate Cloud](/cloud/index.mdx) インスタンスと、サポートされているバージョンの Weaviate [client library](./usage.md#client-library) でのみ利用できます。 +::: + +### 使用例 + +Weaviate クライアントのインスタンスを `Query Agent` に渡すと、`Query Agent` がクライアントから必要な情報を取得してクエリを実行します。 + + + + + + + + + + +次に、自然言語のクエリを入力します。`Query Agent` がクエリを処理し、Weaviate で必要な検索を実行し、回答を返します。 + +### `Search` (検索のみ) + + + + + + + + + + +`Query Agent` は、前回の応答を追加のコンテキストとして使用し、後続の質問にも対応できます。 + + + + + + + + + + +### `Ask` (回答生成付き) + + + + + + + + + + +## 追加リソース + +この エージェント の使用方法の詳細については、[使用方法](./usage.md) ページをご覧ください。 + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/tutorial-ecommerce.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/tutorial-ecommerce.mdx new file mode 100644 index 000000000..e75e5fa1c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/tutorial-ecommerce.mdx @@ -0,0 +1,651 @@ +--- +title: Query Agent で E-Commerce アシスタントを構築する +sidebar_label: "Tutorial: E-Commerce assistant" +description: "Query Agent を使用して、商品およびブランドの質問に回答する e-commerce アシスタントを作成するチュートリアル。" +sidebar_position: 40 +image: og/docs/tutorials.jpg +# tags: ['basics'] +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/docs/agents/_includes/query_agent_tutorial_ecommerce.py"; + +このチュートリアルでは、 **[Weaviate Query Agent](./index.md)** を使ってシンプルな e-commerce アシスタント エージェントを構築します。このエージェントは複数の Weaviate コレクションにアクセスでき、各コレクションの情報を利用してブランドや衣料品に関する複雑な問い合わせに回答できます。 + +Query Agent を試せるように、いくつかの公開データセットを用意しました。 +HuggingFace で公開されています。 + +- [**E-Commerce:**](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-ecommerce) 衣料品、価格、ブランド、レビューなどをまとめたデータセットです。 +- [**Brands:**](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-brands) 親ブランド、子ブランド、平均評価など、衣料品ブランドに関する情報をまとめたデータセットです。 + +## 導入: Query エージェントとは + +Weaviate Query Agent は、Weaviate Cloud に保存されたデータにもとづいて自然言語の質問に回答するためにあらかじめ構築されたエージェント サービスです。ユーザーは自然言語でプロンプトや質問を入力するだけで、Query Agent が途中の処理をすべて担い、回答を返します。 + +import WeaviateAgentsECommerceFlowchart from "/docs/agents/_includes/query_agent_tutorial_ecommerce_flowchart.png"; + +
+
+
+ Weaviate Query Agent flowchart +
+
+
+
+ +Query Agent の流れは次のとおりです。 + +1. 質問や instructions という形で **タスクを受け取る** +2. **適切な生成モデル**(例:大規模言語モデル)を使ってタスクを解析し、実行すべき正確なクエリを決定する +3. **Weaviate へクエリを送信**。必要に応じて指定されたベクトライザー統合(ここでは Weaviate Embeddings)でクエリをベクトル化する +4. **Weaviate から結果を受け取り**、適切な生成モデルを使ってユーザーのプロンプト/質問に対する最終的な回答を生成する + +
+ +## 前提条件 + +Weaviate Agents と Weaviate Embedding サービスを利用するには、 **[Weaviate Cloud](https://console.weaviate.cloud)** アカウントが必要です。 + +## ステップ 1: Weaviate のセットアップ + +ここからは、本チュートリアルで使用する Weaviate Cloud インスタンスを作成し、Python クライアントと接続していきます。 + +### 1.1 Weaviate Cloud クラスターの作成 + +1. Weaviate Cloud で [無料の Sandbox クラスターを作成](/cloud/manage-clusters/create#sandbox-clusters) します。 +1. クラスターへ接続するために `REST Endpoint` と `Admin` API キーをメモします。(詳細は [クイックスタート](/cloud/manage-clusters/connect.mdx) をご覧ください) + +:::tip +このチュートリアルではベクトライザーとして [Weaviate Embeddings](/weaviate/model-providers/weaviate/embeddings.md) サービスを使用するため、外部エンベディング プロバイダー用の追加キーは不要です。Weaviate Embeddings はデフォルトで `Snowflake/snowflake-arctic-embed-l-v2.0` モデルを利用します。

+別のベクトライザーを使用したい場合は、サポートされている [model providers](../../weaviate/model-providers/index.md) をご確認ください。 +::: + +### 1.2 Python ライブラリのインストール + +Weaviate Python クライアントと `agents` コンポーネントをインストールするには、次を実行します。 + + + + +``` +pip install "weaviate-client[agents]" +``` + + + + +また、HuggingFace にホストされている公開データセットへアクセスするために軽量ライブラリ `datasets` も必要です。 + + + + +``` +pip install datasets +``` + + + + +import ForcePipInstall from "../_includes/_force_pip_install.mdx"; + + + +### 1.3 インスタンスへの接続 + +それでは、最初のステップで取得したパラメーターを使って Weaviate Cloud インスタンスへ接続してみましょう。 + + + + + + + +スニペットを実行すると `True` が表示され、インスタンスへの接続が成功したことを確認できます。 + +## ステップ 2: コレクションの準備 + +以下のコード ブロックでは、Hugging Face からデモ データセットを取得し、Weaviate Sandbox クラスターに新しいコレクションとして書き込みます。データを Weaviate にインポートする前に **コレクションを定義** し、データ スキーマを設定し、ベクトライザー/エンベディング サービスを選択する必要があります。 + +### 2.1 コレクションの定義 + +下記は `E-Commerce` と `Brands` データセット内のオブジェクト例です。 + +import WeaviateAgentsEcommerceDataset from "/docs/agents/_includes/query_agent_tutorial_ecommerce_dataset.png"; + +
+
+
+ The E-Commerce and Brands datasets +
+
+
+
+ +`Brands` コレクションでは、インポートされたデータにもとづいてプロパティを自動生成する [`auto-schema`](../../weaviate/config-refs/collections.mdx#auto-schema) オプションを使用します。 +ただし、これは最適なインポート方法とは言えません。 + +Query Agent は **コレクションとプロパティの説明** を参照して、クエリを解決する際にどれを使用するか判断します。説明を変更して詳細を追加し、挙動を試してみると良いでしょう。 +そのため、データ スキーマを手動で定義し、プロパティ説明を追加することを推奨します。 + +たとえば、以下の例では価格がすべて USD であることを Query Agent に明示しています。これは自動では取得できない情報です。 + + + + + + + + + +### 2.2 データベースの入力 + +ここでは、あらかじめベクトル化されたデータ([E-Commerce](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-ecommerce) と [Brands](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-brands))を Weaviate Cloud インスタンスにインポートできます: + + + + + + + +コレクションに対して `len()` を呼び出すことで、インポートが正常に完了したか、またコレクションのサイズを確認できます。 + +``` +Size of the E-Commerce dataset: 448 +Size of the Brands dataset: 104 +``` + +## Step 3: Query エージェントの設定 + +### 3.1 基本的な Query エージェント + +Query エージェントをセットアップする際には、次の項目を指定する必要があります: + +- `client` +- エージェントにアクセスさせたい `collections` +- (任意)エージェントの振る舞いを説明する `system_prompt` +- (任意)タイムアウト - 既定値は 60 s + +まずはシンプルなエージェントから始めます。`Brands` と `ECommerce` データセットにアクセスできる `qa` エージェントを作成します。 + + + + + + + +これだけで完了です。すぐに Query エージェントを使用できます。 + +### 3.2 カスタム Query エージェント(system prompt 付き) {#system-prompt-agent} + +場合によっては、エージェント用にカスタムの `system_prompt` を定義したいことがあります。これにより、エージェントのデフォルトの振る舞いを指示できます。例として、常にユーザーの言語で回答するエージェントを作成してみましょう。 + + + + + + + +このカスタム エージェント `multi_lingual_qa` は [step 4.5](#use-system-prompt-agent) で使用します。 + +## Step 4: Query エージェントの実行 + +エージェントを実行すると、クエリに応じて次のような判断を行います: + +1. どのコレクション(複数可)を参照して回答を検索するかを判断します。 +2. 通常の **検索クエリ** を行うか、どの **フィルター** を使うか、**集約クエリ** を実行するか、あるいはそれらを組み合わせるかを判断します。 +3. その後、`QueryAgentResponse` 内にレスポンスを返します。 + +### 4.1 質問をする + +まずは簡単な質問から始めましょう: + +- 「ビンテージの服が好きなのですが、200 ドル以下でいくつか候補を挙げてもらえますか?」 + + + + + + + +エージェントからのレスポンス: + +``` +original_query='I like vintage clothes, can you list me some options that are less than $200?' collection_names=['ECommerce'] searches=[[QueryResultWithCollection(queries=['vintage clothes'], filters=[[IntegerPropertyFilter(property_name='price', operator=, value=200.0)]], filter_operators='AND', collection='ECommerce')]] aggregations=[] usage=Usage(requests=3, request_tokens=7681, response_tokens=428, total_tokens=8109, details=None) total_time=11.588264226913452 aggregation_answer=None has_aggregation_answer=False has_search_answer=True is_partial_answer=False missing_information=[] final_answer='Here are some vintage-inspired clothing options under $200:\n\n1. **Vintage Philosopher Midi Dress ($125.00)** - A deep green velvet fabric dress with antique gold button detailing, perfect for an academic or sophisticated setting. [Echo & Stitch]\n\n2. **Vintage Gale Pleated Dress ($120.00)** - A burgundy pleated dress capturing the Dark Academia aesthetic, great for poetry readings or contemplative afternoons. [Solemn Chic]\n\n3. **Retro Groove Flared Pants ($59.00)** - Electric blue flared pants capturing early 2000s millennial pop culture chic. [Vivid Verse]\n\n4. **Vintage Scholar Tote ($90.00)** - A deep green canvas tote with brown leather accents, ideal for carrying scholarly essentials. [Echo & Stitch]\n\n5. **Retro Futura Tee ($29.98)** - A bold graphic tee with early 2000s pop culture references, perfect for a nostalgic throwback. [Vivid Verse]\n\n6. **Electric Velvet Trousers ($60.00)** - Neon green velvet trousers with a flared leg, inspired by turn-of-the-century fashion icons. [Vivid Verse]\n\n7. **Vintage Ivy Loafers ($120.00)** - Burgundy leather loafers offering timeless sophistication, suitable for academic settings. [Solemn Chic]' sources=[Source(object_id='6040c373-9cce-421d-8f4e-e01346cbf29f', collection='ECommerce'), Source(object_id='06a83da4-92ff-4cbc-9cc6-c55fc6ed49b9', collection='ECommerce'), Source(object_id='a5a0927d-2859-47e6-8455-d77e0190aa53', collection='ECommerce'), Source(object_id='a5f3c394-d207-4064-a2bc-b9f655d09ddc', collection='ECommerce'), Source(object_id='5d7bb719-2df5-4a7c-9bbc-275450ab29c6', collection='ECommerce'), Source(object_id='50f4c89c-faf9-4430-b393-c39ede5d511d', collection='ECommerce'), Source(object_id='5b6d5a1f-e218-4400-ac9f-df59466f3c97', collection='ECommerce')] +``` + +しかし、この出力は情報量が多すぎるため、`final_answer` フィールドだけを返すようにしてみましょう: + + + + + + + +出力は次のとおりです: + +``` +Here are some vintage-inspired clothing options under $200: + +1. **Vintage Philosopher Midi Dress ($125.00)** - A deep green velvet fabric dress with antique gold button detailing, perfect for an academic or sophisticated setting. [Echo & Stitch] + +2. **Vintage Gale Pleated Dress ($120.00)** - A burgundy pleated dress capturing the Dark Academia aesthetic, great for poetry readings or contemplative afternoons. [Solemn Chic] + +3. **Retro Groove Flared Pants ($59.00)** - Electric blue flared pants capturing early 2000s millennial pop culture chic. [Vivid Verse] + +4. **Vintage Scholar Tote ($90.00)** - A deep green canvas tote with brown leather accents, ideal for carrying scholarly essentials. [Echo & Stitch] + +5. **Retro Futura Tee ($29.98)** - A bold graphic tee with early 2000s pop culture references, perfect for a nostalgic throwback. [Vivid Verse] + +6. **Electric Velvet Trousers ($60.00)** - Neon green velvet trousers with a flared leg, inspired by turn-of-the-century fashion icons. [Vivid Verse] + +7. **Vintage Ivy Loafers ($120.00)** - Burgundy leather loafers offering timeless sophistication, suitable for academic settings. [Solemn Chic] +``` + +`QueryAgentResponse` に対して `display()` メソッドを使用すると、次の情報をユーザーフレンドリーな形式で確認できます: + +- 🔍 元のクエリ - `original_query` +- 📝 最終回答 - `final_answer` +- 🔭 実行された検索 - `searches` +- 📊 実行された集約 - `aggregations` +- 📚 参照元 - `sources` +- ⚠️ 不足している情報 - `missing_information` +- 📊 使用状況統計 - `usage` +- 合計処理時間 - `total_time` + + + + + + + +
+ The response is: + +``` +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔍 Original Query ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ I like vintage clothes, can you list me some options that are less than $200? │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📝 Final Answer ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ Here are some vintage-inspired clothing options under $200: │ +│ │ +│ 1. **Vintage Philosopher Midi Dress ($125.00)** - A deep green velvet fabric dress with antique gold button detailing, perfect for an academic or sophisticated setting. [Echo & Stitch] │ +│ │ +│ 2. **Vintage Gale Pleated Dress ($120.00)** - A burgundy pleated dress capturing the Dark Academia aesthetic, great for poetry readings or contemplative afternoons. [Solemn Chic] │ +│ │ +│ 3. **Retro Groove Flared Pants ($59.00)** - Electric blue flared pants capturing early 2000s millennial pop culture chic. [Vivid Verse] │ +│ │ +│ 4. **Vintage Scholar Tote ($90.00)** - A deep green canvas tote with brown leather accents, ideal for carrying scholarly essentials. [Echo & Stitch] │ +│ │ +│ 5. **Retro Futura Tee ($29.98)** - A bold graphic tee with early 2000s pop culture references, perfect for a nostalgic throwback. [Vivid Verse] │ +│ │ +│ 6. **Electric Velvet Trousers ($60.00)** - Neon green velvet trousers with a flared leg, inspired by turn-of-the-century fashion icons. [Vivid Verse] │ +│ │ +│ 7. **Vintage Ivy Loafers ($120.00)** - Burgundy leather loafers offering timeless sophistication, suitable for academic settings. [Solemn Chic] │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔭 Searches Executed 1/1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ QueryResultWithCollection(queries=['vintage clothes'], filters=[[IntegerPropertyFilter(property_name='price', operator=, value=200.0)]], filter_operators='AND', collection='ECommerce') │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ 📊 No Aggregations Run │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📚 Sources ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ - object_id='6040c373-9cce-421d-8f4e-e01346cbf29f' collection='ECommerce' │ +│ - object_id='06a83da4-92ff-4cbc-9cc6-c55fc6ed49b9' collection='ECommerce' │ +│ - object_id='a5a0927d-2859-47e6-8455-d77e0190aa53' collection='ECommerce' │ +│ - object_id='a5f3c394-d207-4064-a2bc-b9f655d09ddc' collection='ECommerce' │ +│ - object_id='5d7bb719-2df5-4a7c-9bbc-275450ab29c6' collection='ECommerce' │ +│ - object_id='50f4c89c-faf9-4430-b393-c39ede5d511d' collection='ECommerce' │ +│ - object_id='5b6d5a1f-e218-4400-ac9f-df59466f3c97' collection='ECommerce' │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + + 📊 Usage Statistics +┌────────────────┬──────┐ +│ LLM Requests: │ 3 │ +│ Input Tokens: │ 7681 │ +│ Output Tokens: │ 428 │ +│ Total Tokens: │ 8109 │ +└────────────────┴──────┘ + +Total Time Taken: 11.59s +``` + +
+ +### 4.2 フォローアップ質問 + +エージェントには追加のコンテキストを与えることもできます。たとえば、`ChatMessage` オブジェクトを使って前回の応答をコンテキストとして会話を構築し、`new_response` を取得できます: + + + + + + + +
+ 応答は次のとおりです: + +``` +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔍 Original Query ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ What about some nice shoes, same budget as before? │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📝 Final Answer ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ Here are some great vintage-style shoes priced under $200 from various collections that blend style with nostalgia: │ +│ │ +│ 1. **Vintage Noir Loafers** ($125): These dress shoes, part of the Dark Academia collection, come in black and grey, offering a timeless look with subtle modern twists. They have received positive reviews for style and comfort, once broken │ +│ in (Source: 1). │ +│ │ +│ 2. **Vintage Ivy Loafers** ($120): Another classic from the Dark Academia line, these deep burgundy loafers combine elegance with comfort, as appreciated by users in their reviews (Source: 2). │ +│ │ +│ 3. **Glide Platforms** ($90): For a more playful option, these high-shine pink platform sneakers offer a nod to the Y2K era, receiving praise for their comfort and unique look (Source: 3). │ +│ │ +│ 4. **Celestial Step Platform Sneakers** ($90): With a dreamy sky blue color, these Y2K-inspired sneakers provide comfort and a touch of whimsy (Source: 4). │ +│ │ +│ 5. **Garden Stroll Loafers** ($90): From the Cottagecore collection, these cream loafers feature delicate floral motifs for a chic, countryside-inspired look (Source: 5). │ +│ │ +│ 6. **Bramble Brogues** ($120): In dusky green, these suede brogues add pastoral elegance to any outfit, admired for their craftsmanship (Source: 7). │ +│ │ +│ 7. **Garden Fête Heels** ($125): These cottagecore heels feature floral embroidery for a touch of elegance perfect for garden parties (Source: 10). │ +│ │ +│ 8. **Garden Gala T-Straps** ($125): Elegant cream and sage T-strap heels featuring floral embellishments, perfect for a whimsical yet classy touch (Source: 18). │ +│ │ +│ All these options fall under the $200 budget, offering a variety of styles from classic and elegant to colorful and playful, accommodating different fashion tastes and preferences. │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔭 Searches Executed 1/1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ QueryResultWithCollection(queries=['vintage shoes'], filters=[[IntegerPropertyFilter(property_name='price', operator=, value=200.0)]], filter_operators='AND', collection='Ecommerce') │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────── 📊 Aggregations Run 1/1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ AggregationResultWithCollection( │ +│ search_query=None, │ +│ groupby_property=None, │ +│ aggregations=[IntegerPropertyAggregation(property_name='price', metrics=)], │ +│ filters=[TextPropertyFilter(property_name='subcategory', operator=, value='vintage')], │ +│ collection='Ecommerce' │ +│ ) │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📚 Sources ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ - object_id='92efe1bb-77ee-4002-8618-4c9d7c3972c2' collection='Ecommerce' │ +│ - object_id='f51001bf-c0c6-47d5-b165-4e7ce878900e' collection='Ecommerce' │ +│ - object_id='9ba9ed81-c917-4e13-8058-d6ad81896ef3' collection='Ecommerce' │ +│ - object_id='41f324c2-a8e8-4cde-87d0-42661435a32c' collection='Ecommerce' │ +│ - object_id='d8d8e59e-d935-4a6f-9df1-bc2477452b11' collection='Ecommerce' │ +│ - object_id='505238e0-9993-4838-89fc-513c8f53d9f8' collection='Ecommerce' │ +│ - object_id='4a1321dc-d3f5-405d-8b21-e656c448ccfd' collection='Ecommerce' │ +│ - object_id='b59f7700-2633-43d6-807e-72dda35d545c' collection='Ecommerce' │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + + 📊 Usage Statistics +┌────────────────┬───────┐ +│ LLM Requests: │ 5 │ +│ Input Tokens: │ 15998 │ +│ Output Tokens: │ 906 │ +│ Total Tokens: │ 16904 │ +└────────────────┴───────┘ + +Total Time Taken: 22.77s +``` + +
+ +### 4.3 集約の実行 + +ここでは、集約が必要な質問を試してみましょう。どのブランドが最も多くのシューズを掲載しているかを確認します。 + + + + + + + +
+ 応答は次のとおりです: + +``` +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔍 Original Query ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ What is the the name of the brand that lists the most shoes? │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📝 Final Answer ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ The brand that lists the most shoes is Loom & Aura, with a total count of 118 shoes across various styles such as Cottagecore, Fairycore, Goblincore, Light Academia, and Dark Academia. │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ 🔭 No Searches Run │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────── 📊 Aggregations Run 1/1 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ AggregationResultWithCollection( │ +│ search_query=None, │ +│ groupby_property='brand', │ +│ aggregations=[TextPropertyAggregation(property_name='collection', metrics=, top_occurrences_limit=1)], │ +│ filters=[], │ +│ collection='ECommerce' │ +│ ) │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + + 📊 Usage Statistics +┌────────────────┬──────┐ +│ LLM Requests: │ 3 │ +│ Input Tokens: │ 5794 │ +│ Output Tokens: │ 238 │ +│ Total Tokens: │ 6032 │ +└────────────────┴──────┘ + +Total Time Taken: 7.52s +``` + +
+ +### 4.4 複数コレクションの検索 + +場合によっては、複数のコレクションにわたる検索結果を組み合わせる必要があります。上記の結果から、「Loom & Aura」が最も多くのシューズを掲載していることがわかります。 + +次に、ユーザーがこの企業について、_さらに_ その販売商品について詳しく知りたいというシナリオを想定してみましょう。 + + + + + + + +
+ 応答は次のとおりです: + +``` +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔍 Original Query ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ Does the brand 'Loom & Aura' have a parent brand or child brands and what countries do they operate from? Also, what's the average price of a shoe from 'Loom & Aura'? │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📝 Final Answer ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ The brand "Loom & Aura" operates as a parent brand with several child brands, including "Loom & Aura Active," "Loom & Aura Kids," "Nova Nest," "Vivid Verse," "Loom Luxe," "Saffrom Sage," "Stellar Stitch," "Nova Nectar," "Canvas Core," and │ +│ "Loom Lure." "Loom & Aura" itself is based in Italy and operates in multiple countries where its child brands are located, such as the USA, Japan, South Korea, Spain, the UK, and France. │ +│ │ +│ The average price of a shoe from "Loom & Aura" is approximately $87.11, based on the aggregation of available data on shoe prices. │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔭 Searches Executed 1/2 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ QueryResultWithCollection(queries=['Loom parent brand and child brands', 'Aura parent brand and child brands'], filters=[[], []], filter_operators='AND', collection='Brands') │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔭 Searches Executed 2/2 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ QueryResultWithCollection(queries=['countries where Loom & Aura operates'], filters=[[TextPropertyFilter(property_name='name', operator=)], │ +│ filters=[TextPropertyFilter(property_name='brand', operator= + +### 4.5 システムプロンプトの利用 {#use-system-prompt-agent} + +ここでは、[ステップ 3.2](#system-prompt-agent) で作成したカスタム エージェントを、次のシステムプロンプトと共に使用します: + +``` +"You are a helpful assistant that always generates the final response in the user's language." +"You may have to translate the user query to perform searches. But you must always respond to the user in their own language." +``` + +たとえば、ブランド「Eko & Stitch」が英国に支店や関連会社を持っているかどうかを、日本語で質問してみてください(英語ではなく): + + + + + + + +
+ 応答は次のとおりです: + +``` +Eko & Stitchは、英国に拠点があります。1974年に設立され、品質の高いクラフトマンシップとタイムレスなエレガンスで知られています。関連ブランドとして「Eko & Stitch Active」と「Eko & Stitch Kids」があります。また、Eko & Stitchの親会社はNova Nestです。 +``` + +英訳すると: + +``` +Eko & Stitch is based in the UK. It was established in 1974 and is known for its high-quality craftsmanship and timeless elegance. It has associated brands, "Eko & Stitch Active" and "Eko & Stitch Kids." Additionally, the parent company of Eko & Stitch is Nova Nest. +``` + +
+ +## 概要 + +このガイドでは、Weaviate のエージェントサービスを活用して、エンドツーエンドの e-commerce アシスタントを構築する方法を説明しました。具体的には、Weaviate Cloud インスタンスのセットアップやデータセットのインポートから、自然言語クエリをインテリジェントに処理する Query Agent の設定までを扱いました。 + +Query Agent はクエリを自動的に解釈し、標準検索・フィルター・集約のどれを実行するかを判断します。また、複数のコレクションに接続し、クエリに応じて適切なソースを選択します。さらに、過去のやり取りを利用して関連性の高いフォローアップ回答を提供でき、システムプロンプトを定義することで、常にユーザーの好む言語やスタイルで応答させることも可能です。 + +## 関連リソース + +- [Weaviate Agents ‐ Query Agent](./index.md) + +## ご質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/usage.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/usage.md new file mode 100644 index 000000000..c7556bb1a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/query/usage.md @@ -0,0 +1,646 @@ +--- +title: 使用方法 +sidebar_position: 30 +description: "Query Agent を実装するための技術ドキュメントと使用例。" +image: og/docs/agents.jpg +# tags: ['agents', 'getting started', 'query agent'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/docs/agents/\_includes/query_agent.py'; +import TSCode from '!!raw-loader!/docs/agents/\_includes/query_agent.mts'; + +# Weaviate Query Agent:使用方法 + +Weaviate Query Agent は、Weaviate Cloud に保存されたデータを基に自然言語クエリへ回答するよう設計された、あらかじめ構築済みの エージェント サービスです。 + +ユーザーは自然言語でプロンプトや質問を入力するだけで、Query Agent が途中の処理をすべて実行し、回答を返します。 + +![ユーザー視点での Weaviate Query Agent](../_includes/query_agent_usage_light.png#gh-light-mode-only "ユーザー視点での Weaviate Query Agent") +![ユーザー視点での Weaviate Query Agent](../_includes/query_agent_usage_dark.png#gh-dark-mode-only "ユーザー視点での Weaviate Query Agent") + +このページでは、Weaviate Cloud に保存したデータを用いて Query Agent で自然言語クエリに回答する方法を説明します。 + +## 前提条件 + +### Weaviate インスタンス + +このエージェントは Weaviate Cloud インスタンス専用です。Weaviate Cloud インスタンスのセットアップ方法については、[Weaviate Cloud のドキュメント](/cloud/index.mdx) を参照してください。 + +[Weaviate Cloud](https://console.weaviate.cloud/) の無料 Sandbox インスタンスで、この Weaviate エージェントを試すこともできます。 + +### クライアントライブラリ + +:::note 対応言語 +現在、このエージェントは Python と TypeScript/JavaScript のみ対応しています。その他の言語は今後追加予定です。 +::: + +Python では、Weaviate Agents を使うためにオプションの `agents` extras 付きで Weaviate クライアントライブラリをインストールできます。これにより `weaviate-client` パッケージとともに `weaviate-agents` パッケージがインストールされます。TypeScript/JavaScript では、`weaviate-client` パッケージと一緒に `weaviate-agents` パッケージをインストールしてください。 + +次のコマンドでクライアントライブラリをインストールします。 + + + + +```shell +pip install -U weaviate-client[agents] +``` + +#### トラブルシューティング:`pip` で最新バージョンを強制インストールする + +既存環境では、`pip install -U "weaviate-client[agents]"` を実行しても `weaviate-agents` が [最新バージョン](https://pypi.org/project/weaviate-agents/) に更新されない場合があります。その際は `weaviate-agents` パッケージを明示的にアップグレードしてください。 + +```shell +pip install -U weaviate-agents +``` + +または [特定バージョン](https://github.com/weaviate/weaviate-agents-python-client/tags) をインストールします。 + +```shell +pip install -U weaviate-agents==||site.weaviate_agents_version|| +``` + + + + +```shell +npm install weaviate-agents@latest +``` + + + + + +## Query Agent のインスタンス化 + +### 基本的なインスタンス化 + +以下を指定します。 + +- 対象の [Weaviate Cloud インスタンスの詳細](/cloud/manage-clusters/connect.mdx)(例:`WeaviateClient` オブジェクト) +- クエリ対象とするコレクションのデフォルトリスト + + + + + + + + + + + +### コレクションの設定 + +クエリ対象コレクションのリストは、次の項目でさらに設定できます。 + +- テナント名(マルチテナントコレクションの場合は必須) +- クエリ対象とするコレクションの ベクトル(複数可)(任意) +- エージェントが使用するプロパティ名のリスト(任意) +- エージェントが生成したフィルターに常に上乗せする[追加フィルター](#user-defined-filters)(任意) + + + + + + + + + + + +:::info Query Agent がアクセスできるものは? + +Query Agent は、渡された Weaviate クライアントオブジェクトから認証情報を取得します。その後、指定されたコレクション名でさらにアクセス範囲を制限できます。 + +たとえば、指定した Weaviate 認証情報のユーザーが一部のコレクションにしかアクセスできない場合、Query Agent もそのコレクションのみを参照できます。 + +::: + + + +### 追加オプション + +Query エージェントは、次のような追加オプションを指定してインスタンス化できます: + +- `system_prompt`: Weaviate チームが提供するデフォルトのシステムプロンプトを置き換えるためのカスタムシステムプロンプト(JavaScript では `systemPrompt`)。 +- `timeout`: Query エージェントが 1 件のクエリに費やす最大時間(秒)。サーバーサイドのデフォルト: 60。 + +#### カスタムシステムプロンプト + +Query エージェントの挙動を制御するためにカスタムシステムプロンプトを指定できます: + + + + + + + + + + + +### ユーザー定義フィルター + +永続的なフィルターを設定すると、エージェントが生成したフィルターと論理 `AND` で常に結合されます。 + + + + + + + + + + + +### Async Python クライアント + +Async Python クライアントの使用例については、[Async Python クライアントのセクション](#usage---async-python-client)を参照してください。 + +## クエリ実行 + +Query エージェントがサポートするクエリタイプは 2 つあります: + +- [**`Search`**](#search) +- [**`Ask`**](#ask) + +### `Search` + +自然言語で Weaviate に `Search` を実行します。Query エージェントが質問を処理し、Weaviate 内で必要な検索を行い、関連オブジェクトを返します。 + + + + + + + + + + + +#### `Search` 応答構造 + + + + + + + + + + + +
+ Example output + +``` +Original query: winter boots for under $100 +Total time: 4.695224046707153 +Usage statistics: requests=2 request_tokens=143 response_tokens=9 total_tokens=152 details=None +Search performed: queries=['winter boots'] filters=[[IntegerPropertyFilter(property_name='price', operator=, value=100.0)]] filter_operators='AND' collection='ECommerce' +Properties: {'name': 'Bramble Berry Loafers', 'description': 'Embrace your love for the countryside with our soft, hand-stitched loafers, perfect for quiet walks through the garden. Crafted with eco-friendly dyed soft pink leather and adorned with a subtle leaf embossing, these shoes are a testament to the beauty of understated simplicity.', 'price': 75.0} +Metadata: {'creation_time': None, 'last_update_time': None, 'distance': None, 'certainty': None, 'score': 0.4921875, 'explain_score': None, 'is_consistent': None, 'rerank_score': None} +Properties: {'name': 'Glitter Bootcut Fantasy', 'description': "Step back into the early 2000s with these dazzling silver bootcut jeans. Embracing the era's optimism, these bottoms offer a comfortable fit with a touch of stretch, perfect for dancing the night away.", 'price': 69.0} +Metadata: {'creation_time': None, 'last_update_time': None, 'distance': None, 'certainty': None, 'score': 0.47265625, 'explain_score': None, 'is_consistent': None, 'rerank_score': None} +Properties: {'name': 'Celestial Step Platform Sneakers', 'description': 'Stride into the past with these baby blue platforms, boasting a dreamy sky hue and cushy soles for day-to-night comfort. Perfect for adding a touch of whimsy to any outfit.', 'price': 90.0} +Metadata: {'creation_time': None, 'last_update_time': None, 'distance': None, 'certainty': None, 'score': 0.48828125, 'explain_score': None, 'is_consistent': None, 'rerank_score': None} +Properties: {'name': 'Garden Bliss Heels', 'description': 'Embrace the simplicity of countryside elegance with our soft lavender heels, intricately designed with delicate floral embroidery. Perfect for occasions that call for a touch of whimsy and comfort.', 'price': 90.0} +Metadata: {'creation_time': None, 'last_update_time': None, 'distance': None, 'certainty': None, 'score': 0.45703125, 'explain_score': None, 'is_consistent': None, 'rerank_score': None} +Properties: {'name': 'Garden Stroll Loafers', 'description': 'Embrace the essence of leisurely countryside walks with our soft, leather loafers. Designed for the natural wanderer, these shoes feature delicate, hand-stitched floral motifs set against a soft, cream background, making every step a blend of comfort and timeless elegance.', 'price': 90.0} +Metadata: {'creation_time': None, 'last_update_time': None, 'distance': None, 'certainty': None, 'score': 0.451171875, 'explain_score': None, 'is_consistent': None, 'rerank_score': None} +``` + +
+ +#### `Search` のページネーション + +`Search` はページネーションに対応しており、大きな結果セットを効率的に扱えます: + + + + + + + + + + + +
+ Example output + +``` +Page 1: + Glide Platforms - $90.0 + Garden Haven Tote - $58.0 + Sky Shimmer Sneaks - $69.0 + +Page 2: + Garden Haven Tote - $58.0 + Celestial Step Platform Sneakers - $90.0 + Eloquent Satchel - $59.0 + +Page 3: + Garden Haven Tote - $58.0 + Celestial Step Platform Sneakers - $90.0 + Eloquent Satchel - $59.0 +``` + +
+ +### `Ask` + +自然言語で `Ask` を使用して Query Agent に質問します。Query Agent は質問を処理し、 Weaviate で必要な検索を実行し、回答を返します。 + +:::tip クエリを慎重に検討してください +Query Agent は、あなたのクエリに基づいて戦略を立てます。そのため、可能な限り曖昧さがなく、情報が十分で、かつ簡潔なクエリを心掛けてください。 +::: + + + + + + + + + + + +### ランタイムでのコレクション設定 + +クエリ実行時に、照会対象のコレクション一覧を名前のリスト、または追加の設定とともに上書きできます。 + +#### コレクション名のみを指定 + +この例では、このクエリに対してのみ設定済みの Query Agent コレクションを上書きします。 + + + + + + + + + + + +#### コレクションの詳細設定 + +この例では、このクエリに対してのみ設定済みの Query Agent コレクションを上書きし、必要に応じて次のような追加オプションを指定しています。 + +- ターゲット ベクトル +- 表示するプロパティ +- ターゲット テナント +- 追加フィルター + + + + + + + + + + + +### 会話形式のクエリ + +Query Agent は `ChatMessage` オブジェクトのリストを渡すことで複数ターンの会話をサポートします。これは `Search` と `Ask` の両方のクエリタイプで機能します。 + +`ChatMessage` で会話を構築する際、メッセージには次の 2 つのロールがあります。 + +- **`user`** - 人間のユーザーが質問やコンテキストを提供するメッセージを表します +- **`assistant`** - Query Agent の応答、または会話履歴内の任意の AI アシスタントの応答を表します + +会話履歴は Query Agent が前のやり取りからコンテキストを理解するのに役立ち、より首尾一貫した複数ターンの対話を可能にします。適切な会話の流れを維持するため、常に user と assistant のロールを交互にしてください。 + + + + + + + + + + + +## ストリーム応答 + +Query Agent は応答をストリームすることもでき、生成中の回答をリアルタイムで受け取れます。 + +ストリーミング応答は、次のオプションパラメーターで要求できます。 + +- `include_progress`:`True` に設定すると、Query Agent はクエリを処理する進捗をストリームします。 +- `include_final_state`:`True` に設定すると、Query Agent は回答全体が生成されるのを待たず、生成され次第最終回答をストリームします。 + +`include_progress` と `include_final_state` の両方を `False` に設定した場合、Query Agent は進捗更新や最終状態を含めず、生成された回答トークンのみをストリームします。 + + + + + + + + + + + + +## レスポンスの確認 + +Query Agent からのレスポンスには最終的な回答に加えて、追加の補足情報が含まれます。 + +補足情報には、実行された検索や集計、欠落している可能性のある情報、Agent が使用した LLM トークン数などが含まれる場合があります。 + +### ヘルパー関数 + +提供されているヘルパー関数(例: `.display()` メソッド)を使用して、レスポンスを読みやすい形式で表示してみてください。 + + + + + + + + + + + +このコードは、Query Agent が見つけた補足情報の概要とともにレスポンスを出力します。 + +
+ Example output + +```text +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔍 Original Query ────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ I like vintage clothes and nice shoes. Recommend some of each below $60. │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📝 Final Answer ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ For vintage clothing under $60, you might like the Vintage Philosopher Midi Dress by Echo & Stitch. It features deep green velvet fabric with antique gold button details, tailored fit, and pleated skirt, perfect for a classic vintage look. │ +│ │ +│ For nice shoes under $60, consider the Glide Platforms by Vivid Verse. These are high-shine pink platform sneakers with cushioned soles, inspired by early 2000s playful glamour, offering both style and comfort. │ +│ │ +│ Both options combine vintage or retro aesthetics with an affordable price point under $60. │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔭 Searches Executed 1/2 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ QueryResultWithCollection(queries=['vintage clothing'], filters=[[]], filter_operators='AND', collection='ECommerce') │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────────────────────── 🔭 Searches Executed 2/2 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ QueryResultWithCollection(queries=['nice shoes'], filters=[[]], filter_operators='AND', collection='ECommerce') │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ 📊 No Aggregations Run │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 📚 Sources ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ │ +│ - object_id='a7aa8f8a-f02f-4c72-93a3-38bcbd8d5581' collection='ECommerce' │ +│ - object_id='ff5ecd6e-8cb9-47a0-bc1c-2793d0172984' collection='ECommerce' │ +│ │ +╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + + 📊 Usage Statistics +┌────────────────┬─────┐ +│ LLM Requests: │ 5 │ +│ Input Tokens: │ 288 │ +│ Output Tokens: │ 17 │ +│ Total Tokens: │ 305 │ +└────────────────┴─────┘ + +Total Time Taken: 7.58s +``` + +
+ +### 確認例 + +この例では、以下の内容が出力されます。 + +- 元のユーザークエリ +- Query Agent が提供した回答 +- Query Agent が実行した検索・集計(該当する場合) +- 欠落している情報 + + + + + + + + + + + +## 使用方法 - Async Python クライアント + +async Python Weaviate クライアントを使用する場合でも、インスタンス化のパターンはほぼ同じです。違いは `QueryAgent` クラスの代わりに `AsyncQueryAgent` クラスを使用する点です。 + +async パターンの例は以下のとおりです。 + + + + + + + +### ストリーミング + +async Query Agent はレスポンスをストリーミングすることもでき、生成中の回答を逐次受け取れます。 + + + + + + + +## 制限とトラブルシューティング + +### 使用制限 + +import UsageLimits from "/\_includes/agents/query-agent-usage-limits.mdx"; + + + +### カスタムコレクションの説明 + +import CollectionDescriptions from "/\_includes/agents/query-agent-collection-descriptions.mdx"; + + + +### 実行時間 + +import ExecutionTimes from "/\_includes/agents/query-agent-execution-times.mdx"; + + + + + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes.mdx new file mode 100644 index 000000000..478b46463 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes.mdx @@ -0,0 +1,10 @@ +--- +title: Weaviate レシピ(コード例) +hide_table_of_contents: true +--- + +本ページには、 Weaviate の一般的な操作に関するレシピが掲載されています。また、レシピの元となったオリジナルの [Jupyter Notebook](https://github.com/weaviate/recipes) もご覧いただけます。 + +import RecipesCards from "@site/src/components/RecipesCards"; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/personalization-agent-get-started-movies.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/personalization-agent-get-started-movies.md new file mode 100644 index 000000000..80784c832 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/personalization-agent-get-started-movies.md @@ -0,0 +1,580 @@ +--- +layout: recipe +colab: https://colab.research.google.com/github/weaviate/recipes/blob/main/weaviate-services/agents/personalization-agent-get-started-movies.ipynb +toc: True +title: "Weaviate パーソナライズ エージェントの構築 - 映画レコメンダー" +featured: True +integration: False +agent: True +tags: ['Personalization Agent'] +--- + + Open In Google Colab + + +このレシピでは、新しい Weaviate `PersonalizationAgent` を使用して、 Weaviate コレクションからユーザーごとにパーソナライズされたオブジェクトを取得します。この新しいエージェントによる取得方法は、ユーザーのペルソナプロファイルとコレクションとの過去のインタラクションに基づいています。 + +> 📚 `PersonalizationAgent` の詳細な使い方については、当社ブログ「[Introducing the Weaviate Personalization Agent](https://weaviate.io/blog/personalization-agent?utm_source=recipe&utm_campaign=agents)」および[ドキュメント](https://docs.weaviate.io/agents/personalization)をご覧ください。 + +すぐに試せるように、 Hugging Face datasets 🤗 上にいくつかのデモデータセットを用意しています。 + +- [Movies](https://huggingface.co/datasets/weaviate/agents/viewer/personalization-agent-movies):映画、評価、オリジナル言語などを掲載したデータセット +- [Recipes](https://huggingface.co/datasets/weaviate/agents/viewer/personalization-agent-recipes):料理名、短い説明、料理の種類を掲載したデータセット + +本例では、 Movies データセットを使用して映画レコメンダーサービスを作成します。 + +```python +!pip install weaviate-client[agents] datasets +``` + +## Weaviate のセットアップとデータのインポート + +Weaviate Personalization Agent を利用するには、まず [Weaviate Cloud](tps://weaviate.io/deployment/serverless?utm_source=recipe&utm_campaign=agents) アカウントを作成してください👇 +1. [Serverless Weaviate Cloud アカウントを作成](https://weaviate.io/deployment/serverless?utm_source=recipe&utm_campaign=agents)し、無料の[Sandbox](https://docs.weaviate.io/cloud/manage-clusters/create#sandbox-clusters?utm_source=recipe&utm_campaign=agents)をセットアップします。 +2. 「Embedding」を開き、有効化します。デフォルトでは `Snowflake/snowflake-arctic-embed-l-v2.0` が埋め込みモデルとして使用されます。 +3. 下記でクラスターに接続するため、 `WEAVIATE_URL` と `WEAVIATE_API_KEY` を控えておいてください。 + +> Info: 外部の埋め込みプロバイダー用の追加キーを用意する必要がないため、[Weaviate Embeddings](https://docs.weaviate.io/weaviate/model-providers/weaviate) の利用を推奨します。 + +```python +import os + +import weaviate +from weaviate.auth import Auth +from getpass import getpass + +if "WEAVIATE_API_KEY" not in os.environ: + os.environ["WEAVIATE_API_KEY"] = getpass("Weaviate API Key") +if "WEAVIATE_URL" not in os.environ: + os.environ["WEAVIATE_URL"] = getpass("Weaviate URL") + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=Auth.api_key(os.environ.get("WEAVIATE_API_KEY")), +) +``` + +### 新しいコレクションの作成 + +次に、 Weaviate に "Movies" という新しいコレクションを作成します。エージェント機能を利用する場合、コレクションのプロパティに説明文を付けておくと便利です。これらの説明はエージェントによって利用されます。 + +```python +from weaviate.classes.config import Configure, DataType, Property + +# if client.collections.exists("Movies"): + # client.collections.delete("Movies") + +client.collections.create( + "Movies", + description="A dataset that lists movies, including their release dates, ratings, popularity etc.", + vector_config=Configure.Vectors.text2vec_weaviate(), + properties=[ + Property( + name="release_date", + data_type=DataType.TEXT, + description="release date of the movie", + skip_vectorization=True, + ), + Property( + name="title", data_type=DataType.TEXT, description="title of the movie" + ), + Property( + name="overview", + data_type=DataType.TEXT, + description="overview of the movie", + ), + Property( + name="genres", + data_type=DataType.TEXT_ARRAY, + description="genres of the movie", + ), + Property( + name="vote_average", + data_type=DataType.NUMBER, + description="vote average of the movie", + ), + Property( + name="vote_count", + data_type=DataType.INT, + description="vote count of the movie", + ), + Property( + name="popularity", + data_type=DataType.NUMBER, + description="popularity of the movie", + ), + Property( + name="poster_url", + data_type=DataType.TEXT, + description="poster path of the movie", + skip_vectorization=True, + ), + Property( + name="original_language", + data_type=DataType.TEXT, + description="Code of the language of the movie", + skip_vectorization=True, + ), + ], +) +``` + +Python 出力: +```text + +``` +```python +from datasets import load_dataset + +dataset = load_dataset("weaviate/agents", "personalization-agent-movies", split="train", streaming=True) + +movies_collection = client.collections.use("Movies") + +with movies_collection.batch.dynamic() as batch: + for item in dataset: + batch.add_object(properties=item["properties"]) +``` + +## Personalization Agent の作成 + +以下では、 `"Movies"` コレクション用の `PersonalizationAgent` を作成します。すでにこのコレクション用のエージェントが存在する場合は、接続するだけで構いません。 + +新しい `PersonalizationAgent` を作成する際には、 `user_properties` を任意で定義できます。 + +`user_properties` には、エージェントに追加するユーザーに関する有用な情報を指定できます。映画レコメンダーサービスを作成する本例では、各ペルソナに `age`、`favorite_genres`、`languages` を登録することにします。 + +```python +from weaviate.agents.personalization import PersonalizationAgent + +if PersonalizationAgent.exists(client, "Movies"): + agent = PersonalizationAgent.connect( + client=client, + reference_collection="Movies", + ) +else: + agent = PersonalizationAgent.create( + client=client, + reference_collection="Movies", + user_properties={ + "age": DataType.NUMBER, + "favorite_genres": DataType.TEXT_ARRAY, + "languages": DataType.TEXT_ARRAY, + }, + ) + +``` + +### 新しいペルソナの追加 + +`add_persona` を使用して新しいユーザーを追加できます。追加時に先ほど指定したユーザープロパティを設定します。下のコードを変更してご自身を表現してみても構いません👇 + +```python +from uuid import uuid4 +from weaviate.agents.classes import Persona, PersonaInteraction + +persona_id = uuid4() +agent.add_persona( + Persona( + persona_id=persona_id, + properties={ + "age": 29, + "favorite_genres": ["RomCom", "Adventure", "Sci-Fi", "Fantasy"], + "languages": ["English", "French"], + }, + ) +) +``` + +### インタラクションの追加 + +少なくとも 1 つのペルソナを作成したら、そのペルソナに対するインタラクションを追加できます。映画レコメンダーサービスの場合、ペルソナによる映画レビューを追加するのが自然でしょう。 + +各インタラクションには -1.0(ネガティブ)から 1.0(ポジティブ)までの重みを設定できます。以下ではいくつかの映画に対するレビューを追加してみます。 + +エンドアプリケーションがどのようにインタラクションを転送するかを考え、各重みが何を意味するかのルールを決めておくと良いでしょう。例: +- 1.0: お気に入りの映画 +- 0.8: 映画を気に入った +- 0.5: 映画を視聴したがレビューはなし +- -0.5: 映画が気に入らなかった +- -1.0: 映画が大嫌い 👎 + +```python +from uuid import UUID +from weaviate.collections.classes.filters import Filter + +reviewed_movies = [ + "Fantastic Beasts and Where to Find Them", + "The Emoji Movie", + "Titanic", + "The Shining", + "Jumanji", + "West Side Story", + "The Shape of Water", + "Morbius" +] + +reviews_dict = { + movie.properties["title"]: movie + for movie in movies_collection.query.fetch_objects( + filters=Filter.by_property("title").contains_any(reviewed_movies), limit=20 + ).objects +} + +interactions = [ + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Fantastic Beasts and Where to Find Them"].uuid, weight=0.8 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["The Emoji Movie"].uuid, weight=-0.5 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Titanic"].uuid, weight=0.5 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["The Shining"].uuid, weight=0.5 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Jumanji"].uuid, weight=0.8 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["West Side Story"].uuid, weight=-0.5 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["The Shape of Water"].uuid, weight=-1.0 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Morbius"].uuid, weight=-1.0 + ), +] +``` + +```python +agent.add_interactions(interactions=interactions) +``` + +## レコメンデーションと根拠の取得 + +ペルソナとそのインタラクションを追加したので、 `get_objects` でエージェントからおすすめオブジェクトを取得できます。ここでは `use_agent_ranking` を設定するかどうかを選べます。 + +`use_agent_ranking` を使用しない場合、返されるオブジェクトは従来の ML クラスタリングによってランク付けされます。使用する場合は、追加で LLM による再ランキングが行われ、任意の `instruction` を指定できます。 + +`use_agent_ranking` を有効にすると、下記のように `ranking_rationale` でランク付けの根拠も確認できます👇 + +```python +response = agent.get_objects(persona_id, limit=25, use_agent_ranking=True) + +print(response.ranking_rationale) +for i, obj in enumerate(response.objects): + print(f"*****{i}*****") + print(obj.properties["title"]) + print(obj.properties["overview"]) + print(obj.properties["genres"]) + print(f"vote_average: {obj.properties['vote_average']}") + print(obj.properties['poster_url']) +``` + +Python 出力: +```text +We've placed a spotlight on fantasy and adventure titles given your love for these genres. Movies like 'The Chronicles of Narnia' and 'Jumanji' have been prioritized as they align with your past favorites and preferences. Holiday-themed family films were also considered due to their family-friendly and adventurous nature. +*****0***** +The Chronicles of Narnia: The Lion, the Witch and the Wardrobe +Siblings Lucy, Edmund, Susan and Peter step through a magical wardrobe and find the land of Narnia. There, they discover a charming, once peaceful kingdom that has been plunged into eternal winter by the evil White Witch, Jadis. Aided by the wise and magnificent lion, Aslan, the children lead Narnia into a spectacular, climactic battle to be free of the Witch's glacial powers forever. +['Adventure', 'Family', 'Fantasy'] +vote_average: 7.1 +https://image.tmdb.org/t/p/original/kzJip9vndXYSKQHCgekrgqbnUrA.jpg +*****1***** +The Ewok Adventure +The Towani family civilian shuttlecraft crashes on the forest moon of Endor. The four Towani's are separated. Jermitt and Catarine, the mother and father are captured by the giant Gorax, and Mace and Cindel, the son and daughter, are missing when they are captured. The next day, the Ewok Deej is looking for his two sons when they find Cindel all alone in the shuttle (Mace and Cindel were looking for the transmitter to send a distress call), when Mace appears with his emergency blaster. Eventually, the four-year old Cindel is able to convince the teenage Mace that the Ewoks are nice. Then, the Ewoks and the Towani's go on an adventure to find the elder Towanis. +['Adventure', 'Family', 'Fantasy', 'Science Fiction', 'TV Movie'] +vote_average: 6.0 +https://image.tmdb.org/t/p/original/lP7FIxojVrgWsam9efElk5ba3I5.jpg +*****2***** +The Chronicles of Narnia: Prince Caspian +One year after their incredible adventures in the Lion, the Witch and the Wardrobe, Peter, Edmund, Lucy and Susan Pevensie return to Narnia to aid a young prince whose life has been threatened by the evil King Miraz. Now, with the help of a colorful cast of new characters, including Trufflehunter the badger and Nikabrik the dwarf, the Pevensie clan embarks on an incredible quest to ensure that Narnia is returned to its rightful heir. +['Adventure', 'Family', 'Fantasy'] +vote_average: 6.6 +https://image.tmdb.org/t/p/original/qxz3WIyjZiSKUhaTIEJ3c1GcC9z.jpg +*****3***** +Pete's Dragon +For years, old wood carver Mr. Meacham has delighted local children with his tales of the fierce dragon that resides deep in the woods of the Pacific Northwest. To his daughter, Grace, who works as a forest ranger, these stories are little more than tall tales... until she meets Pete, a mysterious 10-year-old with no family and no home who claims to live in the woods with a giant, green dragon named Elliott. And from Pete's descriptions, Elliott seems remarkably similar to the dragon from Mr. Meacham's stories. With the help of Natalie, an 11-year-old girl whose father Jack owns the local lumber mill, Grace sets out to determine where Pete came from, where he belongs, and the truth about this dragon. +['Adventure', 'Family', 'Fantasy'] +vote_average: 6.4 +https://image.tmdb.org/t/p/original/6TwrPngfpbwtVH6UsDfVNUnn3ms.jpg +*****4***** +The Chronicles of Narnia: The Voyage of the Dawn Treader +This time around Edmund and Lucy Pevensie, along with their pesky cousin Eustace Scrubb find themselves swallowed into a painting and on to a fantastic Narnian ship headed for the very edges of the world. +['Adventure', 'Family', 'Fantasy'] +vote_average: 6.4 +https://image.tmdb.org/t/p/original/pP27zlm9yeKrCeDZLFLP2HKELot.jpg +*****5***** +One Piece: Clockwork Island Adventure +Relaxing on a cozy beach, the Straw Hat Pirates are taking a rest from their quest. Right until Luffy noticed the Going Merry has been hijacked and sailed off from the beach. This leads them to search the ship and find the thief who took it from them. They ran into a duo named the Theif Brothers, who informed them that their ship was stolen by a group of pirates called the Trump Kyoudai. When they encountered the Trump Pirates, Nami ended up getting kidnapped as well as Luffy's hat. They tracked down the pirates to their base on Clockwork Island. Now Luffy, Zoro, Sanji, Usopp, and the Theif Brothers must reclaim the Going Merry, Save Nami, and get back Shank's straw hat. +['Action', 'Animation', 'Adventure'] +vote_average: 6.8 +https://image.tmdb.org/t/p/original/mocek0mTd2dX2neCB691iU9le9k.jpg +*****6***** +Good Luck Charlie, It's Christmas! +Teddy Duncan's middle-class family embarks on a road trip from their home in Denver to visit Mrs. Duncans Parents, the Blankenhoopers, in Palm Springs. When they find themselves stranded between Denver and Utah, they try to hitch a ride to Las Vegas with a seemingly normal older couple in a station wagon from Roswell, New Mexico. It turns out that the couple believes they are the victims of alien abduction. The Duncan's must resort to purchasing a clunker Yugo to get to Utah, have their luggage stolen in Las Vegas, and survive a zany Christmas with Grandpa and Grandma Blankenhooper. +['TV Movie', 'Comedy', 'Family'] +vote_average: 6.6 +https://image.tmdb.org/t/p/original/ecuJMYZM3HQ96mnWtmyXoHb7s7T.jpg +*****7***** +Bedknobs and Broomsticks +Three children evacuated from London during World War II are forced to stay with an eccentric spinster (Eglantine Price). The children's initial fears disappear when they find out she is in fact a trainee witch. +['Adventure', 'Fantasy', 'Comedy', 'Family', 'Music'] +vote_average: 7.0 +https://image.tmdb.org/t/p/original/3V7UFCu1u8BJLnoCdvdEqPYVaxQ.jpg +*****8***** +Doraemon: Nobita's New Great Adventure Into the Underworld - The Seven Magic Users +Nobita has changed the real world to a world of magic using the "Moshimo Box" in admiration of magic. One day, Nobita meets Chaplain Mangetsu, a magic researcher, and his daughter Miyoko. Nobita learns from them that the Great Satan of the Devildom Star is scheming to invade the Earth. The Chaplain tries to find a way out using ancient books, however, the Devildom Star rapidly approaches the Earth by the minute, causing earthquakes and abnormal weather conditions. Nobita, along with his friends, Doraemon, Shizuka, Suneo, Gaian and Dorami, together with Miyoko, storm into the Devildom Star, just like the "Legendary Seven Heroes" in an ancient book in order to confront the Great Satan and peace returns to the world of magic. +['Family', 'Adventure', 'Animation'] +vote_average: 6.9 +https://image.tmdb.org/t/p/original/4E0qUqbevK4DAW2RRbvZmjjPsOd.jpg +*****9***** +Barbie: A Perfect Christmas +Join Barbie and her sisters Skipper, Stacie and Chelsea as their holiday vacation plans turn into a most unexpected adventure and heartwarming lesson. After a snowstorm diverts their plane, the girls find themselves far from their New York destination and their holiday dreams. Now stranded at a remote inn in the tiny town of Tannenbaum, the sisters are welcomed by new friends and magical experiences. In appreciation for the wonderful hospitality they receive, they use their musical talents to put on a performance for the whole town. Barbie and her sisters realize the joy of being together is what really makes A Perfect Christmas! +['Animation', 'Family'] +vote_average: 6.7 +https://image.tmdb.org/t/p/original/u14NrsyD9h505ZXs5Ofm7Tv3AuM.jpg +*****10***** +The Many Adventures of Winnie the Pooh +Whether we’re young or forever young at heart, the Hundred Acre Wood calls to that place in each of us that still believes in magic. Join pals Pooh, Piglet, Kanga, Roo, Owl, Rabbit, Tigger and Christopher Robin as they enjoy their days together and sing their way through adventures. +['Animation', 'Family'] +vote_average: 7.2 +https://image.tmdb.org/t/p/original/2xwaFVLv5geVrFd81eUttv7OutF.jpg +*****11***** +The Gruffalo's Child +A follow up to the 2009 animated feature and adapted from the childrens' book by Julia Donaldson and Alex Scheffler. The Gruffalo's child explores the deep dark wood in search of the big bad mouse and meets the Snake, Owl and Fox in the process. She eventually finds the mouse, who manages to outwit her like the Gruffalo before! +['Adventure', 'Animation', 'Family', 'Fantasy'] +vote_average: 7.0 +https://image.tmdb.org/t/p/original/n8fu0eATvUWtmR9CsDlL1gwqTcp.jpg +*****12***** +The Tigger Movie +Winnie the Pooh, Piglet, Owl, Kanga, Roo, and Rabbit are preparing a suitable winter home for Eeyore, the perennially dejected donkey, but Tigger's continual bouncing interrupts their efforts. Rabbit suggests that Tigger go find others of his kind to bounce with, but Tigger thinks "the most wonderful thing about tiggers is" he's "the only one!" Just in case though, the joyously jouncy feline sets out to see if he can find relatives. +['Family', 'Animation', 'Comedy'] +vote_average: 6.5 +https://image.tmdb.org/t/p/original/lxuiGvLHIL1ZyePP7bn6FcKj0Mr.jpg +*****13***** +Return to Never Land +In 1940, the world is besieged by World War II. Wendy, all grown up, has two children; including Jane, who does not believe Wendy's stories about Peter Pan. +['Adventure', 'Fantasy', 'Animation', 'Family'] +vote_average: 6.4 +https://image.tmdb.org/t/p/original/zfclCksB7vCLA5Rd9HKHMGSz40.jpg +*****14***** +Winnie the Pooh: A Very Merry Pooh Year +It's Christmastime in the Hundred Acre Wood and all of the gang is getting ready with presents and decorations. The gang makes a list of what they want for Christmas and send it to Santa Claus - except that Pooh forgot to ask for something. So he heads out to retrieve the letter and get it to Santa by Christmas...which happens to be tomorrow! +['Animation', 'Family'] +vote_average: 6.8 +https://image.tmdb.org/t/p/original/1NbobWwoX7kFd1if8aCyCtFRZpu.jpg +*****15***** +Alice in Wonderland +Alice follows a white rabbit down a rabbit-hole into a whimsical Wonderland, where she meets characters like the delightful Cheshire Cat, the clumsy White Knight, a rude caterpillar, and the hot-tempered Queen of Hearts and can grow ten feet tall or shrink to three inches. But will she ever be able to return home? +['Fantasy', 'Family'] +vote_average: 6.3 +https://image.tmdb.org/t/p/original/kpXmXjqeyuSYCtNuGMytWQLdKX.jpg +*****16***** +Tarzan the Ape Man +James Parker and Harry Holt are on an expedition in Africa in search of the elephant burial grounds that will provide enough ivory to make them rich. Parker's beautiful daughter Jane arrives unexpectedly to join them. Jane is terrified when Tarzan and his ape friends abduct her, but when she returns to her father's expedition she has second thoughts about leaving Tarzan. +['Action', 'Adventure'] +vote_average: 6.8 +https://image.tmdb.org/t/p/original/sqtdNAktAI3p1iXmaEooaHjMmWd.jpg +*****17***** +Doraemon: Nobita and the Tin Labyrinth +Nobita's dad stumbled upon a strange advertisement of a fantastic resort on television at midnight. Sleepy as he was, he made a reservation even though he didn't even realize he was talking to the advertisement. The next day he discussed with the family their holiday plans, only to realize he could not find the place anywhere on earth. All of a sudden though there was a suitcase in Nobita's room and intrigued as he was, he opened it only to find a portal to a beautiful resort managed by tin robots. Better still, it's absolutely free. It seems that there is a hidden agenda behind the person who invites them there. +['Adventure', 'Animation'] +vote_average: 7.3 +https://image.tmdb.org/t/p/original/bkIR641RQyqk7hBlk0hui70dkz9.jpg +*****18***** +Casper's Haunted Christmas +Kibosh, supreme ruler of all ghosts, decrees that casper must scare at least one person before Christmas Day so Casper visits Kriss, Massachusetts where he meets the Jollimore family and sets out to complete his mission. As usual, kindhearted Casper has a ghastky time trying to scare anyone; so The Ghostly Trio, fed up with his goody-boo-shoes behavior, secretly hires Casper's look-alike cousin Spooky to do the job-with hilarious results. +['Animation', 'Family', 'Fantasy'] +vote_average: 5.4 +https://image.tmdb.org/t/p/original/3BFR30kh0O3NKR1Sfea3HXCG6hw.jpg +*****19***** +Home Alone: The Holiday Heist +8-year-old Finn is terrified to learn his family is relocating from sunny California to Maine in the scariest house he has ever seen! Convinced that his new house is haunted, Finn sets up a series of elaborate traps to catch the “ghost” in action. Left home alone with his sister while their parents are stranded across town, Finn’s traps catch a new target – a group of thieves who have targeted Finn’s house. +['Comedy', 'Family', 'TV Movie'] +vote_average: 5.3 +https://image.tmdb.org/t/p/original/6JPrRC0JPM06y17pUXD6w1xMvKi.jpg +*****20***** +The Three Caballeros +For Donald's birthday he receives a box with three gifts inside. The gifts, a movie projector, a pop-up book, and a pinata, each take Donald on wild adventures through Mexico and South America. +['Animation', 'Family', 'Music'] +vote_average: 6.4 +https://image.tmdb.org/t/p/original/nMfScRxw9wVLoO7LiEjziFAKLSK.jpg +*****21***** +The Madagascar Penguins in a Christmas Caper +During the holiday season, when the animals of the Central Park Zoo are preparing for Christmas, Private, the youngest of the penguins notices that the Polar Bear is all alone. Assured that nobody should have to spend Christmas alone, Private goes into the city for some last-minute Christmas shopping. Along the way, he gets stuffed into a stocking +['Animation', 'Comedy', 'Family'] +vote_average: 6.7 +https://image.tmdb.org/t/p/original/gOVdfrRfzQjYwezOxIap13j05d8.jpg +*****22***** +Jumanji: Welcome to the Jungle +The tables are turned as four teenagers are sucked into Jumanji's world - pitted against rhinos, black mambas and an endless variety of jungle traps and puzzles. To survive, they'll play as characters from the game. +['Adventure', 'Action', 'Comedy', 'Fantasy'] +vote_average: 6.8 +https://image.tmdb.org/t/p/original/pSgXKPU5h6U89ipF7HBYajvYt7j.jpg +*****23***** +Poltergeist +Steve Freeling lives with his wife, Diane, and their three children, Dana, Robbie, and Carol Anne, in Southern California where he sells houses for the company that built the neighborhood. It starts with just a few odd occurrences, such as broken dishes and furniture moving around by itself. However, when he realizes that something truly evil haunts his home, Steve calls in a team of parapsychologists led by Dr. Lesh to help before it's too late. +['Horror'] +vote_average: 7.1 +https://image.tmdb.org/t/p/original/xPazCcKp62IshnLVf9BLAjf9vgC.jpg +*****24***** +Up and Away +Hodja is a dreamer. He wants to experience the world, but his father insists he stays home and takes over the family's tailor shop. Fortunately, Hodja meets the old rug merchant El Faza, who gives him a flying carpet. In exchange he has to bring the old man's little granddaughter, Diamond, back to Pjort. El Faza can’t travel to the Sultan city himself, as the mighty ruler has imposed a death sentence on El Faza, on the grounds that he has stolen the Sultan's carpet. However, city life isn't quite what Hodja expected, and he only survives because of Emerald, a poor but street smart girl, who teaches him how to manage in the big world. But when Hodja loses his carpet to the power-hungry sultan, his luck seems to run out. Will he complete his mission, find El Faza's granddaughter and return safely back to Pjort? +['Animation', 'Family', 'Comedy'] +vote_average: 6.2 +https://image.tmdb.org/t/p/original/1WRK69soLEfVFRW1WwE0vWGz1mq.jpg +``` + +### instruction を用いたレコメンデーションの取得 + +任意でエージェントに instruction を与えることもできます。これにより、エージェント LLM にどのような推薦を行うべきかについて追加のコンテキストを提供できます。 + +また、初期ランク付けの上限を高めに設定し、その後エージェントランク付けでより小さなグループに絞り込むといった使い方も可能です👇 + +```python +response = agent.get_objects(persona_id, + limit=100, + use_agent_ranking=True, + instruction="""Your task is to recommend a diverse set of movies that the user may + like based on their fave genres and past interactions. Try to avoid recommending multiple films from within + the same cinematic universe.""", +) + +print(response.ranking_rationale) +for i, obj in enumerate(response.objects[:20]): + print(f"*****{i}*****") + print(obj.properties["title"]) + print(obj.properties["overview"]) + print(obj.properties["genres"]) + print(f"vote_average: {obj.properties['vote_average']}") + print(obj.properties['poster_url']) +``` + +Python 出力: +```text +We've highlighted a mix of movies from the user's favorite genres — RomCom, Adventure, Sci-Fi, and Fantasy — ensuring a diverse selection. We've also included some lesser-known gems to provide variety while avoiding multiple entries from the same cinematic universe. +*****0***** +Jumanji: Welcome to the Jungle +The tables are turned as four teenagers are sucked into Jumanji's world - pitted against rhinos, black mambas and an endless variety of jungle traps and puzzles. To survive, they'll play as characters from the game. +['Adventure', 'Action', 'Comedy', 'Fantasy'] +vote_average: 6.8 +https://image.tmdb.org/t/p/original/pSgXKPU5h6U89ipF7HBYajvYt7j.jpg +*****1***** +The Chronicles of Narnia: The Lion, the Witch and the Wardrobe +Siblings Lucy, Edmund, Susan and Peter step through a magical wardrobe and find the land of Narnia. There, they discover a charming, once peaceful kingdom that has been plunged into eternal winter by the evil White Witch, Jadis. Aided by the wise and magnificent lion, Aslan, the children lead Narnia into a spectacular, climactic battle to be free of the Witch's glacial powers forever. +['Adventure', 'Family', 'Fantasy'] +vote_average: 7.1 +https://image.tmdb.org/t/p/original/kzJip9vndXYSKQHCgekrgqbnUrA.jpg +*****2***** +Alice Through the Looking Glass +Alice Kingsleigh returns to Underland and faces a new adventure in saving the Mad Hatter. +['Adventure', 'Family', 'Fantasy'] +vote_average: 6.5 +https://image.tmdb.org/t/p/original/kbGamUkYfgKIYIrU8kW5oc0NatZ.jpg +*****3***** +Madagascar +Alex the lion is the king of the urban jungle, the main attraction at New York's Central Park Zoo. He and his best friends—Marty the zebra, Melman the giraffe and Gloria the hippo—have spent their whole lives in blissful captivity before an admiring public and with regular meals provided for them. Not content to leave well enough alone, Marty lets his curiosity get the better of him and makes his escape—with the help of some prodigious penguins—to explore the world. +['Family', 'Animation', 'Adventure', 'Comedy'] +vote_average: 6.9 +https://image.tmdb.org/t/p/original/uHkmbxb70IQhV4q94MiBe9dqVqv.jpg +*****4***** +Rio +Captured by smugglers when he was just a hatchling, a macaw named Blu never learned to fly and lives a happily domesticated life in Minnesota with his human friend, Linda. Blu is thought to be the last of his kind, but when word comes that Jewel, a lone female, lives in Rio de Janeiro, Blu and Linda go to meet her. Animal smugglers kidnap Blu and Jewel, but the pair soon escape and begin a perilous adventure back to freedom -- and Linda. +['Animation', 'Adventure', 'Comedy', 'Family'] +vote_average: 6.7 +https://image.tmdb.org/t/p/original/oo7M77GXEyyqDGOhzNNZTzEuDSF.jpg +*****5***** +Alice in Wonderland +Alice, now 19 years old, returns to the whimsical world she first entered as a child and embarks on a journey to discover her true destiny. +['Family', 'Fantasy', 'Adventure'] +vote_average: 6.6 +https://image.tmdb.org/t/p/original/o0kre9wRCZz3jjSjaru7QU0UtFz.jpg +*****6***** +Peter Pan +Leaving the safety of their nursery behind, Wendy, Michael and John follow Peter Pan to a magical world where childhood lasts forever. But while in Neverland, the kids must face Captain Hook and foil his attempts to get rid of Peter for good. +['Animation', 'Family', 'Adventure', 'Fantasy'] +vote_average: 7.2 +https://image.tmdb.org/t/p/original/fJJOs1iyrhKfZceANxoPxPwNGF1.jpg +*****7***** +Titanic +101-year-old Rose DeWitt Bukater tells the story of her life aboard the Titanic, 84 years later. A young Rose boards the ship with her mother and fiancé. Meanwhile, Jack Dawson and Fabrizio De Rossi win third-class tickets aboard the ship. Rose tells the whole story from Titanic's departure through to its death—on its first and last voyage—on April 15, 1912. +['Drama', 'Romance'] +vote_average: 7.9 +https://image.tmdb.org/t/p/original/9xjZS2rlVxm8SFx8kPC3aIGCOYQ.jpg +*****8***** +The Nutcracker and the Four Realms +When Clara’s mother leaves her a mysterious gift, she embarks on a journey to four secret realms—where she discovers her greatest strength could change the world. +['Fantasy', 'Adventure', 'Family'] +vote_average: 6.1 +https://image.tmdb.org/t/p/original/9vPDY8e7YxLwgVum7YZIUJbr4qc.jpg +*****9***** +Pete's Dragon +For years, old wood carver Mr. Meacham has delighted local children with his tales of the fierce dragon that resides deep in the woods of the Pacific Northwest. To his daughter, Grace, who works as a forest ranger, these stories are little more than tall tales... until she meets Pete, a mysterious 10-year-old with no family and no home who claims to live in the woods with a giant, green dragon named Elliott. And from Pete's descriptions, Elliott seems remarkably similar to the dragon from Mr. Meacham's stories. With the help of Natalie, an 11-year-old girl whose father Jack owns the local lumber mill, Grace sets out to determine where Pete came from, where he belongs, and the truth about this dragon. +['Adventure', 'Family', 'Fantasy'] +vote_average: 6.4 +https://image.tmdb.org/t/p/original/6TwrPngfpbwtVH6UsDfVNUnn3ms.jpg +*****10***** +The Chronicles of Narnia: Prince Caspian +One year after their incredible adventures in the Lion, the Witch and the Wardrobe, Peter, Edmund, Lucy and Susan Pevensie return to Narnia to aid a young prince whose life has been threatened by the evil King Miraz. Now, with the help of a colorful cast of new characters, including Trufflehunter the badger and Nikabrik the dwarf, the Pevensie clan embarks on an incredible quest to ensure that Narnia is returned to its rightful heir. +['Adventure', 'Family', 'Fantasy'] +vote_average: 6.6 +https://image.tmdb.org/t/p/original/qxz3WIyjZiSKUhaTIEJ3c1GcC9z.jpg +*****11***** +One Piece: Chopper's Kingdom on the Island of Strange Animals +As the Straw Hat Pirates sail through the Grand Line.A line of geysers erupted from under the Going Merry. And the whole crew find themselves flying over the island. Unfortunatly, Chopper fell off the ship and was separated from his friends. Luffy and the others landed on the other side of the island. Chopper meanwhile finds himself being worshiped as the island's new king by the animals. To make matters worse, a trio of human "horn" hunters are on the island. The leader, Count Butler is a violin playing/horn eating human who wants to eat the island's treasure to inherit immense power. Will Luffy & the rest be able to prevent the count from terrorizing the island? And will they be able to convince Momambi that not all pirates are bad? +['Action', 'Animation', 'Adventure'] +vote_average: 6.6 +https://image.tmdb.org/t/p/original/8uzFccR8F3h7tC9zfIOT063r91N.jpg +*****12***** +The Ewok Adventure +The Towani family civilian shuttlecraft crashes on the forest moon of Endor. The four Towani's are separated. Jermitt and Catarine, the mother and father are captured by the giant Gorax, and Mace and Cindel, the son and daughter, are missing when they are captured. The next day, the Ewok Deej is looking for his two sons when they find Cindel all alone in the shuttle (Mace and Cindel were looking for the transmitter to send a distress call), when Mace appears with his emergency blaster. Eventually, the four-year old Cindel is able to convince the teenage Mace that the Ewoks are nice. Then, the Ewoks and the Towani's go on an adventure to find the elder Towanis. +['Adventure', 'Family', 'Fantasy', 'Science Fiction', 'TV Movie'] +vote_average: 6.0 +https://image.tmdb.org/t/p/original/lP7FIxojVrgWsam9efElk5ba3I5.jpg +*****13***** +Doraemon: Nobita and the Tin Labyrinth +Nobita's dad stumbled upon a strange advertisement of a fantastic resort on television at midnight. Sleepy as he was, he made a reservation even though he didn't even realize he was talking to the advertisement. The next day he discussed with the family their holiday plans, only to realize he could not find the place anywhere on earth. All of a sudden though there was a suitcase in Nobita's room and intrigued as he was, he opened it only to find a portal to a beautiful resort managed by tin robots. Better still, it's absolutely free. It seems that there is a hidden agenda behind the person who invites them there. +['Adventure', 'Animation'] +vote_average: 7.3 +https://image.tmdb.org/t/p/original/bkIR641RQyqk7hBlk0hui70dkz9.jpg +*****14***** +Barbie & Her Sisters in the Great Puppy Adventure +Barbie and her sisters, Skipper, Stacie and Chelsea, and their adorable new puppy friends find unexpected mystery and adventure when they return to their hometown of Willows. While going through mementos in Grandma's attic, the sisters discover an old map, believed to lead to a long-lost treasure buried somewhere in the town. With their puppy pals in tow, the four girls go on an exciting treasure hunt, along the way discovering that the greatest treasure of all is the love and laughter they share as sisters! +['Family', 'Animation', 'Adventure'] +vote_average: 7.3 +https://image.tmdb.org/t/p/original/3ybjPWweUjPXXqIXFERgPnOQ5O3.jpg +*****15***** +Tinker Bell and the Lost Treasure +A blue harvest moon will rise, allowing the fairies to use a precious moonstone to restore the Pixie Dust Tree, the source of all their magic. But when Tinker Bell accidentally puts all of Pixie Hollow in jeopardy, she must venture out across the sea on a secret quest to set things right. +['Animation', 'Family', 'Adventure', 'Fantasy'] +vote_average: 6.7 +https://image.tmdb.org/t/p/original/hg1959yuBkHb4BKbIvETQSfxGCT.jpg +*****16***** +Barbie and the Diamond Castle +Liana and Alexa (Barbie and Teresa) are best friends who share everything, including their love of singing. One day while walking through the forest home from the village, the girls meet an old beggar who gives them a magical mirror. As they clean the mirror and sing, a musical apprentice muse named Melody appears in the mirror's surface, and tells the girls about the secret of the Diamond Castle. +['Animation', 'Family'] +vote_average: 7.4 +https://image.tmdb.org/t/p/original/dvjFM3GgYm3gDZ6Ulw0JurDYs4r.jpg +*****17***** +Doraemon: New Nobita's Great Demon – Peko and the Exploration Party of Five +The film starts with Gian seeing some like spirit and it asks him to accomplish a task. The story starts when a stray dogs are searching some foods in the can. Then a dirty white dog comes out of nowhere. Just then, the dog creates a close stare to the stray dogs and forces to run away. But the dog is disappointed that he doesn't know what to do after searching the garbage, under the pouring rain. After that, Suneo starts saying about the discoverable places on Earth and him and Gian are totally disappointed about that. That then, they are asking favor to Nobita to take them to an undiscovered place to be seen by their naked eyes. Nobita refuses but tells he will try his best. He comes to upstairs to explain Doraemon what the problem is now. +['Family', 'Animation', 'Adventure'] +vote_average: 7.0 +https://image.tmdb.org/t/p/original/1XxnaUvLuAlfSWEqravAfSiCaFj.jpg +*****18***** +The Wolf and the Lion +After her grandfather's death, 20-year-old Alma decides to go back to her childhood home - a little island in the heart of the majestic Canadian forest. Whilst there, she rescues two helpless cubs: a wolf and a lion. They forge an inseparable bond, but their world soon collapses as the forest ranger discovers the animals and takes them away. The two cub brothers must now embark on a treacherous journey across Canada to be reunited with one another and Alma once more. +['Adventure', 'Family'] +vote_average: 7.2 +https://image.tmdb.org/t/p/original/aSRvK4kLJORBrVdlFn2wrGx8XPv.jpg +*****19***** +Tinker Bell and the Legend of the NeverBeast +An ancient myth of a massive creature sparks the curiosity of Tinker Bell and her good friend Fawn, an animal fairy who’s not afraid to break the rules to help an animal in need. But this creature is not welcome in Pixie Hollow — and the scout fairies are determined to capture the mysterious beast, who they fear will destroy their home. Fawn must convince her fairy friends to risk everything to rescue the NeverBeast. +['Adventure', 'Animation', 'Family'] +vote_average: 7.1 +https://image.tmdb.org/t/p/original/bUGX7duQWSm04yAA1rBBfNRe4kY.jpg +``` + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/personalization-agent-get-started-recipes.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/personalization-agent-get-started-recipes.md new file mode 100644 index 000000000..fd5874f79 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/personalization-agent-get-started-recipes.md @@ -0,0 +1,419 @@ +--- +layout: recipe +colab: https://colab.research.google.com/github/weaviate/recipes/blob/main/weaviate-services/agents/personalization-agent-get-started-recipes.ipynb +toc: True +title: "Weaviate パーソナライズ エージェントの構築 - フードレコメンダー" +featured: False +integration: False +agent: True +tags: ['Personalization Agent'] +--- + + Open In Google Colab + + +このレシピでは、Weaviate の新しい `PersonalizationAgent` を使用し、ユーザーごとにパーソナライズされた方法で Weaviate コレクションからオブジェクトを取得します。この新しいエージェント方式の取得は、ユーザーのペルソナ プロファイルとこれまでのコレクションとのやり取りに基づいて行われます。 + +> 📚 `PersonalizationAgent` の使い方の詳細は、弊社ブログ「[Introducing the Weaviate Personalization Agent](https://weaviate.io/blog/personalization-agent?utm_source=recipe&utm_campaign=agents)」および[ドキュメント](https://docs.weaviate.io/agents/personalization)をご覧ください。 + +すぐに試せるように、Hugging Face datasets 🤗 にいくつかのデモデータセットを用意しました。 +- [Recipes](https://huggingface.co/datasets/weaviate/agents/viewer/personalization-agent-recipes): 料理名、短い説明、料理の種類を含むデータセット +- [Movies](https://huggingface.co/datasets/weaviate/agents/viewer/personalization-agent-movies): 映画、評価、オリジナル言語などを含むデータセット + +本例では、Recipes データセットを使用してフード レコメンダー サービスを作成します。 + +```python +!pip install 'weaviate-client[agents]' datasets +``` + +## Weaviate のセットアップとデータのインポート + +Weaviate Personalization Agent を使うには、まず [Weaviate Cloud](tps://weaviate.io/deployment/serverless?utm_source=recipe&utm_campaign=agents) アカウントを作成してください👇 +1. [Serverless Weaviate Cloud アカウント](https://weaviate.io/deployment/serverless?utm_source=recipe&utm_campaign=agents)を作成し、無料の [Sandbox](https://docs.weaviate.io/cloud/manage-clusters/create#sandbox-clusters?utm_source=recipe&utm_campaign=agents) をセットアップします +2. 「Embedding」に移動して有効化します。デフォルトでは `Snowflake/snowflake-arctic-embed-l-v2.0` が埋め込みモデルとして使用されます +3. クラスターに接続するため `WEAVIATE_URL` と `WEAVIATE_API_KEY` を控えておきます + +> Info: 外部埋め込みプロバイダー用の追加キーを用意する必要がないため、[Weaviate Embeddings](https://docs.weaviate.io/weaviate/model-providers/weaviate) の使用を推奨します。 + +```python +import os + +import weaviate +from weaviate.auth import Auth +from getpass import getpass + +if "WEAVIATE_API_KEY" not in os.environ: + os.environ["WEAVIATE_API_KEY"] = getpass("Weaviate API Key") +if "WEAVIATE_URL" not in os.environ: + os.environ["WEAVIATE_URL"] = getpass("Weaviate URL") + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=Auth.api_key(os.environ.get("WEAVIATE_API_KEY")), +) +``` + +### 新しいコレクションの作成 + +次に、Weaviate に "Recipes" という名前の新しいコレクションを作成します。Weaviate のエージェントサービスでは、コレクション内プロパティの説明を含めることが推奨されます。これらの説明はエージェントによって利用されます。 + +```python +from weaviate.classes.config import Configure, DataType, Property + +# if client.collections.exists("Recipes"): +# client.collections.delete("Recipes") + +client.collections.create( + "Recipes", + description="A dataset that lists recipes with titles, desctiptions, and labels indicating cuisine", + vector_config=Configure.Vectors.text2vec_weaviate(), + properties=[ + Property( + name="title", data_type=DataType.TEXT, description="title of the recipe" + ), + Property( + name="labels", + data_type=DataType.TEXT, + description="the cuisine the recipe belongs to", + ), + Property( + name="description", + data_type=DataType.TEXT, + description="short description of the recipe", + ), + ], +) +``` + +```python +from datasets import load_dataset + +dataset = load_dataset("weaviate/agents", "personalization-agent-recipes", split="train", streaming=True) + +recipes_collection = client.collections.use("Recipes") + +with recipes_collection.batch.dynamic() as batch: + for item in dataset: + batch.add_object(properties=item["properties"]) + +``` + +## パーソナライズ エージェントの作成 + +以下では `"Recipes"` コレクションの `PersonalizationAgent` を作成します。すでにこのコレクション用のエージェントが存在する場合は、単に接続するだけです。 + +新しく `PersonalizationAgent` を作成する際、任意で `user_properties` を定義できます。 + +ユーザープロパティは、エージェントに追加されるユーザーに関する有用な情報なら何でも構いません。今回はフード レコメンダー サービスを作成するため、各ペルソナに `favorite_cuisines`、`likes`、`dislikes` を追加することにします。 + +```python +from weaviate.agents.personalization import PersonalizationAgent + +if PersonalizationAgent.exists(client, "Recipes"): + agent = PersonalizationAgent.connect( + client=client, + reference_collection="Recipes", + ) +else: + agent = PersonalizationAgent.create( + client=client, + reference_collection="Recipes", + user_properties={ + "favorite_cuisines": DataType.TEXT_ARRAY, + "likes": DataType.TEXT_ARRAY, + "dislikes": DataType.TEXT_ARRAY + }, + ) + +``` + +### 新規ペルソナの追加 + +`add_persona` を使って新しいユーザーを追加でき、その際に先ほど定義したユーザープロパティを指定します。お好みで下のコードブロックを自身の情報に変更して試してみてください👇 + +```python +from uuid import uuid4 +from weaviate.agents.classes import Persona, PersonaInteraction + +persona_id = uuid4() +agent.add_persona( + Persona( + persona_id=persona_id, + properties={ + "favorite_cuisines": ["Italian", "Thai"], + "likes": ["chocolate", "salmon", "pasta", "most veggies"], + "dislikes": ["okra", "mushroom"], + }, + ) +) +``` + +```python +agent.get_persona(persona_id) + +``` + +Python output: +```text +Persona(persona_id=UUID('df987437-4d10-44d6-b613-dfff31f715fb'), properties={'favorite_cuisines': ['Italian', 'Thai'], 'dislikes': ['okra', 'mushroom'], 'allergies': None, 'likes': ['chocolate', 'salmon', 'pasta', 'most veggies']}) +``` + +### インタラクションの追加 + +少なくとも 1 つのペルソナを作成したら、そのペルソナに対するインタラクションを追加できます。フード レコメンダー サービスの場合、ペルソナの食事レビューを追加するのが理にかなっています。 + +各インタラクションには -1.0(ネガティブ)から 1.0(ポジティブ)までの重みを設定できます。以下では、いくつかの料理に対するレビューを追加してみましょう。 + +どのようなエンドアプリケーションがこれらのインタラクションを送信するか、また各重みが何を表すのかをルール化しておくと良いでしょう。例えばレシピサイトを想定すると: +- 1.0: お気に入りの料理 +- 0.8: 料理を気に入った +- 0.5: レシピページを閲覧した +- -0.5: 料理が好みではない +- -1.0: 料理を完全に嫌った 👎 + +```python +from uuid import UUID +from weaviate.collections.classes.filters import Filter + +reviewed_foods = [ + "Coq au Vin", + "Chicken Tikka Masala", + "Gnocchi alla Sorrentina", + "Matcha Ice Cream", + "Fiorentina Steak", + "Nabe", + "Duck Confit", + "Pappardelle with Porcini" +] + +reviews_dict = { + recipe.properties["title"]: recipe + for recipe in recipes_collection.query.fetch_objects( + filters=Filter.by_property("title").contains_any(reviewed_foods), limit=20 + ).objects +} + +interactions = [ + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Coq au Vin"].uuid, weight=0.8 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Chicken Tikka Masala"].uuid, weight=0.8 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Matcha Ice Cream"].uuid, weight=0.8 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Gnocchi alla Sorrentina"].uuid, weight=0.5 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Fiorentina Steak"].uuid, weight=0.8 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Nabe"].uuid, weight=0.5 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Duck Confit"].uuid, weight=1.0 + ), + PersonaInteraction( + persona_id=persona_id, item_id=reviews_dict["Pappardelle with Porcini"].uuid, weight=-1.0 + ), + +] +``` + +```python +agent.add_interactions(interactions=interactions) +``` + +## レコメンデーションと根拠の取得 + +ペルソナとそのインタラクションを用意できたので、`get_objects` でエージェントからオブジェクトを推薦してもらいましょう。ここでは `use_agent_ranking` を設定するかどうかの 2 通りがあります。 + +`use_agent_ranking` を使用しない場合、返却されたオブジェクトは従来の機械学習クラスタリングでランク付けされます。一方、使用する場合は、LLM による追加の再ランキングが行われ、任意の `instruction` も渡せます。 + +エージェント ランキングを使用すると、下記のように `ranking_rationale` でランキングの根拠も確認できます👇 + +```python +response = agent.get_objects(persona_id, limit=25, use_agent_ranking=True) + +print(response.ranking_rationale) +for i, obj in enumerate(response.objects): + print(f"*****{i}*****") + print(obj.properties["title"]) + print(obj.properties["description"]) + print(obj.properties["labels"]) +``` + +Python output: +```text +Based on your love for Italian cuisine and positive interactions with dishes like Gnocchi alla Sorrentina and Fiorentina Steak, Italian dishes like Frittata di Zucca e Pancetta and Classic Italian Margherita Pizza are highlighted. Your fondness for Chicken Tikka Masala also brought Indian dishes such as Spicy Indian Tikka Masala forward. Although you enjoyed Coq au Vin, the included mushrooms might not be to your liking, which is reflected in a balanced way within French dishes. +*****0***** +Frittata di Zucca e Pancetta +A fluffy egg omelette with sweet potatoes and pancetta, seasoned with herbs and grated cheese, a beloved dish from the heart of Italy. +Italian +*****1***** +Pizza Margherita +A simple yet iconic pizza with San Marzano tomatoes, mozzarella di bufala, fresh basil, and extra-virgin olive oil, encapsulating the Neapolitan pizza tradition. +Italian +*****2***** +Lasagna alla Bolognese +Layers of pasta sheets, Bolognese sauce, and béchamel, all baked to golden perfection, embodying the comforting flavors of Emilia-Romagna. +Italian +*****3***** +Lasagna alla Bolognese +Layers of flat pasta sheets, rich Bolognese sauce, and béchamel, baked to perfection. +Italian +*****4***** +Spicy Indian Tikka Masala +A rich tomato and cream sauce with chunks of chicken, covered in a fiery blend of spices and charred chunks of chicken. +Indian +*****5***** +Classic Italian Margherita Pizza +Thin crust pizza topped with San Marzano tomatoes, fresh mozzarella, basil, and extra-virgin olive oil, representing the simplicity of Italian cuisine. +Italian +*****6***** +Chicken Tikka Masala +Marinated chicken drumsticks grilled on a spit and then simmered in a spicy tomato sauce with cream, a popular dish in Indian cuisine. +Indian +*****7***** +Butter Chicken +A creamy and aromatic tomato sauce with tender chunks of chicken, marinated in a blend of spices and cooked with yogurt and cream, often served with rice or naan bread. +Indian +*****8***** +French Coq au Vin +A hearty stew of chicken braised with wine, mushrooms, and garlic, capturing the essence of French country cooking. +French +*****9***** +Sicilian Arancini +Deep-fried balls of risotto mixed with cheese and peas, coated with breadcrumbs and Parmesan cheese. +Italian +*****10***** +Ramen +A noodle soup dish with Chinese influences, typically containing Chinese-style noodles served in a meat or fish-based broth, often flavored with soy sauce or miso, and uses toppings such as sliced pork, green onions, and nori. +Japanese +*****11***** +Oden +A hearty Japanese hotpot dish made with simmered fish cakes, tofu, konnyaku, and vegetables, in a dashi-based broth. +Japanese +*****12***** +Shabu-Shabu +A Japanese hot pot dish where thinly sliced meat and vegetables are cooked in boiling water at the table. +Japanese +*****13***** +Tempura +A Japanese dish usually made with seafood, vegetables, and sometimes meat, battered and deep-fried until crisp. +Japanese +*****14***** +Oden +A Japanese stew containing fish cakes, daikon radish, konnyaku, tofu, and boiled eggs, typically flavored with miso or dashi broth. +Japanese +*****15***** +Tandoori Chicken +Marinated in yogurt and spices, then cooked in a tandoor (clay oven), resulting in a tangy and spicy chicken dish. +Indian +*****16***** +Beef Bourguignon +A flavorful beef stew cooked slowly in red wine, beef broth, and a bouquet garni, with carrots, onions, and mushrooms, typically served with potatoes or noodles. +French +*****17***** +Pizza Margherita +Simple pizza with San Marzano tomatoes, fresh mozzarella, basil, and extra-virgin olive oil, reflecting the colors of the Italian flag. +Italian +*****18***** +Butter Chicken +Soft and tender pieces of chicken in a rich and creamy sauce made with butter, tomatoes, and a blend of Indian spices. +Indian +*****19***** +Chicken Biryani +A flavorful rice dish cooked with basmati rice, chicken, and a mix of aromatic spices such as cardamom, cinnamon, and cloves, layered with meat and vegetables. +Indian +*****20***** +Milanesa a la Napolitana +A breaded cutlet, typically veal, topped with melted cheese and tomato sauce, a popular street food item. +Argentinian +*****21***** +Tempura Udon +Thick udon noodles served with crispy tempura shrimp and vegetables, lightly coated in a dashi-based sauce for a delicate taste. +Japanese +*****22***** +Miso Soup +A traditional Japanese soup consisting of a stock called dashi into which softened miso paste is mixed, often with pieces of tofu and seaweed. +Japanese +*****23***** +Udon Noodles +A type of thick wheat flour noodle common in Japanese cuisine, served hot or cold with a dipping sauce. +Japanese +*****24***** +Pappardelle with Porcini +Thick wide ribbons of pasta served with a creamy porcini mushroom sauce and grated Parmesan cheese. +Italian +``` + +### instructions 付きレコメンデーションの取得 + +オプションとして、エージェントに instruction を与えることもできます。これにより、エージェント LLM がどのような推薦を行うべきかについて、より多くの文脈を得られます。 + +また、初期ランキングの件数を多めに設定し、その後エージェント ランキングで絞り込むと良い場合もあります。以下ではその例を示します👇 + +```python +response = agent.get_objects(persona_id, + limit=50, + use_agent_ranking=True, + instruction="""Your task is to recommend a diverse set of dishes to the user + taking into account their likes and dislikes. It's especially important to avoid their dislikes.""", +) + +print(response.ranking_rationale) +for i, obj in enumerate(response.objects[:10]): + print(f"*****{i}*****") + print(obj.properties["title"]) + print(obj.properties["description"]) + print(obj.properties["labels"]) +``` + +Python output: +```text +As you love Italian cuisine and have a special liking for foods like pasta and salmon, while disliking mushrooms, we've focused on offering you a variety of Italian and other delightful dishes without mushroom content. We've also incorporated a touch of diversity with dishes from other cuisines you enjoy, while carefully avoiding those with ingredients you dislike. +*****0***** +Chicken Tikka Masala +Marinated chicken drumsticks grilled on a spit and then simmered in a spicy tomato sauce with cream, a popular dish in Indian cuisine. +Indian +*****1***** +Pasta alla Norma +Pasta served with fried eggplant, tomato sauce, and ricotta salata, a flavorful dish that showcases the vibrant flavors of Sicilian cuisine. +Italian +*****2***** +Classic Italian Margherita Pizza +Thin crust pizza topped with San Marzano tomatoes, fresh mozzarella, basil, and extra-virgin olive oil, representing the simplicity of Italian cuisine. +Italian +*****3***** +Pizza Margherita +Simple pizza with San Marzano tomatoes, fresh mozzarella, basil, and extra-virgin olive oil, reflecting the colors of the Italian flag. +Italian +*****4***** +Spicy Indian Tikka Masala +A rich tomato and cream sauce with chunks of chicken, covered in a fiery blend of spices and charred chunks of chicken. +Indian +*****5***** +Lasagna alla Bolognese +Layers of flat pasta sheets, rich Bolognese sauce, and béchamel, baked to perfection. +Italian +*****6***** +Fettuccine Alfredo +Creamy pasta dish made with fettuccine pasta tossed in a rich sauce of butter, heavy cream, and Parmesan cheese. +Italian +*****7***** +Sicilian Arancini +Deep-fried balls of risotto mixed with cheese and peas, coated with breadcrumbs and Parmesan cheese. +Italian +*****8***** +Frittata di Zucca e Pancetta +A fluffy egg omelette with sweet potatoes and pancetta, seasoned with herbs and grated cheese, a beloved dish from the heart of Italy. +Italian +*****9***** +Paneer Tikka +Small cubes of paneer marinated in spices and yogurt, then grilled and served in a spicy tomato sauce. +Indian +``` + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/query-agent-get-started.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/query-agent-get-started.md new file mode 100644 index 000000000..76477165c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/query-agent-get-started.md @@ -0,0 +1,586 @@ +--- +layout: recipe +colab: https://colab.research.google.com/github/weaviate/recipes/blob/main/weaviate-services/agents/query-agent-get-started.ipynb +toc: True +title: "Weaviate Query Agent を構築する – E コマースアシスタント" +featured: True +integration: False +agent: True +tags: ['Query Agent'] +--- + + Open In Google Colab + + +このレシピでは、[Weaviate Query Agent](https://docs.weaviate.io/agents) を使ってシンプルな E コマースアシスタント エージェントを構築します。エージェントは複数の Weaviate コレクションへアクセスでき、各コレクションの情報を利用してブランドや衣類アイテムに関する複雑な質問に回答します。 + +> 📚 本サービスの詳細はブログ「[Introducing the Weaviate Query Agent](https://weaviate.io/blog/query-agent)」をご覧ください。 + +まず、Hugging Face で公開されているオープンデータセットを用意しています。最初のステップとして、Weaviate Cloud のコレクションにデータを投入する方法を説明します。 + +- [**E-commerce**](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-ecommerce): 衣類アイテム、価格、ブランド、レビューなどを含むデータセット +- [**Brands**](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-brands): 親ブランド・子ブランド、平均カスタマーレーティングなどブランド情報を含むデータセット + +加えて、今回のレシピ内で他のエージェントに機能や多様性を持たせる際に使用できる、無関係なデータセットも用意しています。 + +- [**Financial Contracts**](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-financial-contracts): 個人または企業間の金融契約、契約タイプや作成者情報を含むデータセット +- [**Weather**](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-weather): 気温、風速、降水量、気圧などの日次気象情報 + +## 1. Weaviate のセットアップとデータのインポート + +Weaviate Query Agent を使用するには、まず [Weaviate Cloud](https://weaviate.io/deployment/serverless) アカウントを作成します👇 +1. [Serverless Weaviate Cloud アカウントを作成](https://weaviate.io/deployment/serverless)し、無料の [Sandbox](https://docs.weaviate.io/cloud/manage-clusters/create#sandbox-clusters) をセットアップ +2. 「Embedding」セクションで有効化します。デフォルトでは `Snowflake/snowflake-arctic-embed-l-v2.0` が埋め込みモデルとして使用されます。 +3. クラスター接続用に `WEAVIATE_URL` と `WEAVIATE_API_KEY` を控えておきます。 + +> Info: 外部埋め込みプロバイダーのキーを追加する必要がないため、[Weaviate Embeddings](https://docs.weaviate.io/weaviate/model-providers/weaviate) の利用を推奨します。 + +```python +!pip install weaviate-client[agents] datasets +``` + +```python +import os +from getpass import getpass + +if "WEAVIATE_API_KEY" not in os.environ: + os.environ["WEAVIATE_API_KEY"] = getpass("Weaviate API Key") +if "WEAVIATE_URL" not in os.environ: + os.environ["WEAVIATE_URL"] = getpass("Weaviate URL") +``` + +```python +import weaviate +from weaviate.auth import Auth + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=Auth.api_key(os.environ.get("WEAVIATE_API_KEY")), +) +``` + +### コレクションの準備 + +以下のコードでは、デモデータセットを Hugging Face から取得し、Weaviate Serverless クラスターに新しいコレクションとして書き込みます。 + +> ❗️ `QueryAgent` は、クエリを解決する際に使用するコレクションやプロパティを決定するため、またプロパティの詳細情報にアクセスするために、コレクションおよびプロパティの説明を利用します。説明を変更したり、詳細を追加したりといった実験を行うと良いでしょう。例えば下記では、価格がすべて USD であることを `QueryAgent` に伝えています。これは説明がなければ得られない情報です。 + +```python +from weaviate.classes.config import Configure, Property, DataType + +# To re-run cell you may have to delete collections +# client.collections.delete("Brands") +client.collections.create( + "Brands", + description="A dataset that lists information about clothing brands, their parent companies, average rating and more.", + vector_config=Configure.Vectors.text2vec_weaviate() +) + +# client.collections.delete("Ecommerce") +client.collections.create( + "Ecommerce", + description="A dataset that lists clothing items, their brands, prices, and more.", + vector_config=Configure.Vectors.text2vec_weaviate(), + properties=[ + Property(name="collection", data_type=DataType.TEXT), + Property(name="category", data_type=DataType.TEXT), + Property(name="tags", data_type=DataType.TEXT_ARRAY), + Property(name="subcategory", data_type=DataType.TEXT), + Property(name="name", data_type=DataType.TEXT), + Property(name="description", data_type=DataType.TEXT), + Property(name="brand", data_type=DataType.TEXT), + Property(name="product_id", data_type=DataType.UUID), + Property(name="colors", data_type=DataType.TEXT_ARRAY), + Property(name="reviews", data_type=DataType.TEXT_ARRAY), + Property(name="image_url", data_type=DataType.TEXT), + Property(name="price", data_type=DataType.NUMBER, description="price of item in USD"), + ] +) + +# client.collections.delete("Weather") +client.collections.create( + "Weather", + description="Daily weather information including temperature, wind speed, percipitation, pressure etc.", + vector_config=Configure.Vectors.text2vec_weaviate(), + properties=[ + Property(name="date", data_type=DataType.DATE), + Property(name="humidity", data_type=DataType.NUMBER), + Property(name="precipitation", data_type=DataType.NUMBER), + Property(name="wind_speed", data_type=DataType.NUMBER), + Property(name="visibility", data_type=DataType.NUMBER), + Property(name="pressure", data_type=DataType.NUMBER), + Property(name="temperature", data_type=DataType.NUMBER, description="temperature value in Celsius") + ] +) + +# client.collections.delete("Financial_contracts") +client.collections.create( + "Financial_contracts", + description="A dataset of financial contracts between indivicuals and/or companies, as well as information on the type of contract and who has authored them.", + vector_config=Configure.Vectors.text2vec_weaviate(), +) +``` + +```python +from datasets import load_dataset + +brands_dataset = load_dataset("weaviate/agents", "query-agent-brands", split="train", streaming=True) +ecommerce_dataset = load_dataset("weaviate/agents", "query-agent-ecommerce", split="train", streaming=True) +weather_dataset = load_dataset("weaviate/agents", "query-agent-weather", split="train", streaming=True) +financial_dataset = load_dataset("weaviate/agents", "query-agent-financial-contracts", split="train", streaming=True) + +brands_collection = client.collections.use("Brands") +ecommerce_collection = client.collections.use("Ecommerce") +weather_collection = client.collections.use("Weather") +financial_collection = client.collections.use("Financial_contracts") + +with brands_collection.batch.dynamic() as batch: + for item in brands_dataset: + batch.add_object(properties=item["properties"]) + +with ecommerce_collection.batch.dynamic() as batch: + for item in ecommerce_dataset: + batch.add_object(properties=item["properties"]) + +with weather_collection.batch.dynamic() as batch: + for item in weather_dataset: + batch.add_object(properties=item["properties"]) + +with financial_collection.batch.dynamic() as batch: + for item in financial_dataset: + batch.add_object(properties=item["properties"]) +``` + +## 2. Query Agent のセットアップ + +Query Agent を設定する際には、以下を渡す必要があります。 +- `client` +- エージェントにアクセスさせたい `collection` +- (オプション)エージェントの振る舞いを説明する `system_prompt` +- (オプション)タイムアウト(デフォルトは 60 秒) + +まずはシンプルなエージェントを作成しましょう。ここでは `Brands` と `Ecommerce` の両データセットにアクセスできる `agent` を作成しています。 + +```python +from weaviate.agents.query import QueryAgent + +agent = QueryAgent( + client=client, collections=["Ecommerce", "Brands"], +) +``` + +## 3. Query Agent を実行する + +エージェントを実行すると、クエリに応じて以下の判断を行います。 + +1. どのコレクションを参照するか +2. 通常の ***検索クエリ***、使用する ***フィルター***、***集約クエリ*** を行うかどうか、またはそれらを組み合わせるか +3. その後、**`QueryAgentResponse`** 内で応答を返します。`print_query_agent_response` 関数を用いて、レスポンスオブジェクトに含まれる各情報をわかりやすく表示します。 + +### 質問してみる +**まずはシンプルな質問から始めましょう: 「ヴィンテージの服が好きです。200ドル未満のアイテムをいくつか教えてくれますか?」** + +エージェントがどのように回答し、どのコレクションでどのような検索を行ったか、最終回答に不足情報があるかどうかなどを確認できます👇 + +```python +from weaviate.agents.utils import print_query_agent_response + +response = agent.run("I like the vintage clothes, can you list me some options that are less than $200?") +print_query_agent_response(response) +``` + +
╭─────────────────────────────────────────────── 🔍 Original Query ───────────────────────────────────────────────╮
+│                                                                                                                 │
+│ I like the vintage clothes, can you list me some options that are less than $200?                               │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭──────────────────────────────────────────────── 📝 Final Answer ────────────────────────────────────────────────╮
+│                                                                                                                 │
+│ If you are looking for vintage clothing options under $200, here are some great choices:                        │
+│                                                                                                                 │
+│ 1. **Vintage Philosopher Midi Dress** - Priced at $125, this dress from Echo & Stitch embraces a classic        │
+│ scholarly look with its deep green velvet fabric and antique gold detailing. It's tailored for elegance and is  │
+│ ideal for sophisticated occasions.                                                                              │
+│                                                                                                                 │
+│ 2. **Vintage Gale Pleated Dress** - This $120 dress from Solemn Chic features deep burgundy pleats and          │
+│ vintage-inspired sleeve details, perfect for a timeless scholarly appearance.                                   │
+│                                                                                                                 │
+│ 3. **Retro Groove Flared Pants** - For $59, these electric blue flared pants from Vivid Verse bring back the    │
+│ playful spirit of the early 2000s with a modern touch.                                                          │
+│                                                                                                                 │
+│ 4. **Vintage Scholar Tote** - At $90, this tote from Echo & Stitch combines functionality and elegance, ideal   │
+│ for everyday use, especially if you enjoy a scholarly aesthetic.                                                │
+│                                                                                                                 │
+│ 5. **Electric Velvet Trousers** - Priced at $60, these neon green velvet trousers from Vivid Verse offer a fun, │
+│ throwback vibe to early Y2K fashion.                                                                            │
+│                                                                                                                 │
+│ 6. **Victorian Velvet Jumpsuit** - For $120, this jumpsuit from Solemn Chic offers an elegant blend of romance  │
+│ and scholarly charm, suited for library visits or cultured gatherings.                                          │
+│                                                                                                                 │
+│ 7. **Vintage Scholar Turtleneck** - This $55 turtleneck from Echo & Stitch suits the Dark Academia vibe,        │
+│ perfect for layering or wearing alone.                                                                          │
+│                                                                                                                 │
+│ 8. **Vintage Ivy Loafers** - These $120 loafers from Solemn Chic offer timeless sophistication, with a deep     │
+│ burgundy finish that complements any vintage wardrobe.                                                          │
+│                                                                                                                 │
+│ These options cater to various preferences, from dresses and jumpsuits to pants and accessories, all capturing  │
+│ the vintage essence at an affordable price.                                                                     │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭─────────────────────────────────────────── 🔭 Searches Executed 1/1 ────────────────────────────────────────────╮
+│                                                                                                                 │
+│ QueryResultWithCollection(                                                                                      │
+│     queries=['vintage clothes'],                                                                                │
+│     filters=[                                                                                                   │
+│         [                                                                                                       │
+│             IntegerPropertyFilter(                                                                              │
+│                 property_name='price',                                                                          │
+│                 operator=<ComparisonOperator.LESS_THAN: '<'>,                                                   │
+│                 value=200.0                                                                                     │
+│             )                                                                                                   │
+│         ]                                                                                                       │
+│     ],                                                                                                          │
+│     filter_operators='AND',                                                                                     │
+│     collection='Ecommerce'                                                                                      │
+│ )                                                                                                               │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
+│                                                                                                                 │
+│ 📊 No Aggregations Run                                                                                          │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭────────────────────────────────────────────────── 📚 Sources ───────────────────────────────────────────────────╮
+│                                                                                                                 │
+│  - object_id='5e9c5298-5b3a-4d80-b226-64b2ff6689b7' collection='Ecommerce'                                      │
+│  - object_id='48896222-d098-42e6-80df-ad4b03723c19' collection='Ecommerce'                                      │
+│  - object_id='00b383ca-262f-4251-b513-dafd4862c021' collection='Ecommerce'                                      │
+│  - object_id='cbe8f8be-304b-409d-a2a1-bafa0bbf249c' collection='Ecommerce'                                      │
+│  - object_id='c18d3c5b-8fbe-4816-bc60-174f336a982f' collection='Ecommerce'                                      │
+│  - object_id='1811da1b-6930-4bd1-832e-f8fa2119d4df' collection='Ecommerce'                                      │
+│  - object_id='2edd1bc5-777e-4376-95cd-42a141ffb71e' collection='Ecommerce'                                      │
+│  - object_id='9819907c-1015-4b4c-ac75-3b3848e7c247' collection='Ecommerce'                                      │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ + + + +
   📊 Usage Statistics
+┌────────────────┬──────┐
+│ LLM Requests:  │ 3    │
+│ Input Tokens:  │ 7774 │
+│ Output Tokens: │ 512  │
+│ Total Tokens:  │ 8286 │
+└────────────────┴──────┘
+ +
Total Time Taken: 16.93s
+ + + +### フォローアップ質問 + +エージェントには追加のコンテキストを渡すこともできます。たとえば、前回の応答をコンテキストとして渡し、`new_response` を取得できます。 + +```python +new_response = agent.run("What about some nice shoes, same budget as before?", context=response) +print_query_agent_response(new_response) +``` + +
╭─────────────────────────────────────────────── 🔍 Original Query ───────────────────────────────────────────────╮
+│                                                                                                                 │
+│ What about some nice shoes, same budget as before?                                                              │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭──────────────────────────────────────────────── 📝 Final Answer ────────────────────────────────────────────────╮
+│                                                                                                                 │
+│ Here are some great shoe options under $200 that you might like:                                                │
+│                                                                                                                 │
+│ 1. **Vintage Noir Loafers** - Priced at $125, these loafers are part of the Dark Academia collection by Solemn  │
+│ Chic. They come in black and grey, featuring a classic design with a modern twist. Reviews highlight their      │
+│ comfort and stylish appearance, making them suitable for both casual and formal settings.                       │
+│                                                                                                                 │
+│ 2. **Parchment Boots** - At $145, these boots from Nova Nest's Light Academia collection are noted for their    │
+│ elegant ivory leather and classical detail stitching. They are praised for their comfort and versatile style.   │
+│                                                                                                                 │
+│ 3. **Bramble Berry Loafers** - These loafers, priced at $75, come in pink and green and are marked by their     │
+│ eco-friendly material and countryside aesthetic. Produced by Eko & Stitch, they are loved for their comfort and │
+│ sustainability.                                                                                                 │
+│                                                                                                                 │
+│ 4. **Glide Platforms** - Available for $90 from the Y2K collection by Vivid Verse, these platform sneakers are  │
+│ both comfortable and stylish with a high-shine pink finish.                                                     │
+│                                                                                                                 │
+│ 5. **Sky Shimmer Sneaks** - Costing $69, these sneakers are from the Y2K collection by Nova Nest and offer a    │
+│ comfortable fit with a touch of sparkle for style.                                                              │
+│                                                                                                                 │
+│ These selections offer a mix of formal and casual styles, ensuring you can find a perfect pair under your       │
+│ budget of $200.                                                                                                 │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭─────────────────────────────────────────── 🔭 Searches Executed 1/1 ────────────────────────────────────────────╮
+│                                                                                                                 │
+│ QueryResultWithCollection(                                                                                      │
+│     queries=['nice shoes'],                                                                                     │
+│     filters=[                                                                                                   │
+│         [                                                                                                       │
+│             IntegerPropertyFilter(                                                                              │
+│                 property_name='price',                                                                          │
+│                 operator=<ComparisonOperator.LESS_THAN: '<'>,                                                   │
+│                 value=200.0                                                                                     │
+│             )                                                                                                   │
+│         ]                                                                                                       │
+│     ],                                                                                                          │
+│     filter_operators='AND',                                                                                     │
+│     collection='Ecommerce'                                                                                      │
+│ )                                                                                                               │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
+│                                                                                                                 │
+│ 📊 No Aggregations Run                                                                                          │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭────────────────────────────────────────────────── 📚 Sources ───────────────────────────────────────────────────╮
+│                                                                                                                 │
+│  - object_id='96b30047-8ce1-4096-9bcf-009733cf8613' collection='Ecommerce'                                      │
+│  - object_id='61e4fcd7-d2bc-4861-beb6-4c16948d9921' collection='Ecommerce'                                      │
+│  - object_id='6e533f7d-eba1-4e74-953c-9d43008278e7' collection='Ecommerce'                                      │
+│  - object_id='f873ac48-1311-462a-86b2-a28b15fdda7a' collection='Ecommerce'                                      │
+│  - object_id='93b8b13e-a417-4be2-9cce-fda8c767f35e' collection='Ecommerce'                                      │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ + + + +
   📊 Usage Statistics
+┌────────────────┬───────┐
+│ LLM Requests:  │ 4     │
+│ Input Tokens:  │ 9783  │
+│ Output Tokens: │ 574   │
+│ Total Tokens:  │ 10357 │
+└────────────────┴───────┘
+ +
Total Time Taken: 18.02s
+ +次に、集計が必要となる質問を試してみましょう。どのブランドが最も多くの靴を掲載しているかを見てみます。 + +```python +response = agent.run("What is the the name of the brand that lists the most shoes?") +print_query_agent_response(response) +``` + +
╭─────────────────────────────────────────────── 🔍 Original Query ───────────────────────────────────────────────╮
+│                                                                                                                 │
+│ What is the the name of the brand that lists the most shoes?                                                    │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭──────────────────────────────────────────────── 📝 Final Answer ────────────────────────────────────────────────╮
+│                                                                                                                 │
+│ The brand that lists the most shoes is Loom & Aura with a total of 118 shoe listings.                           │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
+│                                                                                                                 │
+│ 🔭 No Searches Run                                                                                              │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭──────────────────────────────────────────── 📊 Aggregations Run 1/1 ────────────────────────────────────────────╮
+│                                                                                                                 │
+│ AggregationResultWithCollection(                                                                                │
+│     search_query=None,                                                                                          │
+│     groupby_property='brand',                                                                                   │
+│     aggregations=[                                                                                              │
+│         IntegerPropertyAggregation(property_name='collection', metrics=<NumericMetrics.COUNT: 'COUNT'>)         │
+│     ],                                                                                                          │
+│     filters=[],                                                                                                 │
+│     collection='Ecommerce'                                                                                      │
+│ )                                                                                                               │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ + + + +
   📊 Usage Statistics
+┌────────────────┬──────┐
+│ LLM Requests:  │ 3    │
+│ Input Tokens:  │ 3976 │
+│ Output Tokens: │ 159  │
+│ Total Tokens:  │ 4135 │
+└────────────────┴──────┘
+ +
Total Time Taken: 5.33s
+ + + +### 複数コレクションでの検索 + +場合によっては、複数のコレクションに対する検索結果を組み合わせる必要があります。上記の結果から、 ' Loom & Aura ' が最も多くの靴を掲載していることが分かります。 + +ここでは、ユーザーがこの会社について _さらに_ 、そして彼らが販売しているアイテムについても詳しく知りたいと想定してみましょう。 + +```python +response = agent.run("Does the brand 'Loom & Aura' have a parent brand or child brands and what countries do they operate from? " + "Also, what's the average price of a item from 'Loom & Aura'?") + +print_query_agent_response(response) +``` + +
╭─────────────────────────────────────────────── 🔍 Original Query ───────────────────────────────────────────────╮
+│                                                                                                                 │
+│ Does the brand 'Loom & Aura' have a parent brand or child brands and what countries do they operate from? Also, │
+│ what's the average price of a item from 'Loom & Aura'?                                                          │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭──────────────────────────────────────────────── 📝 Final Answer ────────────────────────────────────────────────╮
+│                                                                                                                 │
+│ Loom & Aura is itself a well-established brand based in Italy and operates as the parent brand to several child │
+│ brands. These child brands include 'Loom & Aura Active', 'Loom & Aura Kids', 'Nova Nest', 'Vivid Verse', 'Loom  │
+│ Luxe', 'Saffron Sage', 'Stellar Stitch', 'Nova Nectar', 'Canvas Core', and 'Loom Lure'. The countries           │
+│ associated with the operations or origins of these child brands include Italy, USA, UK, Spain, South Korea,     │
+│ Japan, and some extend beyond Italy as suggested by the presence of these brands in different countries.        │
+│                                                                                                                 │
+│ The average price of an item from Loom & Aura is approximately $87.11. This reflects the brand's positioning as │
+│ offering items of timeless elegance and quality craftsmanship.                                                  │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭─────────────────────────────────────────── 🔭 Searches Executed 1/2 ────────────────────────────────────────────╮
+│                                                                                                                 │
+│ QueryResultWithCollection(                                                                                      │
+│     queries=['parent brand of Loom & Aura', 'child brands of Loom & Aura'],                                     │
+│     filters=[[], []],                                                                                           │
+│     filter_operators='AND',                                                                                     │
+│     collection='Brands'                                                                                         │
+│ )                                                                                                               │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭─────────────────────────────────────────── 🔭 Searches Executed 2/2 ────────────────────────────────────────────╮
+│                                                                                                                 │
+│ QueryResultWithCollection(                                                                                      │
+│     queries=['Loom & Aura'],                                                                                    │
+│     filters=[                                                                                                   │
+│         [                                                                                                       │
+│             TextPropertyFilter(                                                                                 │
+│                 property_name='name',                                                                           │
+│                 operator=<ComparisonOperator.LIKE: 'LIKE'>,                                                     │
+│                 value='Loom & Aura'                                                                             │
+│             )                                                                                                   │
+│         ]                                                                                                       │
+│     ],                                                                                                          │
+│     filter_operators='AND',                                                                                     │
+│     collection='Brands'                                                                                         │
+│ )                                                                                                               │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭──────────────────────────────────────────── 📊 Aggregations Run 1/1 ────────────────────────────────────────────╮
+│                                                                                                                 │
+│ AggregationResultWithCollection(                                                                                │
+│     search_query=None,                                                                                          │
+│     groupby_property=None,                                                                                      │
+│     aggregations=[IntegerPropertyAggregation(property_name='price', metrics=<NumericMetrics.MEAN: 'MEAN'>)],    │
+│     filters=[                                                                                                   │
+│         TextPropertyFilter(                                                                                     │
+│             property_name='brand',                                                                              │
+│             operator=<ComparisonOperator.EQUALS: '='>,                                                          │
+│             value='Loom & Aura'                                                                                 │
+│         )                                                                                                       │
+│     ],                                                                                                          │
+│     collection='Ecommerce'                                                                                      │
+│ )                                                                                                               │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ +
╭────────────────────────────────────────────────── 📚 Sources ───────────────────────────────────────────────────╮
+│                                                                                                                 │
+│  - object_id='88433e18-216d-489a-8719-81a29b0ae915' collection='Brands'                                         │
+│  - object_id='99f42d07-51e9-4388-9c4b-63eb8f79f5fd' collection='Brands'                                         │
+│  - object_id='0852c2a4-0c5a-4c69-9762-1be10bc44f2b' collection='Brands'                                         │
+│  - object_id='d172a342-da41-45c3-876e-d08db843b8b3' collection='Brands'                                         │
+│  - object_id='a7ad0ed7-812e-4106-a29f-40442c3a106e' collection='Brands'                                         │
+│  - object_id='b6abfa02-18e5-44cf-a002-ba140e3623ad' collection='Brands'                                         │
+│                                                                                                                 │
+╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
+ + + + +
   📊 Usage Statistics
+┌────────────────┬───────┐
+│ LLM Requests:  │ 5     │
+│ Input Tokens:  │ 9728  │
+│ Output Tokens: │ 479   │
+│ Total Tokens:  │ 10207 │
+└────────────────┴───────┘
+ +
Total Time Taken: 11.38s
+ +### システムプロンプトの変更 + +場合によっては、エージェントに対してカスタムの `system_prompt` を定義したいことがあります。これにより、エージェントにデフォルトの指示を与え、どのように振る舞うかを指定できます。たとえば、常にユーザーの言語でクエリに回答するエージェントを作成してみましょう。 + +さらに、`QueryAgent` に `Financial_contracts` と `Weather` という 2 つのコレクションへのアクセス権を持たせます。次に、ぜひ自分でもクエリを試してみてください! + +```python +multi_lingual_agent = QueryAgent( + client=client, collections=["Ecommerce", "Brands", "Financial_contracts", "Weather"], + system_prompt="You are a helpful assistant that always generated the final response in the users language." + " You may have to translate the user query to perform searches. But you must always respond to the user in their own language." +) +``` + +今回は、天気に関する質問をしてみましょう! + +```python +response = multi_lingual_agent.run("Quelles sont les vitesses minimales, maximales et moyennes du vent?") +print(response.final_answer) +``` + +Python 出力: +```text +Les vitesses de vent minimales, maximales et moyennes sont respectivement de 8,40 km/h, 94,88 km/h et 49,37 km/h. Ces données offrent une vue d'ensemble des conditions de vent typiques mesurées dans une période ou un lieu donné. +``` + +### さらに質問を試す + +たとえば、 ' Eko & Stitch ' というブランドについてもっと調べてみましょう。 + +```python +response = multi_lingual_agent.run("Does Eko & Stitch have a branch in the UK? Or if not, does it have parent or child company in the UK?") + +print(response.final_answer) +``` + +Python 出力: +```text +Yes, Eko & Stitch has a branch in the UK. The brand is part of the broader company Nova Nest, which serves as Eko & Stitch's parent brand. Eko & Stitch itself operates in the UK and has its child brands, Eko & Stitch Active and Eko & Stitch Kids, also within the UK. +``` + +`multi_lingual_agent` には "Financial_contracts" というコレクションにもアクセス権があります。このデータセットについてさらに情報を探してみましょう。 + +```python +response = multi_lingual_agent.run("What kinds of contracts are listed? What's the most common type of contract?") + +print(response.final_answer) +``` + +Python 出力: +```text +The query seeks to identify the types of contracts listed and determine the most common type. Among the types of contracts provided in the results, the following were identified: employment contracts, sales agreements, invoice contracts, service agreements, and lease agreements. The most common type of contract found in the search results is the employment contract. However, when considering data from both search and aggregation results, the aggregation reveals that the invoice contract is the most common, followed by service agreements and lease agreements. While employment contracts appear frequently in the search results, they rank fourth in the aggregation data in terms of overall occurrences. +``` + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/transformation-agent-get-started.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/transformation-agent-get-started.md new file mode 100644 index 000000000..ac8137cc7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/transformation-agent-get-started.md @@ -0,0 +1,345 @@ +--- +layout: recipe +colab: https://colab.research.google.com/github/weaviate/recipes/blob/main/weaviate-services/agents/transformation-agent-get-started.ipynb +toc: True +title: "Weaviate Transformation エージェントの構築" +featured: True +integration: False +agent: True +tags: ['Transformation Agent'] +--- + + Open In Google Colab + + +このレシピでは、Weaviate の [`TransformationAgent`](https://docs.weaviate.io/agents/transformation) を使用して、Weaviate 内のデータを強化します。研究論文のタイトルとアブストラクトを含むコレクションにアクセスできるエージェントを構築し、そのエージェントを使ってコレクション内の各オブジェクトに追加プロパティを作成します。 + +> ⚠️ Weaviate Transformation エージェントは、Weaviate 内のデータをインプレースで変更するよう設計されています。**技術プレビュー期間中は、本番環境での使用は避けてください。** エージェントが期待どおりに動作しない場合や、Weaviate インスタンス内のデータが予期せず変更される可能性があります。 + +`TransformationAgent` は、任意の Weaviate コレクションにアクセスし、その中のオブジェクトに対して操作を実行できます。ただし、各操作は自然言語で定義できます。エージェントは LLM を使用して指示を実行します。 + +> 📚 新しい `TransformationAgent` について詳しくは、併せてお読みいただけるブログ記事「[Introducing the Weaviate Transformation Agent](https://weaviate.io/blog/transformation-agent)」をご覧ください。 + +まずは Hugging Face に公開されているオープンデータセットを用意しました。最初のステップとして、Weaviate Cloud のコレクションをどのように埋め込むかを説明します。 + +- [**ArxivPapers:**](https://huggingface.co/datasets/weaviate/agents/viewer/query-agent-ecommerce) 研究論文のタイトルとアブストラクトをまとめたデータセットです。 + +他のデータセットでさらにエージェントを試したい場合は、[Hugging Face Weaviate agents dataset](https://huggingface.co/datasets/weaviate/agents) にあるデモデータセット一覧をご覧ください。 + +## Weaviate のセットアップとデータのインポート + +Weaviate Transformation エージェントを使用するには、まず [Weaviate Cloud](https://weaviate.io/deployment/serverless) アカウントを作成します👇 +1. [Serverless Weaviate Cloud アカウントの作成](https://weaviate.io/deployment/serverless) と無料の [Sandbox](https://docs.weaviate.io/cloud/manage-clusters/create#sandbox-clusters) のセットアップ +2. 「Embedding」に移動して有効化します。デフォルトでは `Snowflake/snowflake-arctic-embed-l-v2.0` が埋め込みモデルとして使用されます +3. 下記でクラスターに接続するために `WEAVIATE_URL` と `WEAVIATE_API_KEY` を控えておきます + +> Info: 外部埋め込みプロバイダー用の追加キーを用意しなくても済むよう、[Weaviate Embeddings](https://docs.weaviate.io/weaviate/model-providers/weaviate) の利用を推奨します。 + +```python +!pip install "weaviate-client[agents]" datasets +!pip install -U weaviate-agents +``` + +Python output: +```text +/Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/pty.py:95: DeprecationWarning: This process (pid=93073) is multi-threaded, use of forkpty() may lead to deadlocks in the child. + pid, fd = os.forkpty() + +Collecting datasets + Using cached datasets-3.3.2-py3-none-any.whl.metadata (19 kB) +Requirement already satisfied: weaviate-client[agents] in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (4.11.1) +Requirement already satisfied: httpx<0.29.0,>=0.26.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (0.27.0) +Requirement already satisfied: validators==0.34.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (0.34.0) +Requirement already satisfied: authlib<1.3.2,>=1.2.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (1.3.1) +Requirement already satisfied: pydantic<3.0.0,>=2.8.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (2.10.5) +Requirement already satisfied: grpcio<2.0.0,>=1.66.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (1.69.0) +Requirement already satisfied: grpcio-tools<2.0.0,>=1.66.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (1.69.0) +Requirement already satisfied: grpcio-health-checking<2.0.0,>=1.66.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (1.69.0) +Requirement already satisfied: weaviate-agents<1.0.0,>=0.3.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client[agents]) (0.4.0) +Requirement already satisfied: filelock in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (3.17.0) +Requirement already satisfied: numpy>=1.17 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (2.2.2) +Collecting pyarrow>=15.0.0 (from datasets) + Using cached pyarrow-19.0.1-cp313-cp313-macosx_12_0_arm64.whl.metadata (3.3 kB) +Collecting dill<0.3.9,>=0.3.0 (from datasets) + Using cached dill-0.3.8-py3-none-any.whl.metadata (10 kB) +Requirement already satisfied: pandas in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (2.2.3) +Requirement already satisfied: requests>=2.32.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (2.32.3) +Requirement already satisfied: tqdm>=4.66.3 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (4.67.1) +Collecting xxhash (from datasets) + Using cached xxhash-3.5.0-cp313-cp313-macosx_11_0_arm64.whl.metadata (12 kB) +Collecting multiprocess<0.70.17 (from datasets) + Using cached multiprocess-0.70.16-py312-none-any.whl.metadata (7.2 kB) +Requirement already satisfied: fsspec<=2024.12.0,>=2023.1.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from fsspec[http]<=2024.12.0,>=2023.1.0->datasets) (2024.12.0) +Requirement already satisfied: aiohttp in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (3.11.11) +Requirement already satisfied: huggingface-hub>=0.24.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (0.27.1) +Requirement already satisfied: packaging in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (24.2) +Requirement already satisfied: pyyaml>=5.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from datasets) (6.0.2) +Requirement already satisfied: cryptography in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from authlib<1.3.2,>=1.2.1->weaviate-client[agents]) (44.0.0) +Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from aiohttp->datasets) (2.4.4) +Requirement already satisfied: aiosignal>=1.1.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from aiohttp->datasets) (1.3.2) +Requirement already satisfied: attrs>=17.3.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from aiohttp->datasets) (24.3.0) +Requirement already satisfied: frozenlist>=1.1.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from aiohttp->datasets) (1.5.0) +Requirement already satisfied: multidict<7.0,>=4.5 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from aiohttp->datasets) (6.1.0) +Requirement already satisfied: propcache>=0.2.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from aiohttp->datasets) (0.2.1) +Requirement already satisfied: yarl<2.0,>=1.17.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from aiohttp->datasets) (1.18.3) +Requirement already satisfied: protobuf<6.0dev,>=5.26.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from grpcio-health-checking<2.0.0,>=1.66.2->weaviate-client[agents]) (5.29.3) +Requirement already satisfied: setuptools in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from grpcio-tools<2.0.0,>=1.66.2->weaviate-client[agents]) (75.1.0) +Requirement already satisfied: anyio in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client[agents]) (4.8.0) +Requirement already satisfied: certifi in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client[agents]) (2024.12.14) +Requirement already satisfied: httpcore==1.* in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client[agents]) (1.0.7) +Requirement already satisfied: idna in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client[agents]) (3.10) +Requirement already satisfied: sniffio in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client[agents]) (1.3.1) +Requirement already satisfied: h11<0.15,>=0.13 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpcore==1.*->httpx<0.29.0,>=0.26.0->weaviate-client[agents]) (0.14.0) +Requirement already satisfied: typing-extensions>=3.7.4.3 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from huggingface-hub>=0.24.0->datasets) (4.12.2) +Requirement already satisfied: annotated-types>=0.6.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pydantic<3.0.0,>=2.8.0->weaviate-client[agents]) (0.7.0) +Requirement already satisfied: pydantic-core==2.27.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pydantic<3.0.0,>=2.8.0->weaviate-client[agents]) (2.27.2) +Requirement already satisfied: charset-normalizer<4,>=2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from requests>=2.32.2->datasets) (3.4.1) +Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from requests>=2.32.2->datasets) (2.3.0) +Requirement already satisfied: rich>=13.9.4 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-agents<1.0.0,>=0.3.0->weaviate-client[agents]) (13.9.4) +Requirement already satisfied: python-dateutil>=2.8.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pandas->datasets) (2.9.0.post0) +Requirement already satisfied: pytz>=2020.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pandas->datasets) (2024.2) +Requirement already satisfied: tzdata>=2022.7 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pandas->datasets) (2025.1) +Requirement already satisfied: six>=1.5 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from python-dateutil>=2.8.2->pandas->datasets) (1.17.0) +Requirement already satisfied: markdown-it-py>=2.2.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from rich>=13.9.4->weaviate-agents<1.0.0,>=0.3.0->weaviate-client[agents]) (3.0.0) +Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from rich>=13.9.4->weaviate-agents<1.0.0,>=0.3.0->weaviate-client[agents]) (2.19.1) +Requirement already satisfied: cffi>=1.12 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from cryptography->authlib<1.3.2,>=1.2.1->weaviate-client[agents]) (1.17.1) +Requirement already satisfied: pycparser in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from cffi>=1.12->cryptography->authlib<1.3.2,>=1.2.1->weaviate-client[agents]) (2.22) +Requirement already satisfied: mdurl~=0.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from markdown-it-py>=2.2.0->rich>=13.9.4->weaviate-agents<1.0.0,>=0.3.0->weaviate-client[agents]) (0.1.2) +Using cached datasets-3.3.2-py3-none-any.whl (485 kB) +Using cached dill-0.3.8-py3-none-any.whl (116 kB) +Using cached multiprocess-0.70.16-py312-none-any.whl (146 kB) +Using cached pyarrow-19.0.1-cp313-cp313-macosx_12_0_arm64.whl (30.7 MB) +Using cached xxhash-3.5.0-cp313-cp313-macosx_11_0_arm64.whl (30 kB) +Installing collected packages: xxhash, pyarrow, dill, multiprocess, datasets +Successfully installed datasets-3.3.2 dill-0.3.8 multiprocess-0.70.16 pyarrow-19.0.1 xxhash-3.5.0 +Requirement already satisfied: weaviate-agents in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (0.4.0) +Requirement already satisfied: rich>=13.9.4 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-agents) (13.9.4) +Requirement already satisfied: weaviate-client>=4.11.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-agents) (4.11.1) +Requirement already satisfied: markdown-it-py>=2.2.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from rich>=13.9.4->weaviate-agents) (3.0.0) +Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from rich>=13.9.4->weaviate-agents) (2.19.1) +Requirement already satisfied: httpx<0.29.0,>=0.26.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client>=4.11.0->weaviate-agents) (0.27.0) +Requirement already satisfied: validators==0.34.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client>=4.11.0->weaviate-agents) (0.34.0) +Requirement already satisfied: authlib<1.3.2,>=1.2.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client>=4.11.0->weaviate-agents) (1.3.1) +Requirement already satisfied: pydantic<3.0.0,>=2.8.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client>=4.11.0->weaviate-agents) (2.10.5) +Requirement already satisfied: grpcio<2.0.0,>=1.66.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client>=4.11.0->weaviate-agents) (1.69.0) +Requirement already satisfied: grpcio-tools<2.0.0,>=1.66.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client>=4.11.0->weaviate-agents) (1.69.0) +Requirement already satisfied: grpcio-health-checking<2.0.0,>=1.66.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from weaviate-client>=4.11.0->weaviate-agents) (1.69.0) +Requirement already satisfied: cryptography in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from authlib<1.3.2,>=1.2.1->weaviate-client>=4.11.0->weaviate-agents) (44.0.0) +Requirement already satisfied: protobuf<6.0dev,>=5.26.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from grpcio-health-checking<2.0.0,>=1.66.2->weaviate-client>=4.11.0->weaviate-agents) (5.29.3) +Requirement already satisfied: setuptools in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from grpcio-tools<2.0.0,>=1.66.2->weaviate-client>=4.11.0->weaviate-agents) (75.1.0) +Requirement already satisfied: anyio in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client>=4.11.0->weaviate-agents) (4.8.0) +Requirement already satisfied: certifi in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client>=4.11.0->weaviate-agents) (2024.12.14) +Requirement already satisfied: httpcore==1.* in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client>=4.11.0->weaviate-agents) (1.0.7) +Requirement already satisfied: idna in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client>=4.11.0->weaviate-agents) (3.10) +Requirement already satisfied: sniffio in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpx<0.29.0,>=0.26.0->weaviate-client>=4.11.0->weaviate-agents) (1.3.1) +Requirement already satisfied: h11<0.15,>=0.13 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from httpcore==1.*->httpx<0.29.0,>=0.26.0->weaviate-client>=4.11.0->weaviate-agents) (0.14.0) +Requirement already satisfied: mdurl~=0.1 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from markdown-it-py>=2.2.0->rich>=13.9.4->weaviate-agents) (0.1.2) +Requirement already satisfied: annotated-types>=0.6.0 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pydantic<3.0.0,>=2.8.0->weaviate-client>=4.11.0->weaviate-agents) (0.7.0) +Requirement already satisfied: pydantic-core==2.27.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pydantic<3.0.0,>=2.8.0->weaviate-client>=4.11.0->weaviate-agents) (2.27.2) +Requirement already satisfied: typing-extensions>=4.12.2 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from pydantic<3.0.0,>=2.8.0->weaviate-client>=4.11.0->weaviate-agents) (4.12.2) +Requirement already satisfied: cffi>=1.12 in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from cryptography->authlib<1.3.2,>=1.2.1->weaviate-client>=4.11.0->weaviate-agents) (1.17.1) +Requirement already satisfied: pycparser in /Users/tuanacelik/miniconda3/envs/agent/lib/python3.13/site-packages (from cffi>=1.12->cryptography->authlib<1.3.2,>=1.2.1->weaviate-client>=4.11.0->weaviate-agents) (2.22) +``` +```python +import os +from getpass import getpass + +if "WEAVIATE_API_KEY" not in os.environ: + os.environ["WEAVIATE_API_KEY"] = getpass("Weaviate API Key") +if "WEAVIATE_URL" not in os.environ: + os.environ["WEAVIATE_URL"] = getpass("Weaviate URL") +``` + +```python +import weaviate +from weaviate.auth import Auth + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=os.environ.get("WEAVIATE_URL"), + auth_credentials=Auth.api_key(os.environ.get("WEAVIATE_API_KEY")), +) +``` + +### コレクションの準備 + +以下のコードブロックでは、Hugging Face からデモの「papers」データセットを取得し、Weaviate Serverless クラスターに新しいコレクションとして書き込みます。 + +**Important:** Weaviate Cloud コンソールで「Embeddings」を必ず有効にしてください。これにより `text2vec_weaviate` ベクトライザーを使用でき、デフォルトで `Snowflake/snowflake-arctic-embed-l-v2.0` でベクトルが作成されます。 + +```python +from weaviate.classes.config import Configure + +# To re-run cell you may have to delete collections +# client.collections.delete("ArxivPapers") +client.collections.create( + "ArxivPapers", + description="A dataset that lists research paper titles and abstracts", + vector_config=Configure.Vectors.text2vec_weaviate() +) + +``` + +Python output: +```text + +``` +```python +from datasets import load_dataset + +dataset = load_dataset("weaviate/agents", "transformation-agent-papers", split="train", streaming=True) + +papers_collection = client.collections.use("ArxivPapers") + +with papers_collection.batch.dynamic() as batch: + for i, item in enumerate(dataset): + if i < 200: + batch.add_object(properties=item["properties"]) +``` + +### Explorer でコレクションを確認 + +`TransformationAgent` は、今後コレクションを変更します。ここで「ArxivPapers」コレクションの内容を確認してみましょう。Weaviate Cloud コンソールの Explorer ツールでデータを確認できます。正しく取り込めていれば、各オブジェクトに以下の 2 つのプロパティが表示されるはずです。 +- `title`: 論文のタイトル +- `abstract`: 論文のアブストラクト + +さらに各オブジェクトの `vectors` も確認できます。 + +## Transformation 操作の定義 + +`TransformationAgent` の主役は操作(operations)です。 + +コレクションに対して実行したい変換操作を定義できます。操作には次の種類があります。 +- 新しいプロパティの追加 +- 既存プロパティの更新 + +現在、`TransformationAgent` は Weaviate 内の既存オブジェクトを更新する操作をサポートしています。 + +### 新しいプロパティの追加 + +新しいプロパティを追加するには、次の内容で操作を定義します。 +- **`instrcution`**: この新しいプロパティが何であるかを自然言語で説明します +- **`property_name`**: プロパティ名 +- **`data_type`**: プロパティのデータ型(例: `DataType.TEXT`, `DataType.TEXT_ARRAY`, `DataType.BOOL`, `DataType.INT` など) +- **`view_properties`**: 他のプロパティを基にプロパティを作成したい場合、ここに参照するプロパティを列挙します + +#### トピック一覧の作成 + +まず `TEXT_ARRAY` 型の新しいプロパティ「topics」を追加します。「abstract」と「title」を基に、トピックタグを最大 5 つ抽出するよう LLM に依頼しましょう。 + +```python +from weaviate.agents.classes import Operations +from weaviate.classes.config import DataType + +add_topics = Operations.append_property( + property_name="topics", + data_type=DataType.TEXT_ARRAY, + view_properties=["abstract"], + instruction="""Create a list of topic tags based on the abstract. + Topics should be distinct from eachother. Provide a maximum of 5 topics. + Group similar topics under one topic tag.""", +) + +``` + +#### フランス語訳の追加 + +次に「abstract」をフランス語に翻訳した新しいプロパティ「french_abstract」を追加します。 + +```python +add_french_abstract = Operations.append_property( + property_name="french_abstract", + data_type=DataType.TEXT, + view_properties=["abstract"], + instruction="Translate the abstract to French", +) +``` + +#### タイトルの更新 + +今回は `title` プロパティを更新し、フランス語の訳をかっこ書きで追記します。 + +```python +update_title = Operations.update_property( + property_name="title", + view_properties=["title"], + instruction="""Update the title to ensure that it contains the French translation of itself in parantheses, after the original title.""", +) +``` + +#### サーベイ論文かどうかの判定 + +最後に、その論文がサーベイ(既存研究の調査)かどうかを示す `BOOL` 型プロパティを作成します。 + +```python +is_survey_paper = Operations.append_property( + property_name="is_survey_paper", + data_type=DataType.BOOL, + view_properties=["abstract"], + instruction="""Determine if the paper is a "survey". + A paper is considered survey it's a surveys existing techniques, and not if it presents novel techniques""", +) +``` + +## Transformation エージェントの作成と実行 + +すべての操作を定義したら、`TransformationAgent` を初期化できます。 + +エージェントを初期化する際には、どの `collection` に対して変更を行うかを指定する必要があります。ここでは、先ほど作成した「ArxivPapers」コレクションにアクセスさせます。 + +次に、エージェントに実行させたい `operations` のリストを渡します。ここでは前述のすべての操作を指定します。 + +> Note: 同一オブジェクトに対して複数の操作が同時に実行される場合、データ整合性に関する既知の問題を解決中です。 + +```python +from weaviate.agents.transformation import TransformationAgent + +agent = TransformationAgent( + client=client, + collection="ArxivPapers", + operations=[ + add_topics, + add_french_abstract, + is_survey_paper, + update_title, + ], +) +``` + +### 変換の実行 + +`update_all()` を呼び出すことで、 エージェントが各操作ごとに個別のワークフローを立ち上げます。 各操作はコレクション内の各オブジェクトで実行されます。 + +```python +response = agent.update_all() +``` + +### 操作ワークフローの確認 + +操作のステータスを確認するには、 返された `TransformationResponse` に含まれる `workflow_id` を確認し、 `agent.get_status(workflow_id)` でそのステータスを取得できます。 これらの操作は非同期です。 + +```python +response +``` + +Python 出力: +```text +[TransformationResponse(operation_name='topics', workflow_id='TransformationWorkflow-1766a450c35039c2a44e1fa33dc49dd4'), + TransformationResponse(operation_name='french_abstract', workflow_id='TransformationWorkflow-67e90d88830347a5581d3ee1aa10b867'), + TransformationResponse(operation_name='is_survey_paper', workflow_id='TransformationWorkflow-6294dd575fad55c318ee7b0e8a38a8ff'), + TransformationResponse(operation_name='title', workflow_id='TransformationWorkflow-bba64a5bf204b00c3572310de715d1e2')] +``` +```python +agent.get_status(workflow_id=response.workflow_id) +``` + +Python 出力: +```text +{'workflow_id': 'TransformationWorkflow-1766a450c35039c2a44e1fa33dc49dd4', + 'status': {'batch_count': 1, + 'end_time': '2025-03-11 14:58:57', + 'start_time': '2025-03-11 14:57:55', + 'state': 'completed', + 'total_duration': 62.56732, + 'total_items': 200}} +``` + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/transformation-agent-retrieval-benchmark.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/transformation-agent-retrieval-benchmark.md new file mode 100644 index 000000000..f4913bd61 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/recipes/transformation-agent-retrieval-benchmark.md @@ -0,0 +1,509 @@ +--- +layout: recipe +colab: https://colab.research.google.com/github/weaviate/recipes/blob/main/weaviate-services/agents/transformation-agent-retrieval-benchmark.ipynb +toc: True +title: "Synthetic RAG 評価による Arctic 2.0 対 Arctic 1.5 のベンチマーク" +featured: True +integration: False +agent: True +tags: ['Transformation Agent'] +--- + + Open In Google Colab + + +従来、AI システムの評価は人間が作成した評価セットに大きく依存していました。特に、このプロセスには多大な時間とリソースが必要となり、ほとんどの開発者が AI システムを作成して適切に評価することを妨げていました。 + +Weaviate Transformation エージェントは、合成評価データセットを迅速に生成できることで、AI 評価に革新をもたらします。 + +このノートブックでは、Weaviate ブログの記事それぞれに対して ** 2,100 ** 件の合成質問をわずか 63 秒で生成します! + +続いて、このデータセットを用いて Snowflake の [ Arctic 2.0 ](https://arxiv.org/abs/2412.04506) と [ Arctic 1.5 ](https://arxiv.org/abs/2405.05374) の埋め込みモデル間で、埋め込みリコール(干し草の山からソースドキュメントを見つける)を報告します。結果は次のとおりです。 + +| Model | Recall@1 | Recall@5 | Recall@100 | +|------------|----------|----------|------------| +| Arctic 1.5 | 0.7995 | 0.9245 | 0.9995 | +| Arctic 2.0 | 0.8412 | 0.9546 | 0.9995 | + +Arctic 2.0 モデルは優れた性能を示し、特に Recall@1 で 4.17 %、Recall@5 で 3.01 % の向上が見られました。 + +## ノートブックの概要 + +![Embedding Benchmark with the Transformation Agent](https://raw.githubusercontent.com/weaviate/recipes/refs/heads/main/weaviate-services/agents/images/synthetic-query-overview-new.png "Embedding Benchmark with the Transformation Agent") + +```python +import weaviate +import os +from weaviate.classes.init import Auth +import weaviate.classes.config as wvcc +import re +from weaviate.util import get_valid_uuid +from uuid import uuid4 +``` + +```python +# Connect to Weaviate Client + +WEAVIATE_URL = os.getenv("WEAVIATE_URL") +WEAVIATE_API_KEY = os.getenv("WEAVIATE_API_KEY") + +weaviate_client = weaviate.connect_to_weaviate_cloud( + cluster_url=WEAVIATE_URL, + auth_credentials=Auth.api_key(WEAVIATE_API_KEY) +) + +print(weaviate_client.is_ready()) +``` + +Python output: +```text +True +``` +## Weaviate Named ベクトル + +Weaviate で *同じ* プロパティから 2 つの HSNW インデックスを作成できます! + +さらに、それぞれに異なる埋め込みモデルを設定することも可能です。 + +Weaviate Named ベクトルの詳細は [こちら](https://docs.weaviate.io/weaviate/config-refs/collections)、Weaviate Embedding Service については [こちら](https://docs.weaviate.io/cloud/embeddings) をご覧ください。 + +```python +blogs_collection = weaviate_client.collections.create( + name="WeaviateBlogChunks", + vectorizer_config=[ + wvcc.Configure.NamedVectors.text2vec_weaviate( + name="content_arctic_1_5", + model="Snowflake/snowflake-arctic-embed-m-v1.5", + source_properties=["content"], + ), + wvcc.Configure.NamedVectors.text2vec_weaviate( + name="content_arctic_2_0", + model="Snowflake/snowflake-arctic-embed-l-v2.0", + source_properties=["content"], + ) + ], + properties=[ + wvcc.Property(name="content", data_type=wvcc.DataType.TEXT), + ] +) +``` + +## ディレクトリパーサーによるブログのロード + +```python +def chunk_list(lst, chunk_size): + """Break a list into chunks of the specified size.""" + return [lst[i:i + chunk_size] for i in range(0, len(lst), chunk_size)] + +def split_into_sentences(text): + """Split text into sentences using regular expressions.""" + sentences = re.split(r'(? +• [Arctic Embed 2.0 リサーチレポート](https://arxiv.org/abs/2412.04506)
+• [Arctic Embed リサーチレポート](https://arxiv.org/abs/2405.05374)
+• [Weaviate Podcast #110(Luke Merrick、Puxuan Yu、Charles Pierse)](https://www.youtube.com/watch?v=Kjqv4uk3RCs) + +## Luke さんと Puxuan さん、このノートブックのレビューに大きな感謝を! + +![Arctic Embed on the Weaviate Podcast](https://raw.githubusercontent.com/weaviate/recipes/refs/heads/main/weaviate-services/agents/images/pod-110-thumbnail.png "Arctic Embed on the Weaviate Podcast!") + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/index.md new file mode 100644 index 000000000..3806764c2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/index.md @@ -0,0 +1,118 @@ +--- +title: 変換エージェント +sidebar_position: 30 +description: "Weaviate のコレクションにある既存データを強化・拡充・変換する AI エージェントの概要。" +image: og/docs/agents.jpg +# tags: ['agents', 'getting started', 'transformation agent'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/docs/agents/_includes/transformation_agent.py'; + +# Weaviate 変換エージェント + +:::caution Technical Preview + +![この Weaviate エージェントはテクニカルプレビュー版です。](../_includes/agents_tech_preview_light.png#gh-light-mode-only "この Weaviate エージェントはテクニカルプレビュー版です。") +![この Weaviate エージェントはテクニカルプレビュー版です。](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only "この Weaviate エージェントはテクニカルプレビュー版です。") + +[こちらからサインアップ](https://events.weaviate.io/weaviate-agents)して Weaviate エージェントの通知を受け取るか、[このページ](https://weaviateagents.featurebase.app/)で最新情報の確認やフィードバックの送信を行ってください。 + +::: + +:::warning 本番環境では使用しないでください +Weaviate 変換エージェントは、Weaviate 内のデータをその場で変更するよう設計されています。**テクニカルプレビュー期間中は、本番環境で使用しないでください。** エージェントが期待どおりに動作しない可能性があり、Weaviate インスタンス内のデータが予期せぬ形で変更される場合があります。 +::: + +Weaviate 変換エージェント (Transformation Agent) は、生成モデルを用いてデータを拡張・変換するエージェント型サービスです。既存のオブジェクトに対して新しいプロパティを追加したり、既存プロパティを更新したりできます。 + +![Weaviate 変換エージェントの例 - 追加](../_includes/transformation_agent_append_example_light.png#gh-light-mode-only "Weaviate 変換エージェントの例 - 追加") +![Weaviate 変換エージェントの例 - 追加](../_includes/transformation_agent_append_example_dark.png#gh-dark-mode-only "Weaviate 変換エージェントの例 - 追加") + +これにより、アプリケーションでのさらなる活用に向けて、Weaviate コレクション内オブジェクトの品質を向上させられます。 + +## アーキテクチャ + +変換エージェントは Weaviate Cloud 上のサービスとして提供され、既存の Weaviate オブジェクトに対して新しいプロパティの追加や既存プロパティの更新を行います。 + +![Weaviate 変換エージェントの概要](../_includes/transformation_agent_overview_light.png#gh-light-mode-only "Weaviate 変換エージェントの概要") +![Weaviate 変換エージェントの概要](../_includes/transformation_agent_overview_dark.png#gh-dark-mode-only "Weaviate 変換エージェントの概要") + +変換エージェントには、更新対象のコレクション名や確認対象の既存プロパティ、そして instructions などの指示を渡してください。エージェントは指定されたオブジェクトに対し、指示どおりの操作を実行します。 + +:::note オブジェクト総数は変わりません +オブジェクト数自体は増減せず、指定オブジェクトのプロパティのみが更新されます。 +::: + +## 変換エージェント:ワークフローの可視化 + +既存オブジェクトを変換する際、変換エージェントは以下の手順で動作します。 + +- 変換エージェントが指定条件に基づき Weaviate から既存オブジェクトを取得します(ステップ 1–2)。 +- 取得した既存プロパティのコンテキストと instructions を基に、生成モデルで新しいプロパティ値を生成します(ステップ 3–4)。 +- 変換後のオブジェクトを Weaviate に更新します。必要に応じ、指定した ベクトライザー でベクトル化が行われます(ステップ 5–7)。 +- Weaviate からジョブステータスが返され、最終的にユーザーへ返却されます(ステップ 8)。 + +### 既存オブジェクトのプロパティを更新 + +既存プロパティを更新する場合、変換エージェントは既存値を新しい値で置き換えます。ワークフローは以下のとおりです。 + +![Weaviate 変換エージェント: 既存オブジェクトのプロパティを更新](../_includes/transformation_agent_existing_update_light.png#gh-light-mode-only "Weaviate 変換エージェント: 既存オブジェクトのプロパティを更新") +![Weaviate 変換エージェント: 既存オブジェクトのプロパティを更新](../_includes/transformation_agent_existing_update_dark.png#gh-dark-mode-only "Weaviate 変換エージェント: 既存オブジェクトのプロパティを更新") + +### 既存オブジェクトに新しいプロパティを追加 + +プロパティを追加する場合、変換エージェントは新しい値を新規プロパティとしてオブジェクトに追加します。ワークフローは以下のとおりです。 + +![Weaviate 変換エージェント: 既存オブジェクトに新しいプロパティを追加](../_includes/transformation_agent_existing_append_light.png#gh-light-mode-only "Weaviate 変換エージェント: 既存オブジェクトに新しいプロパティを追加") +![Weaviate 変換エージェント: 既存オブジェクトに新しいプロパティを追加](../_includes/transformation_agent_existing_append_dark.png#gh-dark-mode-only "Weaviate 変換エージェント: 既存オブジェクトに新しいプロパティを追加") + +## 基本的な使い方 + +ここでは Weaviate 変換エージェントの基本的な利用方法を概説します。詳細は [Usage](./usage.md) ページをご覧ください。 + +### 前提条件 + +本エージェントは Weaviate Cloud インスタンスと、対応するバージョンの Weaviate クライアントライブラリでのみ利用できます。 + +### 使用例 + +変換エージェントを使用するには、次の入力でインスタンス化します。 + +- Weaviate Cloud インスタンスに接続した Weaviate クライアント(例:Python の `WeaviateClient` オブジェクト) +- 変換対象コレクションの名前 +- 実行する変換操作のリスト + +その後、操作を開始します。 + +変換操作は非同期で実行されます。各操作はワークフロー ID を返すので、ユーザーはその ID を用いてステータスを確認できます。 + + + + + + + + +変換された属性は処理が進むにつれて各オブジェクトに反映されます。 + +### さらに詳しいドキュメント + +本エージェントの詳細な使用方法については、[Usage](./usage.md) ページを参照してください。 + +## 質問とフィードバック + +:::info Changelog and feedback +Weaviate エージェントの公式変更履歴は[こちら](https://weaviateagents.featurebase.app/changelog)で確認できます。機能要望・バグ報告・質問などのフィードバックは、[こちら](https://weaviateagents.featurebase.app/)から送信してください。フィードバックのステータス確認や他の提案への投票も可能です。 +::: + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/tutorial-enrich-dataset.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/tutorial-enrich-dataset.mdx new file mode 100644 index 000000000..f1142c226 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/tutorial-enrich-dataset.mdx @@ -0,0 +1,401 @@ +--- +title: Transformation エージェントによるデータセット拡張 +sidebar_label: "チュートリアル: データセットを拡張する" +description: "Transformation エージェントを使用して Weaviate のコレクションに新しいプロパティを追加し、既存のプロパティを更新する方法を示すチュートリアルです。" +sidebar_position: 40 +image: og/docs/tutorials.jpg +# tags: ['basics'] +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/docs/agents/_includes/transformation_agent_tutorial_enrich_dataset.py"; + +:::caution Technical Preview + +![This Weaviate Agent is in technical preview.](../_includes/agents_tech_preview_light.png#gh-light-mode-only "This Weaviate Agent is in technical preview.") +![This Weaviate Agent is in technical preview.](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only "This Weaviate Agent is in technical preview.") + +[こちらからサインアップ](https://events.weaviate.io/weaviate-agents)して Weaviate エージェントの通知を受け取るか、[このページ](https://weaviateagents.featurebase.app/)で最新情報を確認し、フィードバックをお寄せください。 + +::: + +:::warning 本番環境では使用しないでください +Weaviate Transformation エージェントは、Weaviate 内のデータを直接変更するよう設計されています。**エージェントがテクニカルプレビューの間は、本番環境で使用しないでください。** エージェントが想定どおりに動作しない可能性があり、Weaviate インスタンス内のデータが予期せぬ形で変更される恐れがあります。 +::: + +このチュートリアルでは、**[Transformation エージェント](./index.md)** を使用して Weaviate に保存されたデータを拡張します。論文のタイトルとアブストラクトを含むコレクションにエージェントがアクセスできるようにし、各オブジェクトに追加のプロパティを作成します。 + +Transformation エージェントを体験できる公開データセットを用意しました。Hugging Face でご利用いただけます。 + +- [**ArxivPapers:**](https://huggingface.co/datasets/weaviate/agents/viewer/transformation-agent-papers) 研究論文のタイトルとアブストラクトをまとめたデータセット + +## 導入: Transformation エージェントの概要 + +Transformation エージェントは、指定した Weaviate コレクションにアクセスし、その中のオブジェクトに対して操作を行えます。各操作は自然言語で定義でき、エージェントは LLM を用いて指示を実行します。 + +import WeaviateAgentsArxivFlowchart from "/docs/agents/_includes/transformation_agent_tutorial_arxiv_flowchart.png"; + +
+
+
+ Weaviate Query Agent flowchart +
+
+
+
+ +Transformation エージェントは次のように動作します。 + +1. **タスクを受け取る** – 新しいプロパティを作成する、または既存プロパティを更新する。 +2. **Weaviate から必要なデータを取得する** – 更新対象、または新規プロパティ作成に使用するデータを取得。 +3. **適切なファウンデーションモデル**(例: 大規模言語モデル)を使用してデータを変換。 +4. **変換後のデータを Weaviate に保存する** – 新しいプロパティを作成するか、既存プロパティを更新。 + +
+ +## 前提条件 + +Weaviate エージェントおよび Weaviate Embedding サービスを使用するには、**[Weaviate Cloud](https://console.weaviate.cloud)** アカウントが必要です。 + +## ステップ 1: Weaviate のセットアップ + +それでは、チュートリアルで使用する Weaviate Cloud インスタンスを作成し、Python クライアントから接続してみましょう。 + +### 1.1 Weaviate Cloud クラスタの作成 + +1. Weaviate Cloud で [無料の Sandbox クラスタ](/cloud/manage-clusters/create#sandbox-clusters) を作成します。 +2. クラスタへの接続に必要な `REST Endpoint` と `Admin` API キーを控えておきます。(詳細は [クイックスタート](/cloud/manage-clusters/connect.mdx) を参照) + +:::tip +本チュートリアルでは、ベクトライザーとして [Weaviate Embeddings](../../weaviate/model-providers/weaviate/index.md) サービスを使用するため、外部埋め込みプロバイダー用の追加キーは不要です。Weaviate Embeddings ではデフォルトで `Snowflake/snowflake-arctic-embed-l-v2.0` モデルを利用します。

+別のベクトライザーを使用したい場合は、サポートされている [モデルプロバイダー](../../weaviate/model-providers/index.md) の一覧をご覧ください。 +::: + +### 1.2 Python ライブラリのインストール + +Weaviate Python クライアントと `agents` コンポーネントをインストールします。 + + + + +``` +pip install "weaviate-client[agents]" +``` + + + + +公開データセットへ簡単にアクセスできる軽量ライブラリ `datasets` も必要です。 + + + + +``` +pip install datasets +``` + + + + +import ForcePipInstall from "../_includes/_force_pip_install.mdx"; + + + +### 1.3 インスタンスへの接続 + +それでは、最初のステップで取得したパラメータを使用して Weaviate Cloud インスタンスに接続します。 + + + + + + + +このスニペットを実行すると `True` と表示され、インスタンスへの接続が成功したことを示します。 +## ステップ 2: コレクションの準備 + +以下のコードブロックでは、Hugging Face からデモ用データセットを取得し、Weaviate Sandbox クラスター内の新しいコレクションへ書き込んでいます。データを Weaviate にインポートする前に **コレクションを定義** する必要があります。つまり、データスキーマの設定とベクトライザー/埋め込みサービスの選択を行います。 + +### 2.1 コレクションの定義 + +import WeaviateAgentsArxivDataset from "/docs/agents/_includes/transformation_agent_tutorial_arxiv_dataset.png"; + +
+
+
+

+ この画像は、データセット ArxivPapers に含まれるオブジェクトの例です。 +

+
+
+
+
+ arXiv.org 論文データセット +
+
arXiv.org 論文データセット
+
+
+
+
+ +`ArxivPapers` コレクションには、インポートされるデータに基づいてプロパティを自動生成する [`auto-schema`](../../weaviate/config-refs/collections.mdx#auto-schema) オプションを使用します。 + + + + + + + +### 2.2 データベースへの投入 + +あらかじめベクトル化されたデータ [ArxivPapers](https://huggingface.co/datasets/weaviate/agents/viewer/transformation-agent-papers) を、Weaviate Cloud インスタンスへインポートします。 + + + + + + + +`len()` を呼び出すことで、インポートが正常に完了したかを確認し、コレクションのサイズを確認できます。 + +``` +Size of the ArxivPapers dataset: 200 +``` + +### 2.3 Explorer ツールでコレクションを確認 + +Transformation エージェントは、進行に合わせてコレクションを更新します。ここで「ArxivPapers」コレクションの内容を確認しておきましょう。正しくインポートされていれば、各オブジェクトに以下の 2 つのプロパティが表示されます。 + +- `title`: 論文のタイトル +- `abstract`: 論文のアブストラクト + +さらに、各オブジェクトの `vectors` も確認できます。 + +## ステップ 3: Transformation エージェントの設定 + +Transformation エージェントの中心となるのは「オペレーション」です。 + +これから、コレクションに対して実行したい変換オペレーションを定義します。オペレーションには次の 2 種類があります。 + +- **[新しいプロパティの追加](#31-新しいプロパティの追加)** +- **[既存プロパティの更新](#32-既存プロパティの更新)** + +### 3.1 新しいプロパティの追加 + +新しいプロパティを追加するには、次の要素を持つオペレーションを定義します。 + +- **`instruction`**: 自然言語で新しいプロパティに求める内容を記述します。 +- **`property_name`**: 付与するプロパティ名。 +- **`data_type`**: プロパティのデータ型(`DataType.TEXT`、`DataType.TEXT_ARRAY`、`DataType.BOOL`、`DataType.INT` など)。 +- **`view_properties`**: 既存プロパティの情報を基に新しいプロパティを作成する場合に、参照するプロパティを列挙します。 + +#### 3.1.1 トピック一覧の作成 + +まず、`topics` という `TEXT_ARRAY` 型の新しいプロパティを追加します。`abstract` を基に、LLM に最大 5 件までのトピックタグを抽出させましょう。 + + + + + + + +#### 3.1.2 フランス語訳の追加 + +次に、`abstract` プロパティをフランス語へ翻訳した `french_abstract` プロパティを追加します。 + + + + + + + +#### 3.1.3 NLP 関連度スコアの追加 + +今回は `INT` 型のプロパティを追加します。LLM に、論文が NLP にどれだけ関連しているかを 0 〜 10 のスコアで評価させます。 + + + + + + +#### 3.1.4 サーベイ論文かどうかの判定 + +最後に、論文がサーベイかどうかを示す `BOOL` プロパティを取得します。LLM は、その論文が新しい手法を提示しているのか、それとも既存手法のサーベイなのかを判断します。 + + + + + + + +### 3.2 既存プロパティの更新 + +:::caution + +他のエージェント操作に含まれるプロパティを更新しないでください。予測不能な動作につながります。 + +::: + +ここでは、これまでの操作で使用していない `title` プロパティを更新してみましょう。 + + + + + + + +## Step 4: Transformation エージェントの作成と実行 + +すべてのオペレーションを定義したら、`TransformationAgent` を初期化します。 + +エージェントを初期化する際には、どのコレクションを変更するかを指定する必要があります。ここでは、以前作成した "ArxivPapers" コレクションへアクセスさせます。 + +次に、エージェントが実行すべき `operations` のリストを渡します。ここでは、上で定義したすべてのオペレーションを指定します。 + + + + + + + +### 4.1 変換処理の実行 + +`update_all()` を呼び出すことで、各オペレーションごとに個別のワークフローが起動します。各オペレーションは、コレクション内の各オブジェクトに対して実行されます。 + + + + + + + +import WeaviateAgentsExplorerTool from "/docs/agents/_includes/transformation_agent_tutorial_explorer_tool.png"; + +
+
+

+ 変換結果を確認するには{" "} + Explorer tool{" "} + を開いてください。 +

+
+
+
+
+ Explorer tool in Weaviate Cloud +
+
Weaviate Cloud の Explorer tool
+
+
+
+
+ +出力例: + +``` +[TransformationResponse(operation_name='topics', workflow_id='TransformationWorkflow-7006854bd90f949b59bb8d88c816bdd6'), +TransformationResponse(operation_name='french_abstract', workflow_id='TransformationWorkflow-7a025ef11ef8e681adb0c273755d0a2a'), +TransformationResponse(operation_name='nlp_relevance', workflow_id='TransformationWorkflow-e6db777629ae7b38ca2f8f64df35c305'), +TransformationResponse(operation_name='is_survey_paper', workflow_id='TransformationWorkflow-e70d29827271f462f2a911ec29c6cb0c'), +TransformationResponse(operation_name='title', workflow_id='TransformationWorkflow-6b2ff75370e1f80ff537037fde02cb26')] +``` + +### 4.2 オペレーションワークフローの確認 + +非同期変換オペレーションの状態を確認するには、`agent.get_status(workflow_id)` 関数を使用します。 + + + + + + + +出力例: + +``` +{'workflow_id': 'TransformationWorkflow-f408a4a0211940525c0e2d45cf46a6c2', 'status': {'batch_count': 1, 'end_time': None, 'start_time': '2025-03-10 13:17:31', 'state': 'running', 'total_duration': None, 'total_items': 200}} +``` + +## まとめ + +このガイドでは、Weaviate のエージェントサービスを使用して、エンドツーエンドの Transformation エージェントを構築する方法を紹介しました。Weaviate Cloud インスタンスのセットアップから研究論文データセットのインポート、そしてデータを知的に強化する Transformation エージェントの構成までを説明しました。 + +Transformation エージェントは自然言語の instructions を自動で解釈し、データセット内のプロパティを作成または更新します。トピックタグ、翻訳、関連度スコアなどの新しいプロパティを追加してコレクションを処理し、データを強化してさらなる分析が行える状態にします。 +## 追加リソース + +- [Weaviate Agents - Transformation Agent](./index.md) + +## 質問とフィードバック + +:::info 変更履歴とフィードバック +Weaviate Agents の公式変更履歴は [こちら](https://weaviateagents.featurebase.app/changelog) でご覧いただけます。フィーチャーリクエストやバグ報告、質問などのフィードバックがある場合は、[こちら](https://weaviateagents.featurebase.app/) からご送信ください。送信後はご自身のフィードバックのステータスを確認したり、他のフィードバックに投票したりできます。 +::: + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/usage.md b/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/usage.md new file mode 100644 index 000000000..7339421b8 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/agents/transformation/usage.md @@ -0,0 +1,235 @@ +--- +title: 使用方法 +sidebar_position: 30 +description: "Transformation Agent を実装するための技術ドキュメントおよび使用例" +image: og/docs/agents.jpg +# tags: ['agents', 'getting started', 'transformation agent'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/docs/agents/_includes/transformation_agent.py'; + + +# Weaviate Transformation Agent:使用方法 + +:::caution Technical Preview + +![この Weaviate エージェントはテクニカルプレビュー版です。](../_includes/agents_tech_preview_light.png#gh-light-mode-only "この Weaviate エージェントはテクニカルプレビュー版です。") +![この Weaviate エージェントはテクニカルプレビュー版です。](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only "この Weaviate エージェントはテクニカルプレビュー版です。") + +[こちらから登録](https://events.weaviate.io/weaviate-agents)して Weaviate エージェントの通知を受け取る、または[このページ](https://weaviateagents.featurebase.app/)で最新情報の確認とフィードバックの送信ができます。 + +::: + +:::warning 本番環境での利用は避けてください +Weaviate Transformation Agent は Weaviate 内のデータをその場で変更するよう設計されています。**本エージェントがテクニカルプレビューの間は、本番環境では使用しないでください。** エージェントが期待どおりに動作しない可能性があり、Weaviate インスタンス内のデータが予期しない方法で影響を受ける可能性があります。 +::: + +Weaviate Transformation Agent は、生成モデルを用いてデータを拡張・変換するためのエージェント型サービスです。既存の Weaviate オブジェクトに対し、新しいプロパティを追加したり既存プロパティを更新したりできます。 + +これにより、アプリケーションでの利用に向けて Weaviate コレクション内のオブジェクト品質を向上させることができます。 + +![Weaviate Transformation Agent の概要](../_includes/transformation_agent_overview_light.png#gh-light-mode-only "Weaviate Transformation Agent の概要") +![Weaviate Transformation Agent の概要](../_includes/transformation_agent_overview_dark.png#gh-dark-mode-only "Weaviate Transformation Agent の概要") + +本ページでは、Weaviate Transformation Agent を使用して Weaviate 内のデータを変換・拡張する方法を説明します。 + +:::info 変更履歴とフィードバック +Weaviate エージェントの公式変更履歴は[こちら](https://weaviateagents.featurebase.app/changelog)でご覧いただけます。機能要望、バグ報告、質問などのフィードバックは[こちら](https://weaviateagents.featurebase.app/)から送信してください。送信後はステータスを確認したり、他のフィードバックに投票したりできます。 +::: + +## 前提条件 + +### Weaviate インスタンス + +本エージェントは Weaviate Cloud でのみ利用できます。 + +Weaviate Cloud インスタンスのセットアップ方法については、[Weaviate Cloud ドキュメント](/cloud/index.mdx)をご覧ください。 + +[Weaviate Cloud](https://console.weaviate.cloud/) の無料 Sandbox インスタンスで、この Weaviate エージェントをお試しいただけます。 + +### クライアントライブラリ + +:::note 対応言語 +現時点では、このエージェントは Python のみ対応しています。今後ほかの言語もサポート予定です。 +::: + +Weaviate エージェントを利用するには、`agents` 付きのオプションを使って Weaviate クライアントライブラリをインストールします。これにより、`weaviate-client` パッケージとともに `weaviate-agents` パッケージがインストールされます。 + +以下のコマンドでクライアントライブラリをインストールしてください。 + + + + +```shell +pip install -U weaviate-client[agents] +``` + +#### トラブルシューティング:`pip` に最新バージョンを強制インストールさせる + +すでにインストール済みの場合、`pip install -U "weaviate-client[agents]"` を実行しても `weaviate-agents` が[最新バージョン](https://pypi.org/project/weaviate-agents/)に更新されないことがあります。その場合は、`weaviate-agents` パッケージを明示的にアップグレードしてください。 + +```shell +pip install -U weaviate-agents +``` + +または[特定のバージョン](https://github.com/weaviate/weaviate-agents-python-client/tags)をインストールします。 + +```shell +pip install -U weaviate-agents==||site.weaviate_agents_version|| +``` + + + + + +## 使用方法 + +Transformation Agent を使用するには、必要な入力を指定してインスタンス化し、変換操作を開始します。 + +変換操作は非同期で実行されます。各操作はワークフロー ID を返すので、その ID を使ってステータスを確認します。 + +以下に使用例を示します。 + +### 前提条件 + +Transformation Agent は Weaviate Cloud と密接に統合されています。そのため、Transformation Agent は Weaviate Cloud インスタンスと、対応バージョンのクライアントライブラリでのみ利用できます。 + +### Weaviate への接続 + +Transformation Agent を利用するには、Weaviate Cloud インスタンスへ接続する必要があります。Weaviate クライアントライブラリを使用して接続してください。 + + + + + + + +### 変換操作の定義 + +Transformation Agent を開始する前に、変換操作を定義する必要があります。以下の情報を指定して操作を定義してください。 + +- 操作タイプ +- 対象プロパティ名 +- コンテキストとして使用するプロパティ +- instructions +- (新規プロパティの場合)新規プロパティのデータ型 + +以下に操作例を示します。 +#### データに新しいプロパティを追加 + +既存のプロパティ値とユーザーの instructions に基づいて、オブジェクトに新しいプロパティを追加できます。 + + + + + + + + +#### 既存プロパティの更新 + +既存のプロパティ値とユーザーの instructions に基づいて、オブジェクトの既存プロパティの値を更新できます。 + + + + + + + + +### 変換操作の開始 + +変換操作を開始するには、必要な入力で Transformation Agent をインスタンス化し、操作を開始します。 + +Weaviate クライアント、対象コレクション名、および変換操作のリストを指定して Transformation Agent をインスタンス化します。 + + + + + + + + +### ジョブステータスの監視 + +workflow ID を使用して、各変換操作のステータスを監視できます。 + + + + + + + + +## 制限事項とトラブルシューティング + +:::caution Technical Preview + +![この Weaviate エージェントはテクニカルプレビューです。](../_includes/agents_tech_preview_light.png#gh-light-mode-only "この Weaviate エージェントはテクニカルプレビューです。") +![この Weaviate エージェントはテクニカルプレビューです。](../_includes/agents_tech_preview_dark.png#gh-dark-mode-only "この Weaviate エージェントはテクニカルプレビューです。") + +[こちら](https://events.weaviate.io/weaviate-agents)から Weaviate エージェントの通知に登録するか、[このページ](https://weaviateagents.featurebase.app/)で最新情報の確認とフィードバックの送信ができます。 + +::: + +### 使用制限 + +現時点では、Weaviate Cloud の [組織](/cloud/platform/users-and-organizations.mdx#organizations) ごとに 1 日あたり 50,000 件の Transformation Agent 操作という上限があります。 + +この制限は個々の操作単位で適用されます。つまり、2,500 オブジェクトのコレクションに対して 4 つの操作を含む Transformation Agent を実行すると、その日の上限に達します。 + +この制限は今後のバージョンで変更される可能性があります。 + +### モデル入力コンテキストの長さ + +基盤モデルの制約により、変換操作の入力コンテキストの長さには制限があります。入力コンテキストの長さは約 25000 文字以下に抑えることを推奨します。 + +つまり、入力コンテキスト(コンテキストとして使用するプロパティ)と instructions の合計文字数がこの上限を超えないようにしてください。モデル入力コンテキストの長さが超過すると、変換操作は失敗します。 + +### 複数操作時の競合状態 + +同じコレクションで複数の変換操作を開始すると、race condition により一方の結果が上書きされる可能性があります。 + +これを避けるには、1 度に 1 つの操作のみを実行してください。同じコレクションで複数の操作を行う必要がある場合は、操作を順番に実行してください。 + +前の操作の workflow ID を使用してステータスを監視し、完了を確認してから次の操作を開始することで実現できます。 + +この問題は将来のバージョンで対応予定です。 + +## 質問とフィードバック + +:::info Changelog and feedback +Weaviate エージェントの公式変更履歴は[こちら](https://weaviateagents.featurebase.app/changelog)で確認できます。機能要望、バグ報告、質問などのフィードバックは[こちら](https://weaviateagents.featurebase.app/)にご投稿ください。フィードバックの状況を確認したり、他のフィードバックに投票したりできます。 +::: + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/administration.md b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/administration.md new file mode 100644 index 000000000..5edb7b155 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/administration.md @@ -0,0 +1,68 @@ +--- +title: 管理 +sidebar_position: 3 +description: "組織レベルでの Weaviate Embeddings サービスの設定と管理。" +image: og/wcd/user_guides.jpg +--- + +import Link from '@docusaurus/Link'; + + +:::info +Weaviate Embeddings はデフォルトで組織レベルで有効になっており、すべての Weaviate Cloud ユーザーが利用できます。 +::: + +## Weaviate Embeddings の無効化 + +Weaviate Embeddings は組織レベルで **デフォルトで有効** になっています。組織全体で Weaviate Embeddings サービスを無効にするには、次の手順に従ってください。 + +import DisableWeaviateEmbeddings from '/docs/cloud/img/weaviate-cloud-disable-embeddings.png'; + +
+
+
    +
  1. + Weaviate Cloud コンソール を開きます。 +
  2. +
  3. + 左側のサイドバー (1) で Weaviate Embeddings をクリックします。 +
  4. +
  5. + Enabled トグルボタン (2) を使用してサービスを有効化または無効化します。 +
  6. +
+
+
+
+
+ Weaviate Embeddings をグローバルで無効化 +
+
Weaviate Embeddings をグローバルで無効化します。
+
+
+
+ + + +## 料金と課金 + + +料金モデルの詳細については、Weaviate Embeddings の [製品ページ](https://weaviate.io/product/embeddings) をご覧ください。 +料金はトークン単位で計算されます。つまり、実際に消費されたトークン分のみ課金されます。言い換えると、API から有効なレスポンスが返されたリクエストのみが課金対象になります。 + +Weaviate Cloud の課金に関する詳細は [こちらのページ](/cloud/platform/billing) でご確認いただけます。 + +## 追加リソース + +- [Weaviate Embeddings: 概要](/cloud/embeddings) +- [Weaviate Embeddings: クイックスタート](/cloud/embeddings/quickstart) +- [Weaviate Embeddings: モデルの選択](/cloud/embeddings/models) +- [モデルプロバイダー統合: Weaviate Embeddings](/weaviate/model-providers/weaviate/embeddings.md) + +## サポートとフィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/index.md new file mode 100644 index 000000000..ee74dbdd7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/index.md @@ -0,0 +1,90 @@ +--- +title: Weaviate Embeddings +sidebar_position: 0 +description: "Weaviate Cloud から直接データとクエリの埋め込みを生成する、マネージド埋め込み推論サービスです。" +image: og/wcd/user_guides.jpg +--- + +Weaviate Embeddings は、Weaviate Cloud ユーザー向けのマネージド埋め込み推論サービスです。データとクエリの埋め込みを、Weaviate Cloud データベース インスタンスから直接、簡単に生成できます。 + +![Weaviate Embeddings flowchart](../img/weaviate-embeddings-flowchart.png "Weaviate Embeddings flowchart") + +:::info +Weaviate Embeddings は有料サービスで、Weaviate Cloud インスタンスでのみご利用いただけます。 +**Sandbox クラスターを使用すると無料でお試しいただけます。** +::: + +Weaviate Embeddings を使うと、Weaviate Cloud データベース インスタンスから直接、データとクエリの埋め込みを生成できます。 + +これにより、外部でベクトル埋め込みを生成したり、追加のモデルプロバイダーを管理したりすることなく、[キーワード](/weaviate/search/bm25)、[ベクトル](/weaviate/search/similarity)、および[ハイブリッド検索](/weaviate/search/hybrid)を実行できます。 + +:::tip Quickstart +Weaviate Embeddings をすぐに使い始めたい場合は、**[クイックスタート ガイド](/cloud/embeddings/quickstart)** をご覧ください。 +::: + + + +## 利用可能なモデル + +Weaviate Embeddings で利用できるモデルは次のとおりです。 + +- **[`Snowflake/snowflake-arctic-embed-m-v1.5`](/cloud/embeddings/models#snowflake-arctic-embed-m-v1.5)** +- **[`Snowflake/snowflake-arctic-embed-l-v2.0`](/cloud/embeddings/models#snowflake-arctic-embed-l-v2.0)** + +## 認証 + +Weaviate Embeddings を利用するには、[Weaviate Cloud クラスターへの接続](/cloud/manage-clusters/connect)だけで十分です。 +追加の認証は不要で、Weaviate Embeddings サービスはすべてのクラスターでデフォルトで有効になっています。 +[クライアント ライブラリ](/weaviate/client-libraries)を使用して接続する場合でも、[OIDC](/weaviate/configuration/authz-authn#oidc)などで接続する場合でも、サービスをご利用いただけます。 + +## 使用制限 + + +Weaviate Embeddings では、無料の Sandbox クラスターに対するリクエストにのみ使用制限を設けています。 +Sandbox クラスターのレートリミットは、クラスターあたり 1 日 `2000` リクエストです。 + +:::info +[バッチ インポート](/weaviate/manage-objects/import)でデータをベクトル化する場合、1 バッチの最大サイズは `200` オブジェクトです。 +つまり、無料の Sandbox クラスターでは最大 `400 000` 個の埋め込み(`2000`(リクエスト) × `200`(オブジェクト/リクエスト))を生成できます。 +::: + +## 必要条件 + +import Requirements from '/_includes/weaviate-embeddings-requirements.mdx'; + + + +## データ プライバシー + +Weaviate Embeddings はステートレス サービスで、データを保存しません。 + +Weaviate Embeddings に提供されたデータは、埋め込みを生成する目的のみに使用されます。当社は、お客様のデータをトレーニングやモデル改善など、ほかの目的で保存または使用することはありません。 + +### サービスとデータの所在地 + +Weaviate Embeddings は、アメリカ合衆国にあるインフラストラクチャを利用しています。 +Weaviate Embeddings を利用することで、データが処理のために米国へ転送されることに同意したものとみなされます。 + +今後、ほかのリージョンへサービスを拡大する可能性があります。 + +## 追加リソース + +- [Weaviate Embeddings: クイックスタート](/cloud/embeddings/quickstart) +- [Weaviate Embeddings: モデルの選択](/cloud/embeddings/models) +- [Weaviate Embeddings: 管理](/cloud/embeddings/administration) +- [モデル プロバイダー統合: Weaviate Embeddings](/weaviate/model-providers/weaviate/embeddings.md) + +## サポートとフィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/models.md b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/models.md new file mode 100644 index 000000000..e2308ec8d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/models.md @@ -0,0 +1,58 @@ +--- +title: モデルの選択 +sidebar_label: モデルの選択 +sidebar_position: 2 +description: "複数言語に対応し、エンタープライズ向け検索タスクに最適化された事前学習済み埋め込みモデルの一覧。" +image: og/wcd/user_guides.jpg +--- + +このページでは、英語およびその他の言語でのエンタープライズ検索タスク向けに特化した事前学習済みモデルの一覧を確認できます。今後さらにモデルや機能が追加される予定ですので、定期的にご確認ください。 + +## 適切なモデルの選び方 + +以下は、特定のモデルを使用すべきシンプルな推奨事項です。 + +- **[`Snowflake/snowflake-arctic-embed-m-v1.5`](#snowflake-arctic-embed-m-v1.5)** + 主に **English** で、テキストの長さが通常 **512 tokens** 未満のデータセットに最適です。 +- **[`Snowflake/snowflake-arctic-embed-l-v2.0`](#snowflake-arctic-embed-l-v2.0)** + **複数言語**を含むデータセットや、**8192 tokens** までの長いコンテキストが必要な場合に理想的です。このモデルは、English と多言語の両方の検索タスクで高いパフォーマンスを発揮するよう最適化されています。 + +以下に、利用可能なすべてのモデルを一覧で示します。 + +--- + +## 利用可能なモデル + + + +import WeaviateEmbeddingsModels from '/_includes/weaviate-embeddings-models.mdx'; + + + +## ベクトライザー パラメーター + +import WeaviateEmbeddingsVectorizerParameters from '/_includes/weaviate-embeddings-vectorizer-parameters.mdx'; + + + +## 追加リソース + +- [Weaviate Embeddings: 概要](/cloud/embeddings) +- [Weaviate Embeddings: クイックスタート](/cloud/embeddings/quickstart) +- [Weaviate Embeddings: 管理](/cloud/embeddings/administration) +- [モデル プロバイダー統合: Weaviate Embeddings](/weaviate/model-providers/weaviate/embeddings.md) + +## サポート & フィードバック + +import SupportAndTrouble from '/\_includes/wcs/support-and-troubleshoot.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/quickstart.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/quickstart.mdx new file mode 100644 index 000000000..3f3e6a891 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/embeddings/quickstart.mdx @@ -0,0 +1,306 @@ +--- +title: クイックスタート +sidebar_position: 1 +description: Weaviate Embeddings サービスを使用してデータをインポートし検索するための入門ガイド。 +image: og/wcd/user_guides.jpg +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyConnect from "!!raw-loader!/docs/weaviate/model-providers/_includes/provider.connect.weaviate.py"; +import TSConnect from "!!raw-loader!/docs/weaviate/model-providers/_includes/provider.connect.weaviate.ts"; +import GoConnect from "!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect-weaviate-embeddings/main.go"; +import JavaConnect from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/ConnectWeaviateEmbeddingsTest.java"; +import PyCode from "!!raw-loader!/docs/weaviate/model-providers/_includes/provider.vectorizer.py"; +import TSCode from "!!raw-loader!/docs/weaviate/model-providers/_includes/provider.vectorizer.ts"; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/UsageWeaviateTextEmbeddingsArcticEmbedLV20.java"; +import JavaImportQueries from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/ImportAndQueries.java"; + +想定所要時間: 30 分 +
+
+ +:::info 学べること + +このクイックスタートでは、 Weaviate Cloud と **Weaviate Embeddings** を組み合わせて以下を行う方法を学びます。 + +1. Weaviate Cloud インスタンスをセットアップします。(10 分) +2. Weaviate Embeddings を使ってデータを追加しベクトル化します。(10 分) +3. セマンティック(ベクトル)検索とハイブリッド検索を実行します。(10 分) + +```mermaid +flowchart LR + %% Define nodes with white backgrounds and darker borders + A1["Create a new
cluster"] --> A2["Install client
library"] + A2 --> A3["Connect to
Weaviate Cloud"] + A3 --> B1["Configure the
vectorizer"] + B1 --> B2["Import
objects"] + B2 --> C1["Semantic (vector)
search"] + + %% Group nodes in subgraphs with brand colors + subgraph sg1 ["1\. Setup"] + A1 + A2 + A3 + end + + subgraph sg2 ["2\. Populate"] + B1 + B2 + end + + subgraph sg3 ["3\. Query"] + C1 + end + + %% Style nodes with white background and darker borders + style A1 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style A2 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style A3 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style B1 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style B2 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style C1 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + + %% Style subgraphs with brand colors + style sg1 fill:#ffffff,stroke:#61BD73,stroke-width:2px,color:#130C49 + style sg2 fill:#ffffff,stroke:#130C49,stroke-width:2px,color:#130C49 + style sg3 fill:#ffffff,stroke:#7AD6EB,stroke-width:2px,color:#130C49 +``` + +注意: + +- ここに掲載しているコード例は自己完結型です。コピー&ペーストしてご自身の環境でそのままお試しいただけます。 + +::: + +## 必要条件 + +Weaviate Embeddings を利用するには、次が必要です。 + + + +- Weaviate `1.28.5` 以上で稼働する Weaviate Cloud Sandbox +- Weaviate Embeddings をサポートする Weaviate クライアント ライブラリ + - **Python** クライアント バージョン `4.9.5` 以上 + - **JavaScript/TypeScript** クライアント バージョン `3.2.5` 以上 + - **Go/Java** クライアントはまだ公式サポートされていません。以下の例のように、インスタンス化時に `X-Weaviate-Api-Key` と `X-Weaviate-Cluster-Url` ヘッダーを手動で渡す必要があります。 + +## ステップ 1: Weaviate をセットアップ + +### 1.1 新しいクラスターの作成 + +無料の **Sandbox** クラスターを Weaviate Cloud に作成するには、**[こちらの手順](/cloud/manage-clusters/create#create-a-cluster)** に従ってください。 + +import LatestWeaviateVersion from "/_includes/latest-weaviate-version.mdx"; + + + +### 1.2 クライアント ライブラリをインストール + +Weaviate を操作する際には [クライアント ライブラリ](/weaviate/client-libraries) の利用を推奨します。以下の手順に従って、公式クライアント ライブラリ([Python](/weaviate/client-libraries/python)、[JavaScript/TypeScript](/weaviate/client-libraries/typescript)、[Go](/weaviate/client-libraries/go)、[Java](/weaviate/client-libraries/java))のいずれかをインストールしてください。 + +import CodeClientInstall from "/_includes/code/quickstart/clients.install.mdx"; + + + +### 1.3 Weaviate Cloud に接続 + +Weaviate Embeddings は Weaviate Cloud と統合されています。 Weaviate Cloud の認証情報が、 Weaviate Embeddings へのアクセス許可に使用されます。 + + + + + + + + + + + + + + + + +## ステップ 2: データベースを準備する + +### 2.1 コレクションを定義する + +次に、データを格納するコレクションを定義します。コレクションを作成する際には、ベクトライザーが使用する [利用可能なモデル](/cloud/embeddings/models) のいずれかを指定する必要があります。このモデルが、データからベクトル埋め込みを生成します。 + + + + + + + + + + + + + + + + +利用可能なモデルの詳細については、[モデルを選択](/cloud/embeddings/models) ページをご覧ください。 + + + +### 2.2 オブジェクトのインポート + +ベクトライザーを設定したら、[データをインポート](/weaviate/manage-objects/import.mdx) して Weaviate に取り込みます。Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + +## ステップ 3:データのクエリ + +ベクトライザーが設定されると、Weaviate は指定したモデルを使用してベクトル検索を実行します。 + +### ベクトル( near text )検索 + +[ベクトル検索](/weaviate/search/similarity.md#search-with-text) を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数だけデータベースから最も類似した n 個のオブジェクトを返します。 + + + + + + + + + + + + + + + + +## 次のステップ + +import CardsSection from "/src/components/CardsSection"; + +export const nextStepsData = [ + { + title: "Choose a model", + description: + "Check out which additional models are available through Weaviate Embeddings.", + link: "/cloud/embeddings/models", + icon: "fa fa-list-alt", + }, + { + title: "Explore hybrid search", + description: + "Discover how hybrid search combines keyword matching and semantic search.", + link: "/weaviate/search/hybrid", + icon: "fa fa-search", + }, +]; + + +
+ +## サポートとフィードバック + +import SupportAndTrouble from "/_includes/wcs/support-and-troubleshoot.mdx"; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/faq.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/faq.mdx new file mode 100644 index 000000000..f5b44f696 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/faq.mdx @@ -0,0 +1,124 @@ +--- +title: よくある質問 +sidebar_position: 7 +description: "Weaviate Cloud ( WCD ) の機能、料金、トラブルシューティングに関するよくある質問と回答。" +image: og/wcd/faq.jpg +--- + +[ Weaviate Cloud ( WCD )](https://console.weaviate.cloud/) に関するよくある質問 ( FAQ ) をまとめています。 + +## 機能 + +#### Q: Weaviate Cloud は他のデプロイ方法とどのように違いますか? + +
+ Answer + +Weaviate Cloud を使用すると、テスト用に 14 日間無料で利用できるサンドボックスにアクセスできます。さらに、すべてのデプロイ方法で利用できるわけではない [ Weaviate Embeddings ](docs/cloud/embeddings/index.md) や [ Weaviate Agents ](docs/agents/index.md) などの高度な機能も利用できます。 + +
+ +## アカウント管理 + +#### Q: アカウントのパスワードをリセットまたは変更できますか? {#reset-password} + +
+ Answer + +はい。[ Weaviate Cloud ログインページ](https://console.weaviate.cloud/) にアクセスし、"Log in" ボタンをクリックしてください。その後 **"Forgot Password"** をクリックしてメールアドレスを入力します。そのアドレスにリセット用メールが届きます。 + +
+ +#### Q: 認証メールが届きません。 + +
+ Answer + +受信トレイに認証メールが見当たらない場合は、迷惑メールフォルダーを確認してください。それでも届いていない場合は、[ パスワードをリセット ](./faq.mdx#reset-password) して再送できます。 + +
+ +## インスタンス管理 + +#### Q: Weaviate Cloud クラスターはバックアップされていますか? + +
+ Answer + +はい。Weaviate Cloud では毎日自動バックアップを実行しています。また、クラスターのバージョンを更新する前にもデータをバックアップします。 + +
+ +#### Q: Weaviate Cloud クラスターを新しいバージョンに更新できますか? + +
+ Answer + +はい。Cloud Console で対象クラスターを開き **"Details."** をクリックしてください。新しいバージョンが利用可能な場合は **"Update!"** ボタンが表示されます。安全なメンテナンス時間帯にのみ更新してください。 + +
+ +#### Q: クラスターリソースは自動でスケールしますか? + +
+ Answer + +現時点では自動スケーリングは行われません。Weaviate Cloud がクラスターを監視し、リサイズが必要と思われる場合に通知は行いますが、デフォルトでは自動スケールは無効です。 + +
+ +#### Q: 追加のクラスターリソースを要求できますか? + +
+ Answer + +可能な場合があります。[support@weaviate.io](mailto:support@weaviate.io) までご連絡いただき、カスタムプロビジョニングやリソース増強のご要望をお知らせください。 + +
+ +#### Q: 同時にいくつのクラスターを作成できますか? + +
+ Answer + +デフォルトでは、各組織につき **six ( 6 )** 件の serverless クラスターと **two ( 2 )** 件の sandbox クラスターを作成できます。さらに必要な場合は [ サポートへお問い合わせください ](mailto:support@weaviate.io)。 + +
+ +## インフラストラクチャ + +#### Q: Weaviate Cloud はどのインフラストラクチャ上で稼働していますか? + +
+ Answer + +現在、Weaviate Cloud は **Google Cloud Platform ( GCP )** 上で稼働しています。**AWS** と **Azure** への対応もロードマップにあります。 + +
+ +## Weaviate Cloud Console + +#### Q: Weaviate Cloud Console はユーザーデータを収集しますか? + +
+ Answer + +コンソールは Weaviate インスタンスからデータを収集 **しません**。インフラ管理・保守のために **operational metrics** のみを収集します。 + +
+ +#### Q: Weaviate Cloud Console から Weaviate Cloud 以外のインスタンスに接続できますか? + +
+ Answer + +はい。Weaviate Cloud Console にある GraphQL クエリツールは、公開アクセス可能であれば **外部 Weaviate インスタンス** にも接続できます。 + +
+ +## サポート + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/cluster-status.modules.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/cluster-status.modules.png new file mode 100644 index 000000000..fd07c7fcb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/cluster-status.modules.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/enable_weaviate_embeddings.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/enable_weaviate_embeddings.png new file mode 100644 index 000000000..74796a3f0 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/enable_weaviate_embeddings.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-1.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-1.png new file mode 100644 index 000000000..8fe024140 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-1.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-2.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-2.png new file mode 100644 index 000000000..24d83dcd9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-2.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-3.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-3.png new file mode 100644 index 000000000..0dda0cab1 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-3.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-4.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-4.png new file mode 100644 index 000000000..68694aa9b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-4.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-5.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-5.png new file mode 100644 index 000000000..6eae312ba Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-5.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-6.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-6.png new file mode 100644 index 000000000..9614d5dc6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-6.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-7.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-7.png new file mode 100644 index 000000000..c75a1ddb3 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/explorer-7.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/mfa-enable-icon.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/mfa-enable-icon.jpg new file mode 100644 index 000000000..7fa724dab Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/mfa-enable-icon.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/mfa-one-time-code.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/mfa-one-time-code.jpg new file mode 100644 index 000000000..7fead9494 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/mfa-one-time-code.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/orgs-update-name-before.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/orgs-update-name-before.jpg new file mode 100644 index 000000000..c2c91ad92 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/orgs-update-name-before.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/orgs-update-name-confirm.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/orgs-update-name-confirm.jpg new file mode 100644 index 000000000..40a48f19f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/orgs-update-name-confirm.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/query-app-example.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/query-app-example.jpg new file mode 100644 index 000000000..a7df92385 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/query-app-example.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/register.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/register.png new file mode 100644 index 000000000..5559a2bc8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/register.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-extra-props.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-extra-props.jpg new file mode 100644 index 000000000..8571d4481 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-extra-props.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-general.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-general.jpg new file mode 100644 index 000000000..c9680d2c2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-general.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-objs.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-objs.jpg new file mode 100644 index 000000000..06ff2414e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-objs.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-props.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-props.jpg new file mode 100644 index 000000000..6a8df7bc6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-ed-props.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-select-mod.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-select-mod.jpg new file mode 100644 index 000000000..b8bca014f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcd-coll-select-mod.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-add-key-details.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-add-key-details.jpg new file mode 100644 index 000000000..c2ef5eb47 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-add-key-details.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-api-keys.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-api-keys.jpg new file mode 100644 index 000000000..21d310573 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-api-keys.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-auth-header.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-auth-header.jpg new file mode 100644 index 000000000..0d7c0bb0c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-auth-header.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-connected-instances.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-connected-instances.jpg new file mode 100644 index 000000000..ea7a27df1 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-connected-instances.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-connected-instances.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-connected-instances.png new file mode 100644 index 000000000..29f620a30 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-connected-instances.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-api-keys-expanded.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-api-keys-expanded.jpg new file mode 100644 index 000000000..055020fa6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-api-keys-expanded.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-button.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-button.png new file mode 100644 index 000000000..c926511ac Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-button.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-details-api-key.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-details-api-key.jpg new file mode 100644 index 000000000..9b80e9ee6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-details-api-key.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-example-query.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-example-query.png new file mode 100644 index 000000000..25f8020a3 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-example-query.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-inference-key.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-inference-key.png new file mode 100644 index 000000000..dfa2e5c73 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-inference-key.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-many-inference-keys.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-many-inference-keys.png new file mode 100644 index 000000000..b3b7ad11b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-many-inference-keys.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-no-clusters.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-no-clusters.jpg new file mode 100644 index 000000000..4e2cb8b84 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-no-clusters.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-url-check.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-url-check.jpg new file mode 100644 index 000000000..876845a71 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-console-url-check.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-create.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-create.png new file mode 100644 index 000000000..4dd87a968 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-create.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-creation-progress.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-creation-progress.png new file mode 100644 index 000000000..a7f38678c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-creation-progress.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-delete-api-key.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-delete-api-key.jpg new file mode 100644 index 000000000..cd38bdb91 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-delete-api-key.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-details-cluster-url.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-details-cluster-url.jpg new file mode 100644 index 000000000..fe42289b5 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-details-cluster-url.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-details-icon.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-details-icon.jpg new file mode 100644 index 000000000..69b1d416a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-details-icon.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-get-key.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-get-key.png new file mode 100644 index 000000000..033f3edeb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-get-key.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-landing-page-register.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-landing-page-register.jpg new file mode 100644 index 000000000..750583e5b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-landing-page-register.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-options.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-options.png new file mode 100644 index 000000000..c18218517 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-options.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-query-console-location.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-query-console-location.jpg new file mode 100644 index 000000000..113379a0a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-query-console-location.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-query-dropdown.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-query-dropdown.png new file mode 100644 index 000000000..da38292fa Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/wcs-query-dropdown.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-add-organization.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-add-organization.png new file mode 100644 index 000000000..4a27e5a21 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-add-organization.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-advanced-configuration.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-advanced-configuration.png new file mode 100644 index 000000000..e06bf4de9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-advanced-configuration.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-create-form.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-create-form.png new file mode 100644 index 000000000..316bee8e3 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-create-form.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-create.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-create.png new file mode 100644 index 000000000..b1d84f968 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-create.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-delete.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-delete.png new file mode 100644 index 000000000..a660dab01 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-delete.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-edit.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-edit.png new file mode 100644 index 000000000..bb4d7cbca Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-edit.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-management.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-management.png new file mode 100644 index 000000000..eac452a8c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-management.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-rotate.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-rotate.png new file mode 100644 index 000000000..851761a4b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-rotate.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-save.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-save.png new file mode 100644 index 000000000..784cba7ff Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-key-save.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-keys.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-keys.png new file mode 100644 index 000000000..b218b2eaa Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-api-keys.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-billing-section.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-billing-section.png new file mode 100644 index 000000000..94215c4e1 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-billing-section.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-cluster-details.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-cluster-details.png new file mode 100644 index 000000000..3e0268fdb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-cluster-details.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-collection-details.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-collection-details.png new file mode 100644 index 000000000..28b94568e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-collection-details.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-cluster.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-cluster.png new file mode 100644 index 000000000..f7ada9fbd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-cluster.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-collection.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-collection.png new file mode 100644 index 000000000..a61bd2a4b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-collection.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-new-cluster.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-new-cluster.png new file mode 100644 index 000000000..e718d12d8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-create-new-cluster.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-api-key-confirm.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-api-key-confirm.png new file mode 100644 index 000000000..752358abf Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-api-key-confirm.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-api-key.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-api-key.png new file mode 100644 index 000000000..75987c5a9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-api-key.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-collection-confirm.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-collection-confirm.png new file mode 100644 index 000000000..ee88de41b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-collection-confirm.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-collection.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-collection.png new file mode 100644 index 000000000..3088ba55d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-collection.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-organization.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-organization.png new file mode 100644 index 000000000..fd7301264 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-delete-organization.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-disable-embeddings.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-disable-embeddings.png new file mode 100644 index 000000000..94fc3d2eb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-disable-embeddings.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-edit-support-plan.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-edit-support-plan.png new file mode 100644 index 000000000..58a58083c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-edit-support-plan.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-enable-mfa.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-enable-mfa.png new file mode 100644 index 000000000..f80e7f059 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-enable-mfa.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-endpoint-urls.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-endpoint-urls.png new file mode 100644 index 000000000..cb0e04e17 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-endpoint-urls.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-flowchart.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-flowchart.png new file mode 100644 index 000000000..a5aae415c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-flowchart.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-collection-settings.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-collection-settings.png new file mode 100644 index 000000000..a8bb5f0cc Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-collection-settings.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-confirm.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-confirm.png new file mode 100644 index 000000000..00394f76d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-confirm.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-explorer.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-explorer.png new file mode 100644 index 000000000..1c167ff67 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-explorer.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-property-settings.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-property-settings.png new file mode 100644 index 000000000..1a9f4bc0f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-property-settings.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-start.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-start.png new file mode 100644 index 000000000..98378ab33 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-import-tool-start.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-mfa.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-mfa.png new file mode 100644 index 000000000..0e2919643 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-mfa.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-new-api-key-confirm.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-new-api-key-confirm.png new file mode 100644 index 000000000..19a6c3648 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-new-api-key-confirm.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-new-api-key.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-new-api-key.png new file mode 100644 index 000000000..1de510aca Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-new-api-key.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-organization-settings.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-organization-settings.png new file mode 100644 index 000000000..c8da11b04 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-organization-settings.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool-console.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool-console.png new file mode 100644 index 000000000..ebeaabeed Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool-console.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool-preview.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool-preview.png new file mode 100644 index 000000000..81a01ab44 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool-preview.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool.png new file mode 100644 index 000000000..2c1cf7cd8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-query-tool.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-register.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-register.png new file mode 100644 index 000000000..cc2d44b29 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-register.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-create-form.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-create-form.png new file mode 100644 index 000000000..1bbc726f4 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-create-form.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-create.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-create.png new file mode 100644 index 000000000..9fd09aa80 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-create.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-delete-form.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-delete-form.png new file mode 100644 index 000000000..d99376032 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-delete-form.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-delete.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-delete.png new file mode 100644 index 000000000..ac677b4d6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-delete.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-edit-form.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-edit-form.png new file mode 100644 index 000000000..2fa868d1e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-edit-form.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-edit.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-edit.png new file mode 100644 index 000000000..1d9d83547 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-roles-edit.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-sandbox-cluster.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-sandbox-cluster.png new file mode 100644 index 000000000..cc5119e20 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-sandbox-cluster.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-select-support-plan.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-select-support-plan.png new file mode 100644 index 000000000..79fa4779f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-select-support-plan.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-serverless-cluster.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-serverless-cluster.png new file mode 100644 index 000000000..d6a4ba33d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-serverless-cluster.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-update-cluster-confirm.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-update-cluster-confirm.png new file mode 100644 index 000000000..9ffaf3b31 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-update-cluster-confirm.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-update-cluster.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-update-cluster.png new file mode 100644 index 000000000..2146ac2e8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-cloud-update-cluster.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-embeddings-flowchart.png b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-embeddings-flowchart.png new file mode 100644 index 000000000..b9563f78c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/img/weaviate-embeddings-flowchart.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/index.mdx new file mode 100644 index 000000000..35e0a710b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/index.mdx @@ -0,0 +1,46 @@ +--- +title: Weaviate Cloud +sidebar_label: Introduction +description: "マネージド型ベクトルデータベースのデプロイと運用向けドキュメントである Weaviate Cloud ( WCD ) の概要です。" +sidebar_position: 0 +image: og/wcd/title.jpg +--- + +import WCDLandingIntro from '/_includes/wcs/wcs-landing-intro.mdx' + + + +![Weaviate Cloud フローチャート](./img/weaviate-cloud-flowchart.png "Weaviate Cloud フローチャート") + +:::tip Quickstart + Weaviate Cloud を始めるには、**[クイックスタートガイド](/cloud/quickstart)** をご覧ください。 +::: + +## Weaviate Cloud と Weaviate Database + +import WCDLandingOpenSource from '/_includes/wcs/wcs-landing-open-source.mdx' + + + +## Weaviate Cloud ソリューション + +import WCDLandingSolutions from '/_includes/wcs/wcs-landing-solutions.mdx' + + + +## 開始方法 + +import WCDLandingGetStarted from '/_includes/wcs/wcs-landing-get-started.mdx' + + + +## サポートとフィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + +import CustomScriptLoader from '/src/components/scriptSwitch'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/authentication.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/authentication.mdx new file mode 100644 index 000000000..5b28c6f5e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/authentication.mdx @@ -0,0 +1,347 @@ +--- +title: 認証 +sidebar_position: 5 +description: "API キーの追加、更新、削除によって Weaviate Cloud クラスターの認証オプションを設定します。" +image: og/wcd/user_guides.jpg +--- + +import WCDAPIKeys from '/docs/cloud/img/wcs-api-keys.jpg'; +import WCDAddAPIKeys from '/docs/cloud/img/wcs-add-key-details.jpg'; +import WCDDelAPIKeys from '/docs/cloud/img/wcs-delete-api-key.jpg'; +import RestartTheCluster from '/_includes/wcs/restart-warning.mdx'; + +RBAC(Role-Based Access Control)の有効/無効に応じて、クラスター認証を管理する方法は 2 つあります。 +- [RBAC 有効時の認証](#authentication-with-rbac-enabled) +- [RBAC 無効時の認証](#authentication-with-rbac-disabled) + +## RBAC 有効時の認証 + +このセクションは、[RBAC(Role-Based Access Control)](/weaviate/configuration/rbac/index.mdx) が有効になっているクラスターにのみ適用されます。Weaviate バージョン `v1.30` 以降で作成された新規クラスターでは、RBAC はデフォルトで有効になっています。 + +### API キーの作成 + +import CreateAPIKeys from '/_includes/wcs/create-api-keys.mdx'; + + + +### API キーのローテーション + +API キーをローテーションすると、古いキーを無効化しつつ新しいキーを生成できるため、セキュリティが向上します。 + +import RotateAPIKey from '/docs/cloud/img/weaviate-cloud-api-key-management.png'; +import RotateAPIKeyConfirm from '/docs/cloud/img/weaviate-cloud-api-key-rotate.png'; + +
+
+
    +
  1. + {' '}Weaviate Cloud コンソール を開きます。 +
  2. +
  3. + {' '}クラスターを選択し、API Keys セクションへ移動します。 +
  4. +
  5. + ローテーションしたい API キーを見つけ、隣の Rotate ボタン(画像の 1)をクリックします。 +
  6. +
+
+
+
+
+ Rotate an API key in Weaviate Cloud +
+
Weaviate Cloud で API キーをローテーションします。
+
+
+
+
+ +
+
+
    +
  1. + 古いキーが無効化される旨の確認ダイアログが表示されます。Rotate key をクリックして続行します(画像の 1)。 +
  2. +
  3. + 新しい API キーが生成されます。2 新しいキーは再表示できないため、必ず直ちにコピーして安全な場所に保存してください。 +
  4. +
+
+
+
+
+ Confirm API key rotation +
+
API キーのローテーションを確認します。
+
+
+
+ +### API キーの編集 + +API キーを編集すると、その名前や関連付けられているロールを変更できます。クラスターの API キーを編集する手順は以下のとおりです。 + +import EditAPIKey from '/docs/cloud/img/weaviate-cloud-api-key-management.png'; +import EditAPIKeyForm from '/docs/cloud/img/weaviate-cloud-api-key-edit.png'; + +
+
+
    +
  1. + {' '}Weaviate Cloud コンソール を開きます。 +
  2. +
  3. + {' '}クラスターを選択し、API Keys セクションへ移動します。 +
  4. +
  5. + 編集したい API キーを見つけ、隣の Edit ボタン(画像の 1)をクリックします。 +
  6. +
+
+
+
+
+ Edit an API key in Weaviate Cloud +
+
Weaviate Cloud で API キーを編集します。
+
+
+
+
+ +
+
+
    +
  1. + Edit API key フォームで、キーの説明/名前(1)を変更できます。 +
  2. +
  3. + この API キーに関連付けるロールも更新できます。既存のロールから選択するか、{' '}別のロールを割り当ててください(2)。 +
  4. +
  5. + Save ボタン(3)をクリックして変更を適用します。 +
  6. +
+
+
+
+
+ Edit API key details +
+
API キーの詳細を編集します。
+
+
+
+ + + +### API キーの削除 + +API キーを削除するには、次の手順に従います: + +import DeleteAPIKeyRBAC from '/docs/cloud/img/weaviate-cloud-delete-api-key.png'; + +
+
+
    +
  1. + Weaviate Cloud コンソールを開きます。 +
  2. +
  3. + + クラスターを選択 + {' '} + し、API Keys セクションに移動します。 +
  4. +
  5. + 削除したい API キーを探し、その横にある Delete ボタンをクリックします (1)。 +
  6. +
+
+
+
+
+ Weaviate Cloud で API キーを削除 +
+
Weaviate Cloud で API キーを削除します。
+
+
+
+
+ +import DeleteAPIKeyConfirmRBAC from '/docs/cloud/img/weaviate-cloud-delete-api-key-confirm.png'; + +
+
+
    +
  1. + 確認ダイアログが表示されます。削除を確定するために必要なテキスト(通常は API キー名または確認用フレーズ)を入力します (1)。 +
  2. +
  3. + Confirm and delete ボタンをクリックします (2)。 +
  4. +
+
+
+
+
+ API キーの削除を確認 +
+
API キーの削除を確認します。
+
+
+
+ +## RBAC 無効時の認証 + +[RBAC(Role-Based Access Control)](/weaviate/configuration/rbac/index.mdx) が有効になっていない場合、デフォルトで `ReadOnly` と `Admin` の 2 つの API キーが存在します。 + +- `Admin` キーは読み書きが可能です。 +- `ReadOnly` キーにはデータベースへの書き込み権限がありません。 + +Serverless クラスターをお持ちの場合、API キーの作成、削除、編集、およびローテーションが可能です。Sandbox クラスターのキーは変更できません。 + +### API キーの取得 + +import RetrieveAPIKeys from '/_includes/wcs/retrieve-api-keys.mdx'; + + + +### API キーの作成 + +Serverless クラスターをお持ちの場合、新しい API キーを作成できます。新しい API キーを作成するには、次の手順に従ってください: + +import Link from '@docusaurus/Link'; +import NewAPIKey from '/docs/cloud/img/weaviate-cloud-new-api-key.png'; + +
+
+
    +
  1. + Weaviate Cloud コンソールを開きます。 +
  2. +
  3. + + クラスターを選択 + {' '} + し、API Keys セクションを探します。 +
  4. +
  5. + New Key ボタンをクリックします (1)。 +
  6. +
+
+
+
+
+ クラスターに新しい API キーを追加 +
+
クラスターに新しい API キーを追加します。
+
+
+
+
+ +import NewAPIKeyConfirm from '/docs/cloud/img/weaviate-cloud-new-api-key-confirm.png'; + +
+
+
    +
  1. + Admin キーにするか ReadOnly キーにするかを選択します。 +
  2. +
  3. + Create ボタンをクリックします。 +
  4. +
+
+
+
+
+ 新しい API キーの種類を選択 +
+
新しい API キーの種類を選択します。
+
+
+
+
+ +:::info + + + +::: + +### API キーの削除 + +Serverless クラスターをお使いの場合、API キーを削除できます。API キーを削除するには、次の手順に従ってください。 + +import DeleteAPIKey from '/docs/cloud/img/weaviate-cloud-delete-api-key.png'; + +
+
+
    +
  1. + Weaviate Cloud コンソールを開きます。 +
  2. +
  3. + + クラスターを選択 + + し、API Keys セクションを探します。 +
  4. +
  5. + 削除したいキーの横にある Delete ボタンをクリックします (1)。 +
  6. +
+
+
+
+
+ Delete an API key in Weaviate Cloud +
+
Weaviate Cloud で API キーを削除します。
+
+
+
+
+ +import DeleteAPIKeyConfirm from '/docs/cloud/img/weaviate-cloud-delete-api-key-confirm.png'; + +
+
+
    +
  1. 削除を確認するために必要なテキストを入力します。
  2. +
  3. + Confirm and delete ボタンをクリックします。 +
  4. +
+
+
+
+
+ Confirm API key deletion +
+
API キーの削除を確認します。
+
+
+
+
+ +:::info + + + +::: + +## さらなるリソース + +- [WCD で認可を管理する](./authorization.mdx) +- [RBAC ドキュメント](/weaviate/configuration/rbac/index.mdx) + +## サポート + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/authorization.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/authorization.mdx new file mode 100644 index 000000000..ec79559fe --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/authorization.mdx @@ -0,0 +1,248 @@ +--- +title: 認可 +sidebar_position: 6 +description: " Weaviate Cloud クラスター向け Role-Based Access Control (RBAC) 設定ガイド。" +image: og/wcd/user_guides.jpg +--- + +import Link from '@docusaurus/Link'; +import WCDCreateRole from '/docs/cloud/img/weaviate-cloud-roles-create.png'; +import WCDCreateRoleForm from '/docs/cloud/img/weaviate-cloud-roles-create-form.png'; +import WCDEditRole from '/docs/cloud/img/weaviate-cloud-roles-edit.png'; +import WCDEditRoleForm from '/docs/cloud/img/weaviate-cloud-roles-edit-form.png'; +import WCDDeleteRole from '/docs/cloud/img/weaviate-cloud-roles-delete.png'; +import WCDDeleteRoleForm from '/docs/cloud/img/weaviate-cloud-roles-delete-form.png'; + +import RestartTheCluster from '/_includes/wcs/restart-warning.mdx'; + +:::info + +このガイドは、 RBAC(Role-Based Access Control)が有効になっているクラスターにのみ適用されます。 Weaviate バージョン `v1.30`(以降)で作成された新しいクラスターでは、デフォルトで RBAC が有効になっています。 + +::: + +## ロールの作成 + +カスタムロールを使用すると、異なるユーザーやアプリケーションがあなたの Weaviate クラスターへアクセスする際の詳細な権限を定義できます。コレクション、テナント、特定の操作へのアクセスを制御できます。 + +
+
+
    +
  1. + Weaviate Cloud コンソールを開きます。 +
  2. +
  3. + + クラスターを選択 + {' '} + し、Roles セクションへ移動します。 +
  4. +
  5. + Create Role ボタン( + 1)をクリックします。 +
  6. +
+
+
+
+
+  Weaviate Cloud のロール管理セクション +
+
ロール管理セクションへアクセスします。
+
+
+
+
+ +
+
+
    +
  1. + Role name{' '}フィールド(1)に、ロールの説明的な名前を入力します。 +
  2. +
  3. + Collection セクション(2)でコレクションレベルの権限を設定します: +
      +
    • + ドロップダウンから対象コレクションを選択( + 3) +
    • +
    • + Create、Read、Update、Delete の各 Collection 権限を選択(4) +
    • +
    +
  4. +
  5. + コレクションでマルチテナンシーを使用している場合は、必要に応じてCollection Tenants 権限を設定します。 +
  6. +
  7. + Create ボタン(5)をクリックして新しいロールを保存します。 +
  8. +
+
+
+
+
+ 新しい API ロール作成フォーム +
+
新しいロールの権限を設定します。
+
+
+
+
+ +:::info + + RBAC と利用可能な権限の詳細については、[RBAC ドキュメント](/weaviate/configuration/rbac/index.mdx)を参照してください。 + +::: + +## ロールの編集 + +既存のカスタムロールの権限や設定は、いつでも変更できます。 + +
+
+
    +
  1. ロール管理ページで編集したいロールを探します。
  2. +
  3. + そのロールの横にあるEdit ボタン(1)をクリックします。 +
  4. +
+
+
+
+
+ 編集ボタンがハイライトされたロール +
+
ロールの権限を変更します。
+
+
+
+
+
+
+
    +
  1. + ロール編集画面では、以下が行えます: +
      +
    • + Create、Read、Update、Delete 操作のチェックボックスを切り替えてコレクション権限を更新 +
    • +
    • + ドロップダウンメニューを使用して、権限の適用対象となるコレクションなど、ロールのスコープに追加の制約を追加・削除 +
    • +
    +
  2. +
  3. + 変更が完了したら、Update ボタン( + 1)をクリックして保存します。 +
  4. +
+
+
+
+
+ Update ボタンがハイライトされたロール編集フォーム +
+
+ ロールの権限を編集し、更新を確定します。 +
+
+
+
+
+ +ロールの権限変更は、そのロールに割り当てられているすべての API キーに即時反映されます。 + + + +## ロールの削除 + +カスタムロールが不要になった場合は削除できます。この操作は現在そのロールに割り当てられているすべての API keys に影響します。 + +
+
+
    +
  1. + ロール管理ページで、削除したいロールを探します。 +
  2. +
  3. + 対象ロールの横にある Delete ボタン (1) をクリックします。 +
  4. +
+
+
+
+
+ Delete ボタンがハイライトされたロール +
+
+ ロールを削除する様子。 +
+
+
+
+
+
+
+
    +
  1. + 確認ダイアログで、削除を確定するためにロール名を正確に入力します (1)。これにより誤って削除することを防ぎます。 +
  2. +
  3. + Confirm and delete (2) をクリックしてロールを完全に削除します。 +
  4. +
+
+
+
+
+ ロール削除確認ダイアログ +
+
+ ロール名を入力して削除を確定します。 +
+
+
+
+
+ +ロールの削除は永久的で、取り消すことはできません。この操作により次のことが起こります: + +- ロールとその関連するすべての権限が削除される +- このロールが割り当てられていた API keys に影響する +- このロールによって付与されていた権限に依存するアプリケーションが動作しなくなる可能性がある + +ロールを削除する前に、影響を受ける API keys を更新するか別のロールに割り当て直すようにしてください。 + +:::info +admin と viewer の組み込みロールは削除できません。これらはクラスタの基本的な操作に必要なシステム定義のロールだからです。 +::: + +## 参考リソース + +- [WCD での API keys の管理](./authentication.mdx) +- [RBAC のドキュメント](/weaviate/configuration/rbac/index.mdx) + +## サポート + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/connect.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/connect.mdx new file mode 100644 index 000000000..6e380154f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/connect.mdx @@ -0,0 +1,209 @@ +--- +title: Weaviate Cloud への接続 +sidebar_label: Connect to a cluster +sidebar_position: 1 +description: "Weaviate Cloud クラスター インスタンスへアクセスする複数の接続オプションと方法を紹介します。" +image: og/wcd/user_guides.jpg +--- + +import CompareURLs from '/docs/cloud/img/wcs-console-url-check.jpg'; + +[Weaviate Cloud (WCD)](https://console.weaviate.cloud/) には、クラスターへ接続するための複数のオプションがあります。 + +- **[API で接続](#connect-with-an-api)**: + + - [クライアントライブラリ](/weaviate/client-libraries) を使用して Weaviate Cloud インスタンスへ接続します。 + - cURL のようなツールを用いて [REST API](/weaviate/api/rest) に接続します。 + +- **[Weaviate Cloud コンソール経由で接続](#connect-to-the-weaviate-cloud-console)**: + + - ログインしてクラスター、ユーザー、請求を管理します。 + - 組み込みツールを使用してデータを操作します。 + +## API で接続 + +以下のガイドは、[RBAC (Role-Based Access Control)](/weaviate/configuration/rbac/index.mdx) が有効なクラスターに適用されます。Weaviate バージョン `v1.30` 以降で作成された新規クラスターでは、デフォルトで RBAC が有効です。 + +
+ RBAC が無効な場合の API キー接続 + +Weaviate クライアントライブラリは API キーを使って Weaviate Cloud インスタンスへ認証します。RBAC が無効な場合、デフォルトで 2 種類の API キーが作成されます。**Serverless** と **Sandbox** の両クラスターには次のキーがあります。 + +- `Admin key`: クラスターへの読み書きアクセスを許可する管理者キー +- `ReadOnly key`: クラスターへの読み取りのみを許可するビューアーキー + +Weaviate サーバーはすべてのリクエストを認証します。 + +- Weaviate クライアントライブラリを使用する場合、クライアントをインスタンス化するときに API キーを渡します。接続が確立された後は、追加のリクエストで API キーを再度渡す必要はありません。 +- cURL などのツールを使用する場合、リクエストヘッダーに API キーを追加してください。 + +
+ +### API キーと REST エンドポイントの取得 + +import CreateAPIKeys from '/_includes/wcs/create-api-keys.mdx'; + + + +import RetrieveRESTEndpoint from '/_includes/wcs/retrieve-rest-endpoint.mdx'; + + + +### 環境変数 + +クライアントコードに API キーや Weaviate URL をハードコードしないでください。環境変数を渡す、あるいは同様の安全なコーディング手法を検討してください。 + +```bash +export WEAVIATE_URL="replaceThisWithYourRESTEndpointURL" +export WEAVIATE_API_KEY="replaceThisWithYourAPIKey" +``` + +### 接続例 + +接続には `REST Endpoint` の URL と `Admin` API キーを使用します。 + +import ConnectIsReady from '/_includes/code/quickstart/quickstart.is_ready.mdx'; + + + +## Weaviate Cloud コンソールへの接続 + +Weaviate Cloud コンソールは、メールアドレスとパスワードで認証します。パスワードは Weaviate Cloud アカウント作成時に設定します。 + +コンソールへ接続する手順は次のとおりです。 + +1. ブラウザーで [Weaviate Cloud ログインページ](https://console.weaviate.cloud/) を開きます。 +1. メールアドレスとパスワードを入力して認証します。 +1. `Login` をクリックします。 + +## Query Tool でインスタンスに接続 + +組み込みの [Query tool](/cloud/tools/query-tool) は、追加の認証なしで Weaviate Cloud 組織内のクラスターへ直接接続します。 + +import APIKeyInHeader from '/docs/cloud/img/wcs-auth-header.jpg'; + +
+
+

+ Query tool から組織外の Weaviate インスタンスへ接続する場合は、 + リモートインスタンス用の API キーを入力してください。
+
+ API キーは Query tool タブ下部の Headers に追加します。 +

+
+
+
+
+ クラスターを作成 +
+
+ クラスターに適した API キーをコピーしてください。 +
+
+
+
+ +## トラブルシューティング + +ここでは一般的な問題に対する解決策を紹介します。さらにサポートが必要な場合は、[サポートへ連絡](#support--feedback) してください。 + +### パスワードをリセットする + +Weaviate Cloud のパスワードをリセットするには、次の手順に従ってください。 + +1. Weaviate Cloud の [ログインページ](https://console.weaviate.cloud) にアクセスします。 +1. ログインボタンをクリックします。 +1. `Forgot Password` をクリックします。 +1. Weaviate Cloud から送信されるパスワードリセットメールを確認します。 +1. メール内のリンクをクリックし、表示される手順に従ってパスワードをリセットします。リンクは 5 分間のみ有効です。 + +### 接続タイムアウト + +新しい Python クライアントは gRPC プロトコルを使用して Weaviate Cloud に接続します。gRPC はクエリ性能を向上させますが、ネットワーク速度の影響を受けやすくなります。タイムアウトエラーが発生した場合は、接続コード内でタイムアウト値を増やしてください。 + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCodeSupp from '!!raw-loader!/_includes/code/client-libraries/python_slow_connection.py'; + + + + + + + +あるいは、デフォルトのタイムアウト値を保持し、初期接続チェックをスキップすることもできます。 + + + + + + + + + +### gRPC ヘルスチェック エラー + +**問題**: Serverless クラスターを更新した後に gRPC がヘルスチェック エラーを返します。 + +``` +weaviate.exceptions.WeaviateGRPCUnavailableError: gRPC health check could not be completed. +``` + +**解決策**: クラスター URL が正しいことを確認し、必要に応じて URL を更新してください。 + + Serverless クラスターを更新すると、クラスター URL がわずかに変更される場合があります。 Weaviate Cloud は旧 URL へのルーティングを引き続き行うため一部の接続は機能しますが、新しい gRPC URL と旧 HTTP URL は異なるため、 gRPC を必要とする接続は失敗します。 + + URL を確認するには、 Weaviate Cloud Console を開き、クラスターの詳細パネルを確認します。クラスター URL の前に `grpc-` を付けた場合、クラスター URL とクラスター gRPC URL が一致している必要があります。 + +import EndpointURLs from '/docs/cloud/img/weaviate-cloud-endpoint-urls.png'; + +
+
+

+ クラスター URL とアプリケーションで使用している接続 URL を比較してください。旧 URL と新 URL は似ていますが、新しいものには .c0.region などのサブドメインが追加されている場合があります。 +

+
+

+ もし URL が異なる場合は、アプリケーションの接続コードを更新し、新しいクラスター URL を使用してください。 +

+
+
+
+
+ Cluster URLs +
+
クラスター URL。
+
+
+
+ +## 追加リソース + + Weaviate クライアントライブラリで認証を行う方法については、以下をご覧ください。 + +- [Python](/weaviate/client-libraries/python/index.mdx) +- [TypeScript/JavaScript](../../weaviate/client-libraries/typescript/index.mdx) +- [Go](/weaviate/client-libraries/go.md#authentication) +- [Java](/weaviate/client-libraries/java.md#authentication) + +## サポート & フィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + +import CustomScriptLoader from '/src/components/scriptSwitch'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/create.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/create.mdx new file mode 100644 index 000000000..bf629b782 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/create.mdx @@ -0,0 +1,218 @@ +--- +title: クラスターの作成 +sidebar_position: 2 +description: "新しい Sandbox または Serverless Weaviate Cloud クラスターを作成して設定する手順ガイド。" +image: og/wcd/user_guides.jpg +--- + +[Weaviate Cloud (WCD)](https://console.weaviate.cloud/) では、2 種類のインスタンスを提供しています。 + +- **Sandbox クラスター**: 小規模で無料のクラスターです。学習や実験向けに設計されており、スケーラブルではなく 14 日で期限切れになります。 +- **Serverless クラスター**: 本番環境向けに設計された堅牢な有料クラスターです。 + +## クラスターの作成 + +Weaviate Cloud の Web コンソールにログインすると、`Clusters` パネルにクラスター一覧が表示されます (1)。新しいアカウントでログインした場合は、まだクラスターはありません。 + +クラスターを作成する手順は次のとおりです。 + +import CreateCluster from '/docs/cloud/img/weaviate-cloud-create-new-cluster.png'; +import SandboxCluster from '/docs/cloud/img/weaviate-cloud-sandbox-cluster.png'; +import ServerlessCluster from '/docs/cloud/img/weaviate-cloud-serverless-cluster.png'; + +
+
+
    +
  1. + Clusters パネルの ➕ アイコンをクリックします ( + 2)。 +
  2. +
  3. + Create cluster をクリックします。 +
  4. +
  5. + クラスターのオプションを選択できる新しいパネルが開きます。 +
  6. +
+
+
+
+
+ Create a cluster +
+
このボタンをクリックしてクラスターを作成します。
+
+
+
+ +Weaviate では、次のクラスターオプションを提供しています。 + +- **[Sandbox クラスター](#sandbox-clusters)**: 開発用途向けの無料・短期クラスター +- **[Serverless クラスター](#serverless-clusters)**: 永続的で本番使用に適した環境 + +### Sandbox クラスター + +Sandbox クラスターを作成する手順は次のとおりです。 + +
+
+
    +
  1. + Sandbox タブを選択します (1)。 +
  2. +
  3. + クラスター名を入力します (2)。 +
  4. +
  5. + ドロップダウンからクラウドリージョンを選択します (3)。 +
  6. +
  7. + 必要に応じて Advanced configuration を設定します (4)。 +
  8. +
  9. + Create ボタンをクリックします。 +
  10. +
+

Serverless クラスターの詳細設定

+

次の詳細設定が利用できます。

+
    +
  • + + Enable auto schema generation + +
  • +
  • + + Enable async indexing + +
  • +
  • + + Enable async replication + +
  • +
  • + Allow all CORS origins +
  • +
+
+
+
+
+ Create a sandbox cluster +
+
Sandbox クラスターの設定を行います。
+
+
+
+ +### Serverless クラスター + +Serverless クラスターには課金情報が必要です。まだ登録していない場合は、Weaviate Cloud から課金情報の追加を求められます。 + +Serverless クラスターを作成する手順は次のとおりです。 + +import Link from '@docusaurus/Link'; + +
+
+
    +
  1. + Serverless タブを選択します (1)。 +
  2. +
  3. + クラスター名を入力します (2)。 +
  4. +
  5. + ドロップダウンからクラウドリージョンを選択します (3)。 +
  6. +
  7. + 必要に応じて High Availability を有効にすると、アップグレードやスケーリング時のダウンタイムを削減できます。 +
  8. +
  9. + 必要に応じて Advanced configuration を設定します ( + 4)。 +
  10. +
  11. + Create ボタンをクリックします。 +
  12. +
+

Serverless クラスターの詳細設定

+

次の詳細設定が利用できます。

+
    +
  • + + Enable auto schema generation + +
  • +
  • + + Enable async indexing + +
  • +
  • + + Enable async replication + +
  • +
  • + Allow all CORS origins +
  • +
+
+
+
+
+ Create a serverless cluster +
+
Serverless クラスターの設定を行います。
+
+
+
+ + + +## 認証 + +Weaviate Cloud クラスターは API キー認証を使用します。認証方法は、[RBAC (Role-Based Access Control)](/weaviate/configuration/rbac) が有効かどうかによって異なります。 + +### RBAC 有効時の認証 + +新しく作成した Weaviate バージョン `v1.30` 以降のクラスターでは、既定で RBAC が有効になっています。RBAC が有効な場合は、細かなアクセス制御のためにロールを指定した API キーを作成します。 + +クライアント アプリケーションを開発する際は、API キーを使用してクラスターに接続してください。新しいキーの作成やロール管理を含む API キーの確認・管理方法は、次のガイドをご覧ください。 + +- **[クラスター管理: 認証](/cloud/manage-clusters/authentication.mdx)** + +### RBAC 無効時の認証 + +RBAC が有効でない場合(`v1.30` 以前)、クラスターは従来の 2 つの既定 API キー方式を使用します。 + +- **Admin キー**: データベースへの読み書きアクセスを提供 +- **ReadOnly キー**: データベースへの読み取り専用アクセスを提供 + +Serverless クラスターでは API キーの作成、削除、編集、ローテーションが可能ですが、Sandbox クラスターでは既定キーを変更できません。 + +## Weaviate データベース バージョン + +新しいクラスターをプロビジョニングすると、Weaviate Cloud は最新の Weaviate バージョンでクラスターをセットアップします。新しい Weaviate バージョンがリリースされてから Weaviate Cloud で利用可能になるまで、わずかな遅延が生じる場合があります。 + +Weaviate Cloud は、新しい Weaviate バージョンがリリースされても既存クラスターを自動更新しません。 + +Weaviate Cloud のバージョニングの詳細は、以下を参照してください。 + +- **[アカウント管理: サーバーバージョン](/cloud/platform/version)** + +## クラスター数 + + + +既定では、1 つの組織が同時に持てるクラスターは、Serverless が最大 6 基、Sandbox が最大 2 基です。これらの制限を変更したい場合は、[サポートにお問い合わせ](mailto:support@weaviate.io)ください。 + +## サポートとフィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/status.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/status.mdx new file mode 100644 index 000000000..7a33a4c73 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/status.mdx @@ -0,0 +1,117 @@ +--- +title: クラスター ステータス +sidebar_position: 3 +description: "複数の方法で Weaviate Cloud クラスターの運用状況を監視および確認します。" +image: og/wcd/user_guides.jpg +--- + +[Weaviate Cloud (WCD)](https://console.weaviate.cloud/) では、クラスターのステータスを確認するために次の 2 つの方法を提供しています。 +- **[ウェブ インターフェース](#cluster-details)** : Weaviate Cloud コンソール内 +- **[API エンドポイント](#api-endpoint)** : Weaviate インスタンスに関する情報を取得 + +## Weaviate Cloud コンソールでのクラスター ステータス {#cluster-details} + +### クラスターの選択 {#select-your-cluster} + +import ClusterDetails from '/docs/cloud/img/weaviate-cloud-cluster-details.png'; + +
    +
  1. + Weaviate Cloud コンソール を開きます。 +
  2. +
  3. + 左サイドバーの Clusters リスト ( + 1) を開きます。 +
  4. +
  5. + 確認したいクラスターを選択します ( + 2)。 +
  6. +
  7. 右側にクラスター詳細パネルが表示されます。
  8. +
+ +
+
+
+ View cluster status in Weaviate Cloud +
+
+

Weaviate Cloud でクラスター ステータスを表示します。

+
+
+
+
+ +## クラスター ステータス情報 + +ページ上部では、以下のクラスター統計情報を確認できます。 + +- `Dimensions stored` +- `Dimensions queried` +- `Object count` +- `Running costs` + +`Information` セクションには次の項目が含まれます。 + +- `Name` +- `REST Endpoint` +- `gRPC Endpoint` +- `Weaviate Database version` +- `Cloud region` +- `Created at` +- `Type`: Serverless または Sandbox +- `Support Plan` +- `High Availability` + +Serverless クラスターには `Advanced configuration` セクションがあり、以下の追加設定の有効化状況を確認または変更できます。 + +- `Enable auto schema generation` +- `Enable async indexing` +- `Enable async replication` +- `Allow all CORS origins` + +## API エンドポイント {#api-endpoint} + +プログラムからクラスター詳細を取得するには、[`nodes`](/deploy/configuration/nodes.md) REST エンドポイントを使用します。 + +import APIOutputs from '/_includes/rest/node-endpoint-info.mdx'; + + + +## 有効なモジュール + +各 Weaviate インスタンスには有効化されているモジュールのセットがあります。利用可能なモジュールは、使用している Weaviate のバージョンや Weaviate Cloud のポリシーによって異なります。 + +Weaviate Cloud インスタンスで有効なモジュール一覧を確認するには、次の手順を実行してください。 + +import ClusterStatusModules from '/docs/cloud/img/cluster-status.modules.png'; + +
+
+
    +
  1. Weaviate Cloud コンソールを開きます。
  2. +
  3. + Clusters をクリックし、確認したいクラスターを選択します。 +
  4. +
  5. + modules active セクションまでスクロールします。 +
  6. +
+
+
+
+
+ Create a cluster +
+
クラスターで利用可能なモジュール。
+
+
+
+ +## サポート & フィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/upgrade.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/upgrade.mdx new file mode 100644 index 000000000..cb4e09ad2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/manage-clusters/upgrade.mdx @@ -0,0 +1,111 @@ +--- +title: クラスタの更新 +sidebar_position: 4 +description: "新しい Weaviate Database バージョンがリリースされた際に既存クラスタを手動で更新する手順。" +image: og/wcd/user_guides.jpg +--- + +[Weaviate Cloud (WCD)](https://console.weaviate.cloud/) は、Weaviate コアの新しいバージョンがリリースされても既存のクラスタを自動的に更新しません。 + +スタンドアロン構成のクラスタでは、更新の際にシステム停止が必要です。ビジネス要件を考慮し、適切なメンテナンス ウィンドウでクラスタを更新してください。高可用性 (HA) クラスタの場合、ダウンタイムは発生しません。 + +## Weaviate Database バージョンの更新 + +Weaviate Database の新しいバージョンが利用可能になると、クラスタ詳細ページの上部に通知バナーが表示されます。バナーの色と緊急度は更新期限によって異なります。 + +- **Info (緑色の背景)**: 通常の更新通知 +- **Warning (黄色/オレンジの背景)**: 更新期限が近づいています +- **Critical (赤色の背景)**: 更新期限が目前です + +import Link from '@docusaurus/Link'; +import UpdateCluster from '/docs/cloud/img/weaviate-cloud-update-cluster.png'; + +
+
+
    +
  1. + Weaviate Cloud コンソール{' '} + を開き、{' '} + + クラスタを選択 + + します。 +
  2. +
  3. + 更新が利用可能な場合、クラスタ詳細ページの上部に通知バナーが表示されます (1)。バナー内の Update ボタンをクリックします。 +
  4. +
+
+
+
+
+ Update a Weaviate Cloud cluster +
+
+ Update 通知バナーと確認用ボタン。 +
+
+
+
+
+ +import UpdateClusterConfirm from '/docs/cloud/img/weaviate-cloud-update-cluster-confirm.png'; + +
+
+
    +
  1. + 更新に使用する Weaviate バージョンを選択します ( + 2)。 +
  2. +
  3. + 更新を確認するためにクラスタ名を入力します ( + 3)。 +
  4. +
  5. + Confirm and update ボタンをクリックして更新プロセスを開始します (4)。 +
  6. +
+
+
+
+
+ Confirm Weaviate Cloud cluster update +
+
+ クラスタ更新の確認。 +
+
+
+
+
+ +## 更新プロセスとステータス + +更新中は `Update` ボタンが無効化され、現在のステータスに応じた説明付きの読み込みインジケーターが表示されます。 + +- **Preparing**: クラスタを更新する準備中です (正常でない状態、作成中、再起動中、またはディスク拡張中の場合があります) +- **Updating**: クラスタが更新操作中、またはバージョンを更新中です +- **Backup in Progress**: データのバックアップを実行中です + +コンソールにはプロセス全体を通してステータス インジケーターが表示されます。インジケーターが消え、クラスタが準備完了になると Weaviate Cloud から確認メールが送信されます。 + +:::info 更新プロセスに関する重要な注意点 + +- Weaviate Database バージョンの更新前に、データの完全バックアップが作成されます +- 処理時間はクラスタ内のデータ量に依存します +- 大量のデータを持つクラスタでは、更新完了までに長時間を要する場合があります +- ステータス インジケーターはリアルタイムのプロビジョニング状況を反映するため、特定の順序で表示されないことがあります + +::: + +## サポートとフィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/platform/billing.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/platform/billing.mdx new file mode 100644 index 000000000..5da859c81 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/platform/billing.mdx @@ -0,0 +1,88 @@ +--- +title: 請求 +sidebar_position: 3 +description: "無料の Sandbox クラスターと有料の Serverless プランを含む Weaviate Cloud サービスの請求情報です。" +image: og/wcd/user_guides.jpg +--- + +Sandbox クラスターは無料です。Sandbox クラスターを作成するために請求アカウントは必要ありません。 + +Serverless クラスターはリソース使用量に応じて課金されます。月額料金は、使用量とサポートプランによって決まります。Serverless クラスターを作成するには請求アカウントが必要です。 + +さまざまな使用量レベルとサポートプランの組み合わせによる費用を見積もるには、[料金計算ツール](https://weaviate.io/services/serverless)をご覧ください。 + +:::note + +[AWS](https://aws.amazon.com/marketplace/pp/prodview-ng2dfhb4yjoic) や [GCP](https://console.cloud.google.com/marketplace/product/weaviate-gcp-mktplace/weaviate?inv=1&invt=AbwjlA) などの外部クラウドプロバイダー経由で Weaviate Cloud に登録した場合、請求はそのクラウドプロバイダーのマーケットプレイスを通じて行われます。 + +::: + +## アカウント作成 + +Weaviate Cloud ( WCD ) では請求に [Stripe](https://stripe.com/) を使用しています。Stripe アカウントを作成する手順は以下のとおりです。 + +import EditOrganization from '/_includes/wcs/weaviate-cloud-edit-organization.mdx' + + + +import BillingSection from '/docs/cloud/img/weaviate-cloud-billing-section.png'; + +
    +
  1. + Billing セクションで Add payment method ボタン (3) をクリックします。 +
  2. +
  3. 必要な個人情報を入力します。
  4. +
  5. Stripe アカウントを作成します。
  6. +
+ +
+
+
+ Add payment method to Weaviate Cloud +
+
+

Weaviate Cloud に支払い方法を追加します。

+
+
+
+
+ +## 使用料金 + +使用料金は、コレクション内のオブジェクトの数とサイズを反映したものです。Weaviate は各コレクションをポーリングして、日次でオブジェクト数を取得します。 + +- オブジェクトが非圧縮の場合、請求システムはオブジェクト数に次元数を掛けて `vectorDimensionsSum` を算出します。 +- オブジェクトが圧縮されている場合、請求システムはオブジェクト数にベクトルセグメント数を掛けて `vectorSegmentsSum` を算出します。 + +これらの値を合算して正規化し、基本料金を求めます。基本料金にクラスターのサポートプランの料金率を掛けて請求額を算出します。 + +クラスターが **高可用性** の場合、料金率は 3 倍になります。 + +:::tip + +**圧縮** を有効にすると大幅なコスト削減が期待できます。 + +::: + +## サポート & フィードバック レベル + +Weaviate では、[Standard](/cloud/platform/support-levels#standard-support)、[Professional](/cloud/platform/support-levels#professional-support)、[Business Critical](/cloud/platform/support-levels#business-critical-support) の 3 つのサポートレベルを提供しています。各サポートプランには使用料金に対する課金率と月額最低料金が設定されています。 + +- 使用料金がサポートプランの月額最低料金を下回る場合、Weaviate は月額最低料金を請求します。 +- 使用料金が月額最低料金を超えた場合、Weaviate は最低料金に追加料金を加えて請求します。 + +## 高可用性 + +高可用性 ( HA ) クラスターの場合、Weaviate Cloud は最低料金と使用料金を 3 倍にして、追加リソース分を考慮します。 + +## 請求サイクル + +アクティブなクラスターの料金は毎月 1 日に計算され、請求書が発行されます。 + +## サポート & フィードバック + +import SupportAndTrouble from '/_includes/wcs/support-and-troubleshoot.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/cloud/platform/create-account.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/platform/create-account.mdx new file mode 100644 index 000000000..197e9ec41 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/cloud/platform/create-account.mdx @@ -0,0 +1,57 @@ +--- +title: アカウントの作成とサインイン +sidebar_position: 20 +description: "Weaviate Cloud コンソールにアクセスするためのアカウント作成手順。" +image: og/wcd/user_guides.jpg +--- + +import LandingRegister from '/docs/cloud/img/wcs-landing-page-register.jpg'; + +Weaviate Cloud ( WCD ) にはインタラクティブなコンソールがあります。ユーザーアカウントを作成し、ログインして WCD クラスターを管理したり、クエリを実行したり、組織の詳細を設定したりできます。 + +## 新規ユーザーアカウントの作成とサインイン {#create-a-new-user-account} + +[Weaviate Cloud コンソール](https://console.weaviate.cloud) にアクセスし、以下の手順に従って新しいアカウントを作成してログインしてください。 + +
+ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/_img/weaviate_vibe_coding_guide.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/_img/weaviate_vibe_coding_guide.png new file mode 100644 index 000000000..4fe06b6d3 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/_img/weaviate_vibe_coding_guide.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/code-generation.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/code-generation.md new file mode 100644 index 000000000..c123d566c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/code-generation.md @@ -0,0 +1,111 @@ +--- +title: AI ベースの Weaviate コード生成 +sidebar_position: 50 +description: 生成型 AI モデルで Weaviate 関連のコードをより良く記述するためのヒントと手法。 +image: og/docs/howto.jpg +# tags: ['best practices', 'how-to'] +--- + +# AI ベースの Weaviate コード生成( vibe-coding ) + +生成型 AI モデルはコードの自動生成能力を高めつつあります。この実践は一般的に「 vibe-coding 」または「 AI 支援コーディング」と呼ばれます。開発を高速化できる一方で、学習データに最新情報がない場合などにはハルシネーションが発生するなどの落とし穴もあります。 + +ここでは、私たちの経験を基に、生成型 AI モデルやツールを使って Weaviate クライアントライブラリのコードを書く際のヒントをご紹介します。 + +![Weaviate vibe-coding ガイド](./_img/weaviate_vibe_coding_guide.png "Weaviate vibe-coding ガイド") + +## 具体的な推奨事項 + +### 高性能モデル + +2025 年 7 月時点で、以下のモデルはコード生成で良好な結果を示しました( [Python v4 クライアントライブラリ](/weaviate/client-libraries/python/index.mdx) のコード正確性を評価)。 + +- Anthropic `claude-sonnet-4-20250514` +- Google `gemini-2.5-pro` +- Google `gemini-2.5-flash` + +Python クライアントライブラリをご使用の場合、上記モデルのいずれかがユースケースに合うかお試しください。 + +これらのモデルはいずれもゼロショット(タスク説明のみ)で完全に正しいコードを生成できるわけではありませんが、インコンテキストのサンプルを与えると大半で正しく生成できました。 + +### インコンテキストコードサンプル + +上記 LLM の性能は、インコンテキストサンプルを与えることで大幅に向上しました。目的のタスクに関連するサンプルを提示すると、より良い結果が得られるでしょう。 + +まずは、以下にまとめたコードサンプルをプロンプトにコピー & ペーストしてみてください。 + +import CodeExamples from '!!raw-loader!/_includes/code/python/best-practices.python.ai.py'; +import CodeBlock from '@theme/CodeBlock'; + +
+ + {CodeExamples} + +
+
+ +もし上記のコードサンプルが十分でない場合、次の方法をお試しください。 + +- Weaviate ドキュメントの該当セクションからコードサンプルを収集する。 +- Weaviate ドキュメントの `Ask AI` 機能で具体的なタスク方法を検索し、そこで得たコードをプロンプトに使用する。 + +:::tip 小規模モデル +一般に、小規模モデルはゼロショットのコード生成が得意ではありません。しかし Anthropic の `claude-3-5-haiku-20241022` と OpenAI の `gpt-4.1` / `gpt-4.1-mini` は、インコンテキストサンプルがあれば良質なコードを生成できました。 +::: + +## 一般的なヒント + +上記の具体的推奨事項に加え、以下の一般的なヒントもご覧ください。 + +### 最新モデルを使用する + +すでに好みのモデルプロバイダーがある場合でも、最新モデルを試してみてください。 + +後発モデルはより新しいデータで学習されているため、ゼロショットのコード生成性能が高い可能性があります。これは、2024 年に書き換えられた Weaviate Python クライアントのようにコードベースが大幅に更新されたケースで特に重要です。 + +### 指示追従性の高いモデルを探す + +モデルによっては、インコンテキストの指示をより忠実に守るものがあります。 + +そのようなモデルは、最新のインコンテキストサンプルをより尊重してくれます。 + +### 生成コードをハルシネーションチェックする + +生成されたコードにハルシネーションの兆候がないか確認しましょう。 + +Weaviate Python クライアントの場合、`weaviate.Client` クラスを用いて接続しようとしているコードは、旧バージョン( v3 )の書き方であり、 v4 では存在しません。これはハルシネーションまたは古い情報に基づくコードの典型例です。 + +最新の Weaviate Python クライアントでは、`WeaviateClient` クラスと `weaviate.connect_to_xyz()` の各ヘルパー関数で接続します。 + +### 追加ドキュメントをインデックスする + +Cursor など一部の AI 支援コード生成ツールでは、追加ドキュメントをインデックスできます。これにより、コード生成に必要なコンテキストを拡充できます。 IDE にインデックスしたドキュメントを基にコード生成を促すことも可能です。 + +お使いの IDE がこの機能を備えているか、またその利用方法を確認してください。 + +### Weaviate エージェントの利用を検討する + +[Weaviate エージェント](/agents) は、[クエリ](/agents/query)、[データ変換](/agents/transformation/)、[コンテンツのパーソナライズ](/agents/personalization) など特定タスク向けに設計されたエージェント型サービスです。 + +Weaviate Cloud ユーザーは、自然言語でインスタンスと対話できるエージェントを利用できます。ユースケースによっては、 AI 支援コード生成ツールより適している場合があります。 + +## このページの改善にご協力ください + +上記の推奨事項は、生成型 AI モデルを使ったコード生成の経験に基づいています。 + +このページのために体系的なデータを収集する目的で、[こちらのリポジトリ](https://github.com/weaviate-tutorials/weaviate-vibe-eval) で一連の評価を実施しました。 + +テストでは、さまざまな LLM を用いて Weaviate Python クライアント v4 のコードを生成し、実行可能かどうかを確認しました。各タスクはゼロショットで一度、インコンテキストサンプル付きで少なくとも一度実行しました。 + +一部の結果は [このディレクトリ](https://github.com/weaviate-tutorials/weaviate-vibe-eval/tree/main/example_results) に掲載しています。 + +ご注意: これはガイドライン提供を目的とした小規模評価です。独自の評価を実施したい場合は、ぜひリポジトリをご覧ください。 + +質問やフィードバックがありましたら、[GitHub](https://github.com/weaviate-tutorials/weaviate-vibe-eval/issues) で Issue を開いてお知らせください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/index.md new file mode 100644 index 000000000..82bfa57eb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/best-practices/index.md @@ -0,0 +1,353 @@ +--- +title: ベストプラクティス +sidebar_position: 10 +description: Weaviate のパフォーマンスを最大化するための専門的な推奨事項と最適化戦略。 +image: og/docs/howto.jpg +# tags: ['best practices', 'how-to'] +--- + +# ベストプラクティスとヒント + +このページでは、Weaviate を利用する際の一般的なベストプラクティスを紹介します。これらは私たちの経験とユーザーからのフィードバックに基づいています。 + +:::info Consider this a hub for best practices +Weaviate が進化し、ユーザーの利用方法についてさらに学ぶにつれて、このページを随時更新します。定期的にご確認ください。 +::: + +## アップグレードとメンテナンス + +### Weaviate とクライアントライブラリーを最新に保つ + +Weaviate は急速に進化しており、新機能の追加、パフォーマンス向上、バグ修正が絶えず行われています。最新の機能と改善点を享受するために、Weaviate と使用するクライアントライブラリーを常に最新に保つことを推奨します。 + +最新リリースを把握するには、以下を行ってください。 + +- [Weaviate newsletter](https://newsletter.weaviate.io/) に登録する +- 関連する Weaviate の GitHub リポジトリを [Watch](https://docs.github.com/en/account-and-profile/managing-subscriptions-and-notifications-on-github/managing-subscriptions-for-activity-on-github/viewing-your-subscriptions#reviewing-repositories-that-youre-watching) する + - [Weaviate](https://github.com/weaviate/weaviate) + - [Weaviate Python client](https://github.com/weaviate/weaviate-python-client) + - [Weaviate TS/JS client](https://github.com/weaviate/typescript-client) + - [Weaviate Go client](https://github.com/weaviate/weaviate-go-client) + - [Weaviate Java client](https://github.com/weaviate/java-client) + +:::info How often are new versions released? +一般的に、Weaviate のマイナーバージョンは 6〜10 週間ごとにリリースされ、パッチバージョンは随時リリースされます。 +::: + + + +## リソース管理 + +### 高可用性クラスタで速度と信頼性を向上 + +高い信頼性要求、高いクエリ負荷、または低レイテンシが求められる環境では、複数ノードによる高可用性 (HA) 構成で Weaviate をデプロイすることを検討してください。HA 構成は次の利点を提供します。 + +- **優れたフォールトトレランス**: 個々のノードに問題が発生してもリクエスト処理を継続 +- **ローリングアップグレード**: クラスタ全体を停止せずにノード単位でアップグレード可能 +- **クエリ性能の向上**: クエリ負荷を複数ノードに分散しレイテンシを削減 +- **スループットの増加**: 同時クエリやデータ操作をより多く処理 + +:::tip Further resources +- [Concepts: Cluster architecture](../concepts/cluster.md) +- [Configuration: Replication](/deploy/configuration/replication.md) +::: + +#### レプリケーション設定 + +HA 構成を使用する場合、次のレプリケーション設定を検討してください。 + +- **Replication factor**: クォーラム (クラスタサイズの過半数) を得られるよう奇数に設定し、過度なレプリケーションを避けます。注意: ノード数が replication factor 未満の場合、Weaviate は起動しません。 +- **Deletion strategy**: ユースケースに合った削除戦略を選択します。一般的には `NoAutomatedResolution` 戦略を推奨します。 + +### データサブセットにマルチテナンシーを使用 + +次のすべての条件を満たす複数のデータサブセットを扱う場合は、マルチテナンシーの有効化を検討してください。 + +- 同一のデータ構造 (スキーマ) を持つ +- ベクトルインデックス、転置インデックス、ベクトライザーモデルなど同一設定を共有できる +- 互いに同時検索する必要がない + +それぞれのデータサブセットを別々のテナントに割り当てることで、Weaviate のリソースオーバーヘッドを削減し、より効果的にスケールできます。 + +

Replication Factor

+ +:::tip Further resources +- [How-to: Perform multi-tenancy operations](../manage-collections/multi-tenancy.mdx) +- [How to: Manage tenant states](../manage-collections/tenant-states.mdx) +- [Concepts: Multi-tenancy](../concepts/data.md#multi-tenancy) +::: + +### データ規模に合わせたベクトルインデックスタイプの設定 + +多くの場合、デフォルトの `hnsw` インデックスタイプが良い出発点ですが、場合によっては `flat` インデックスや `dynamic` インデックスの方が適していることもあります。 + +- `flat` インデックスは、各コレクションが少数 (例: 100,000 未満) のベクトルしか保持しないと分かっている場合に有用です。 + - メモリ消費が非常に少ない一方、大規模データセットでは検索が遅くなります。 +- `dynamic` インデックスは `flat` で始まり、コレクション内のベクトル数が閾値を超えると自動的に `hnsw` に切り替わります。 + - メモリ使用量とクエリ性能のバランスに優れています。 + +特にマルチテナント環境では、テナント内のベクトル数が閾値を超えた際に自動で `hnsw` に切り替わる `dynamic` インデックスが有益です。 + +:::tip Further resources +- [How-to: Set the vector index type](../manage-collections/vector-config.mdx#set-vector-index-type) +- [Concepts: Vector indexes](../concepts/indexing/vector-index.md) +::: + +### ベクトル量子化でメモリ使用量を削減 + +データセットが大きくなるにつれ、対応するベクトルインデックスは高いメモリ要求を招き、コスト増大につながります。特に `hnsw` インデックスを使用している場合は顕著です。 + +大量のベクトルを扱う場合は、ベクトル量子化を使用してインデックスのメモリフットプリントを削減することを検討してください。メモリ要件を抑え、より低コストでスケールできます。 + +![Overview of quantization schemes](@site/_includes/images/concepts/quantization_overview_light.png#gh-light-mode-only "Overview of quantization schemes") +![Overview of quantization schemes](@site/_includes/images/concepts/quantization_overview_dark.png#gh-dark-mode-only "Overview of quantization schemes") + +HNSW インデックスの場合、まず 直積量子化 (PQ) を有効にすることを推奨します。メモリ使用量とクエリ性能のバランスが良好で、ユースケースに合わせてパラメーター調整も可能です。 + +:::tip Further resources +- [How-to: Configure vector quantization](../configuration/compression/index.md) +- [Concepts: Vector quantization](../concepts/vector-quantization.md) +::: + +### システムしきい値を調整してダウンタイムを防止 + +Weaviate では、メモリまたはディスク使用率が一定の割合を超えると警告を発し、さらに高くなるとリードオンリーモードに移行するよう設定されています。 + +これらのしきい値はユースケースに合わせて調整可能です。たとえば、大量メモリのマシンで Weaviate を稼働させる場合、同じ割合でも実際のメモリ量が多いため、リードオンリーに移行する前のメモリしきい値を上げたいことがあります。 + +ディスク使用率のしきい値は `DISK_USE_WARNING_PERCENTAGE` と `DISK_USE_READONLY_PERCENTAGE`、メモリ使用率のしきい値は `MEMORY_WARNING_PERCENTAGE` と `MEMORY_READONLY_PERCENTAGE` で設定します。 + +:::tip Further resources +- [References: Environment variables](/deploy/configuration/env-vars/index.md#general) + +::: + + + +### メモリ割り当て計画 + +Weaviate を実行する際、メモリ使用量はよくボトルネックになります。経験則として、以下のメモリが必要になります。 + +- 1 million 件・1024 次元 ベクトル: 6 GB のメモリ +- 1 million 件・256 次元 ベクトル: 1.5 GB のメモリ +- 量子化を有効にした 1 million 件・1024 次元 ベクトル: 2 GB のメモリ + +
+ この数値はどのように算出したのか? + +量子化を使用しない場合、各ベクトルは n 次元の float として保存されます。1024 次元ベクトルの場合は次のとおりです。 + +- 4 byte / float × 1024 次元 × 1 M ベクトル = 4 GB + +インデックス構造や追加のオーバーヘッドを加味すると、おおよそ 6 GB になります。 + +
+ +:::tip 参考リソース +- [概念: リソース計画](../concepts/resources.md) +::: + +### メモリ使用量を素早く確認する方法 + +本番環境では、Grafana や Prometheus などを用いたクラスタ[監視](/deploy/configuration/monitoring.md)を設定することを推奨します。 + +しかし、Weaviate のメモリ使用量を素早く確認する別の方法もあります。 + +:::note すでに Prometheus 監視を設定済みの場合 +内容に依存せず全体の使用量だけを確認したい場合、既存の Prometheus 監視で `go_memstats_heap_inuse_bytes` メトリクスを確認すると、常に完全なメモリフットプリントが得られます。 +::: + +#### `pprof` 経由 + +システムに `go` がインストールされている場合、Golang の `pprof` ツールでヒーププロファイルを確認できます。 + +- Go ランタイムをインストールするか、Go ベースの Docker コンテナを起動します。 +- Docker/K8s で実行している場合はポート 6060 を公開します。 + +プロファイルを可視化するには: + +```bash +go tool pprof -png http://{host}:6060/debug/pprof/heap +``` + +テキスト出力を表示するには: + +```bash +go tool pprof -top http://{host}:6060/debug/pprof/heap +``` + +#### コンテナ使用量の確認 + +Kubernetes で Weaviate を実行している場合、`kubectl` でコンテナ全体のメモリ使用量を確認できます。 + +```bash +kubectl exec weaviate-0 -- /usr/bin/free +``` + +`weaviate-0` はポッド名です。 + +外部(OS/コンテナレベル)から見ると、表面的なメモリ消費ははるかに大きく見える点に注意してください。Go ランタイムは非常にオポチュニスティックで、しばしば [MADV_FREE](https://www.man7.org/linux/man-pages/man2/madvise.2.html) を使用します。これは、必要に応じてメモリの一部を容易に解放できることを意味します。その結果、Weaviate がコンテナ内で唯一のアプリケーションの場合、実際に必要な量より多くのメモリを保持しますが、他プロセスが必要とした際には迅速に解放可能です。 + +したがって、この方法はメモリ使用量の上限を把握するのに有用ですが、`pprof` を用いた方が Weaviate のヒーププロファイルをより正確に把握できます。 + +### シャード読み込み動作の設定によるシステムとデータ可用性のバランス + +Weaviate は起動時に、デプロイ内のすべてのシャードからデータを読み込みます。デフォルトでは、遅延シャード読み込みにより、バックグラウンドでシャードを読み込みつつ、すでに読み込まれたシャードへ即座にクエリを実行できるため、起動が速くなります。 + +しかし、単一テナントのコレクションで高負荷がかかる場合、遅延読み込みはインポート操作を遅延させたり、部分的に失敗させたりすることがあります。このようなシナリオでは、以下の環境変数を設定して[遅延読み込みを無効化](../concepts/storage.md#lazy-shard-loading)することを検討してください。 + +``` +DISABLE_LAZY_LOAD_SHARDS: "true" +``` + +これにより、Weaviate が Ready と報告する前に、すべてのシャードが完全に読み込まれます。 + +:::caution 重要 +遅延シャード読み込みを無効化するのは単一テナントのコレクションに限ってください。マルチテナント環境では、遅延読み込みを有効にしておくことで起動時間を大幅に短縮できます。 +::: + +## データ構造 + +### クロスリファレンスと平坦化プロパティ + +データスキーマを設計する際、クロスリファレンスを使用するか、プロパティを平坦化するかを検討してください。リレーショナルデータベースの経験がある場合、データを正規化してクロスリファレンスを使いたくなるかもしれません。 + +しかし、Weaviate ではクロスリファレンスにはいくつかの欠点があります。 + +- ベクトル化されないため、その情報がオブジェクトのベクトル表現に含まれません。 +- 参照先オブジェクトの取得に追加クエリが必要となるため、クエリが遅くなる可能性があります。Weaviate はグラフ的なクエリやジョインを前提として設計されていません。 + +代わりに、各オブジェクトに情報を別のプロパティとして直接埋め込むことを検討してください。これにより情報がベクトル化され、より効率的にクエリできます。 + + + + + + + +## データ操作 + +### データスキーマの明示的定義 + +Weaviate には便利な["オートスキーマ"機能](../config-refs/collections.mdx#auto-schema)があり、データのスキーマを自動的に推測できます。 + +しかし、本番環境ではスキーマを明示的に定義し、オートスキーマ機能を無効化(`AUTOSCHEMA_ENABLED: 'false'` に設定)することを推奨します。これにより、データが Weaviate に正しく解釈され、不正なデータがシステムに取り込まれるのを防げます。 + +例として、次の 2 件のオブジェクトをインポートする場合を考えます。 + +```json +[ + {"title": "The Bourne Identity", "category": "Action"}, + {"title": "The Bourne Supremacy", "cattegory": "Action"}, + {"title": "The Bourne Ultimatum", "category": 2007}, +] +``` + +この例では、2 件目と 3 件目のオブジェクトが不正です。2 件目は `cattegory` というプロパティ名のタイプミスがあり、3 件目は `category` が数値であるべきでないにもかかわらず数値です。 + +オートスキーマが有効だと、Weaviate はコレクションに `cattegory` プロパティを作成してしまい、データクエリ時に予期せぬ動作を招く可能性があります。また 3 件目では、`category` プロパティが `INT` 型で作成されてしまうかもしれません。 + +オートスキーマを無効にし、スキーマを明示的に定義しましょう。 + +```python +from weaviate.classes.config import Property, DataType + +client.collections.create( + name="WikiArticle", + properties=[ + Property(name="title", data_type=DataType.TEXT) + Property(name="category", data_type=DataType.TEXT) + ], +) +``` + +これにより、正しいスキーマを持つオブジェクトのみが Weaviate に取り込まれ、不正なスキーマのオブジェクトをインポートしようとした際にはユーザーに通知されます。 + +:::tip 参考リソース +- [概念: データスキーマ](../concepts/data.md#data-schema) +- [リファレンス: コレクション定義 - オートスキーマ](../config-refs/collections.mdx#auto-schema) +::: + + + +### バッチインポートによるデータ取り込みの高速化 + +10 個を超えるオブジェクトなど、一定量以上のデータを取り込む場合はバッチインポートを使用してください。これにより、以下 2 つの理由からインポート速度が大幅に向上します。 + +- 送信する Weaviate へのリクエスト数が減り、ネットワークのオーバーヘッドが削減されます。 +- Weaviate でデータのベクトル化をオーケストレーションしている場合、ベクトル化リクエストもバッチで送信できるため高速化されます。特に推論を GPU で行う場合に効果的です。 + +```python +# ⬇️ Don't do this +for obj in objects: + collection.data.insert(properties=obj) + +# ✅ Do this +with collection.batch.fixed_size(batch_size=200) as batch: + for obj in objects: + batch.add_object(properties=obj) +``` + +:::tip さらに詳しく +- [How-to: バッチインポートでデータを取り込む](../manage-objects/import.mdx) +::: + +### 非アクティブテナントのオフロードによるコスト最小化 + +マルチテナンシーを使用しており、頻繁にクエリされないテナントがある場合は、それらをコールド(クラウド)ストレージへオフロードすることをご検討ください。 + +![Storage Tiers](../starter-guides/managing-resources/img/storage-tiers.jpg) + +オフロードされたテナントはクラウドストレージバケットに保存され、必要に応じて Weaviate へリロードできます。これにより Weaviate のメモリおよびディスク使用量を大幅に削減でき、コスト削減につながります。 + +再び使用される可能性がある場合(例: ユーザーがログインしたときなど)は、テナントを Weaviate へリロードし、再びクエリ可能にできます。 + +:::info オープンソース版 Weaviate のみで利用可能 +現時点では、テナントのオフロード機能はオープンソース版 Weaviate のみで利用可能です。 Weaviate Cloud でも提供予定です。 +::: + +:::tip さらに詳しく +- [スターターガイド: リソース管理](../starter-guides/managing-resources/index.md) +- [How-to: テナント状態を管理する](../manage-collections/tenant-states.mdx) +::: + + + + + +## アプリケーション設計と統合 + +### クライアント生成の最小化 + + Weaviate クライアントオブジェクトを生成する際には、接続確立やヘルスチェックを行う I/O 処理のためパフォーマンスのオーバーヘッドが発生します。 + +可能な限り、同じクライアントオブジェクトを再利用して多くの操作を実行してください。一般にクライアントオブジェクトはスレッドセーフであり、複数スレッド間で並行して使用できます。 + +どうしても複数のクライアントオブジェクトが必要な場合は、初期チェックをスキップすることをご検討ください(例: [ Python ](../client-libraries/python/notes-best-practices.mdx#initial-connection-checks))。これにより複数クライアント生成時のオーバーヘッドを大幅に削減できます。 + +クライアントライブラリごとの制限にもご注意ください。たとえば Weaviate Python クライアントは、[クライアントオブジェクト 1 つにつきバッチインポートスレッドは 1 つ](../client-libraries/python/notes-best-practices.mdx#thread-safety)の使用に限定されています。 + +加えて、非同期環境でのパフォーマンス向上のために[非同期クライアント API](#use-the-relevant-async-client-as-needed)の利用をご検討ください。 + +### 必要に応じた Async Client の利用 + +非同期環境で Weaviate を使用する場合は、非同期クライアント API の使用を検討してください。特に複数クエリを並行して実行する際、アプリケーションの性能を大幅に向上させられます。 + +#### Python + + Weaviate Python クライアント `4.7.0` 以降には、[非同期クライアント API (`WeaviateAsyncClient`)](../client-libraries/python/async.md) が含まれています。 + +#### Java + + Weaviate Java クライアント `5.0.0` 以降には、[非同期クライアント API (`WeaviateAsyncClient`)](https://javadoc.io/doc/io.weaviate/client/latest/io/weaviate/client/v1/async/WeaviateAsyncClient.html) が含まれています。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_cli.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_cli.md new file mode 100644 index 000000000..08060cd4f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_cli.md @@ -0,0 +1,194 @@ +--- +title: Weaviate CLI +sidebar_position: 90 +image: og/docs/client-libraries.jpg +# tags: ['cli'] +--- + +:::note Weaviate CLI バージョン +現在の Weaviate CLI のバージョンは `v||site.weaviate_cli_version||` です。 +::: + +## インストール + +Weaviate CLI は [Pypi.org](https://pypi.org/project/weaviate-cli/) で公開されています。パッケージは [pip](https://pypi.org/project/pip/) を使って簡単にインストールできます。クライアントは Python 3.7 以上で開発およびテストされています。 + +Weaviate CLI は次のコマンドでインストールできます。 + +```sh +pip install weaviate-cli +``` + +CLI が正しくインストールされたかを確認するには、次を実行します。 + +```sh +weaviate version +``` + +`||site.weaviate_cli_version||` が返ってくれば成功です。 + +## 機能 + +### 設定 + +Weaviate CLI でインスタンスと対話する前に、CLI ツールを設定する必要があります。手動で設定する方法と、コマンドにフラグを追加する方法があります。 +- 手動 (対話式): + ```sh + weaviate config set + ``` + または + ```sh + weaviate init + ``` + その後、Weaviate の URL と認証モードを入力するよう求められます。 + +- フラグ: 手動で設定していない場合、各コマンドに設定用 JSON ファイルへのパスを指定するフラグ (`--config-file myconfig.json`) を付けられます。 + + ```bash + weaviate --config-file myconfig.json + ``` + + `myconfig.json` は次のいずれかの形式である必要があります。 + ```json + { + "url": "http://localhost:8080", + "auth": null + } + ``` + または + ```json + { + "url": "http://localhost:8080", + "auth": { + "type": "client_secret", + "secret": + } + } + ``` + または + + ```json + { + "url": "http://localhost:8080", + "auth": { + "type": "username_and_password", + "user": , + "pass": + } + } + ``` + または + + ```json + { + "url": "http://localhost:8080", + "auth": { + "type": "api_key", + "api_key": + } + } + ``` + +現在の設定は次のコマンドで確認できます。 + +```sh +weaviate config view +``` + +### Ping +接続先の Weaviate URL に Ping を送るには次を実行します。 +```sh +weaviate ping +``` + +接続が正しく確立されている場合、`Weaviate is reachable!` が返ります。 + +### スキーマ +スキーマに関しては、[インポート](#import)、[エクスポート](#export)、[ truncate ](#truncate) の 3 つの操作が利用できます。 + +#### インポート + +スキーマを追加するには次を実行します。 + +```sh +weaviate schema import my_schema.json +``` + +`my_schema.json` には [こちら](../starter-guides/managing-collections/index.mdx) で説明されているスキーマを含めてください。 + +スキーマを上書きしたい場合は `--force` フラグを付けることで、インデックスをクリアしてスキーマを置き換えられます。 + +```sh +weaviate schema import --force my_schema.json # using --force will delete your data +``` + +#### エクスポート +Weaviate インスタンスに存在するスキーマを JSON ファイルとしてエクスポートするには次を実行します。 + +```sh +weaviate schema export my_schema.json +``` + +`my_schema.json` は任意のファイル名およびローカルパスに変更できます。もちろん、Weaviate にスキーマが存在する場合のみ指定した場所にスキーマが出力されます。 + +#### Truncate + +`delete` を使うと、スキーマとそれに紐付くすべてのデータを削除できます。`--force` フラグを付けない限り、実行前に確認が求められます。 + +```sh +weaviate schema delete +``` + +### データ + +#### インポート +`import` 機能は JSON ファイルからのデータインポートを実行します。`--fail-on-error` フラグを付けると、データオブジェクトのロード中に Weaviate がエラーを返した場合、コマンド実行が失敗します。 + +```sh +weaviate data import my_data_objects.json +``` + +コマンドで指定した JSON ファイルとパスを読み込みます。ファイルは Weaviate のデータスキーマに従ってフォーマットされている必要があります。例: + +```json +{ + "classes": [ + { + "class": "Publication", + "id": "f81bfe5e-16ba-4615-a516-46c2ae2e5a80", + "properties": { + "name": "New York Times" + } + }, + { + "class": "Author", + "id": "36ddd591-2dee-4e7e-a3cc-eb86d30a4303", + "properties": { + "name": "Jodi Kantor", + "writesFor": [{ + "beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80", + "href": "/v1/f81bfe5e-16ba-4615-a516-46c2ae2e5a80" + }] + } + } + ] +} +``` + +#### 空にする +`delete` を使うと、Weaviate 内のすべてのデータオブジェクトを削除できます。`--force` フラグを付けない限り、実行前に確認が求められます。 + +```sh +weaviate data delete +``` + +## 変更履歴 + +最新の `CLI` 変更については [GitHub の変更履歴](https://github.com/weaviate/weaviate-cli/releases) をご確認ください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.api.key.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.api.key.mdx new file mode 100644 index 000000000..ad40b598a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.api.key.mdx @@ -0,0 +1,2 @@ +API キーで認証する場合は、次のようにクライアントをインスタンス化します: + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.bearer.token.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.bearer.token.mdx new file mode 100644 index 000000000..c16c2984c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.bearer.token.mdx @@ -0,0 +1,4 @@ +他の OIDC 認証方法を使用してアイデンティティプロバイダーから直接トークンを取得することもできます。たとえば、[ハイブリッド フロー](/weaviate/configuration/authz-authn) のステップバイステップガイドをご覧ください。 + +`refresh token` が提供されない場合、新しい `access token` を取得する方法がないため、有効期限後にクライアントは未認証状態になります。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx new file mode 100644 index 000000000..344d0d278 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx @@ -0,0 +1,8 @@ +この OIDC フローは、認証に必要なトークンを取得するために `client secret` を使用します。 + +このフローはエンドユーザーを伴わない server-to-server の通信に推奨され、アプリケーションを Weaviate に対して認証します。この認証フローは、resource owner password フローよりも一般的に安全性が高いと見なされています。なぜなら、漏えいした `client secret` は簡単に無効化できますが、漏えいしたパスワードは、侵害された認証の範囲を超えてより大きな影響を及ぼす可能性があるためです。 + +`client secret` を認証するために、ほとんどのアイデンティティプロバイダーでは *scope* の指定が必要です。この *scope* はアイデンティティプロバイダーの設定によって異なるため、各アイデンティティプロバイダーのドキュメントを参照してください。 + +ほとんどのプロバイダーはレスポンスにリフレッシュトークンを含めないため、既存のトークンが期限切れになった際に新しい `access token` を取得できるよう、`client secret` がクライアントに保存されます。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx new file mode 100644 index 000000000..f3f08803b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx @@ -0,0 +1,12 @@ +この OIDC フローでは、ユーザー名とパスワードを使用して、認証に必要なトークンを取得します。 + +すべてのプロバイダーが自動的に `refresh token` を付与するわけではないことに注意してください。そのため、ID プロバイダーによっては、適切な *scope* を指定する必要があります。クライアントはデフォルトで *offline_access* を使用します。これは一部のプロバイダーでは機能しますが、ID プロバイダーの設定に依存するため、詳細は各プロバイダーのドキュメントをご確認ください。 + +`refresh token` がない場合、新しい `access token` を取得する方法がなく、トークンの有効期限が切れるとクライアントは未認証状態になります。 + +:::note +Weaviate クライアントは使用したユーザー名やパスワードを保存しません。 + +それらは最初のトークンを取得するためにのみ使用され、その後は可能であれば既存のトークンを利用して次のトークンを取得します。 +::: + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.introduction.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.introduction.mdx new file mode 100644 index 000000000..d0ecfa152 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.introduction.mdx @@ -0,0 +1,6 @@ +Weaviate での認証設定に関するより詳細な情報については、[認証](/weaviate/configuration/authz-authn) ページをご覧ください。 + +

{props.clientName} クライアントは、複数の OIDC 認証フローを含む、Weaviate への認証方法を複数提供します。

+ +クライアントに適した認証オプションと方法は、主に Weaviate インスタンスの具体的な設定に依存します。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx new file mode 100644 index 000000000..b610371cf --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx @@ -0,0 +1,6 @@ +Weaviate に対して OIDC を用いて認証するには、アイデンティティプロバイダーが提供するフローを選択し、そのフロー専用の認証設定を作成する必要があります。 + +この設定はその後、 Weaviate クライアントによる認証に使用されます。設定には、クライアントが `access token` を取得し、設定されている場合は `refresh token` を取得するのに役立つシークレットが含まれます。 + +`access token` は各リクエストの HTTP ヘッダーに追加され、 Weaviate での認証に使用されます。通常、このトークンには有効期限があるため、必要に応じて `refresh token` を使用して新しいトークンを取得できます。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.wcs.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.wcs.mdx new file mode 100644 index 000000000..ff72fe888 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_components/client.auth.wcs.mdx @@ -0,0 +1,6 @@ +:::tip WCD + Weaviate client +[Weaviate Cloud (WCD)](https://console.weaviate.cloud/) 内の各 Weaviate インスタンスは、OIDC 認証用のトークン発行者としてあらかじめ設定されています。 +::: + +お好みの Weaviate クライアントを使用して WCD に対して認証する方法については、[WCD 認証ドキュメント](/cloud/manage-clusters/connect) をご覧ください。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_includes/feedback.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_includes/feedback.mdx new file mode 100644 index 000000000..36c3a0701 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/_includes/feedback.mdx @@ -0,0 +1,8 @@ +:::note 質問 +API のこのセクションに関連して回答してください。 + +- 気に入った点や気に入らなかった点はありますか? +- エラーや困難に遭遇しましたか?あった場合は、具体的に教えてください。 +- その他、改善のためのメモや提案はありますか? +::: + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/community.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/community.md new file mode 100644 index 000000000..7326d3c14 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/community.md @@ -0,0 +1,38 @@ +--- +title: コミュニティ製クライアント +sidebar_position: 95 +description: 追加言語サポートのためにコミュニティが開発した Weaviate クライアントライブラリおよび統合機能です。 +image: og/docs/client-libraries.jpg +# tags: ['client libraries', 'cli'] +--- + +Weaviate は次の言語向けに公式クライアントライブラリを提供しています: + +- [Python](/weaviate/client-libraries/python) +- [TypeScript](/weaviate/client-libraries/typescript) +- [Go](/weaviate/client-libraries/go) +- [Java](/weaviate/client-libraries/java) + +Weaviate コミュニティのメンバーは、さらに多くの言語向けにクライアントライブラリを提供しています。これらのコミュニティ提供ライブラリは Weaviate によって公式に保守されているわけではありませんが、私たちは開発者の皆様の貢献に大変感謝しており、ここで共有いたします。 + +## コミュニティ保守クライアントライブラリ + +| 言語 | メンテナー | ソースコード | パッケージマネージャー | ドキュメント | ライセンス | +| -------- | ---------- | ----------- | --------------- | ------------------------ | ------- | +| .NET/C# | [Antonio Cisternino](https://github.com/cisterni) | [GitHub](https://github.com/Unipisa/WeaviateNET/tree/master) | [NuGet](https://www.nuget.org/packages/WeaviateNET) | [GitHub README](https://github.com/Unipisa/WeaviateNET/blob/master/README.md)
[統合テスト](https://github.com/Unipisa/WeaviateNET/tree/master/src/WeaviateNET.Test) | [MIT](https://github.com/Unipisa/WeaviateNET/blob/master/LICENSE.txt) | +| .NET/C# | Stuart Cam
[Search Pioneer](https://searchpioneer.com/) | [GitHub](https://github.com/searchpioneer/weaviate-dotnet-client) | [NuGet](https://www.nuget.org/packages/SearchPioneer.Weaviate.Client) | [GitHub README](https://github.com/searchpioneer/weaviate-dotnet-client)
[統合テスト](https://github.com/searchpioneer/weaviate-dotnet-client/tree/main/tests-integration/SearchPioneer.Weaviate.Client.IntegrationTests/Api) | [Apache 2.0](https://github.com/searchpioneer/weaviate-dotnet-client/blob/main/license.txt) | +| PHP | [Tim Kleyersburg](https://www.tim-kleyersburg.de/) | [GitHub](https://github.com/timkley/weaviate-php) | [Packagist](https://packagist.org/packages/timkley/weaviate-php) | [GitHub README](https://github.com/timkley/weaviate-php) | [MIT](https://github.com/timkley/weaviate-php/blob/main/LICENSE.md) | +| Ruby | Andrei Bondarev
[Source Labs](https://www.sourcelabs.io/) | [GitHub](https://github.com/andreibondarev/weaviate-ruby) | [RubyGems](https://rubygems.org/gems/weaviate-ruby) | [RubyDoc](https://rubydoc.info/gems/weaviate-ruby) | [MIT](https://github.com/andreibondarev/weaviate-ruby/blob/main/LICENSE.txt) | + +## 貢献方法 + +これらのライブラリに貢献したい場合は、メンテナーに直接ご連絡ください。 + +ここに追加したい Weaviate クライアントライブラリをお持ちの場合は、フォーラムまたは Slack でお知らせください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/go.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/go.md new file mode 100644 index 000000000..734c9424b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/go.md @@ -0,0 +1,444 @@ +--- +title: Go +sidebar_position: 70 +description: Weaviate を Go アプリケーションやサービスに統合するための公式 Go クライアントライブラリのドキュメント。 +image: og/docs/client-libraries.jpg +# tags: ['go', 'client library'] +--- + +import QuickLinks from "/src/components/QuickLinks"; + +export const goCardsData = [ + { + title: "weaviate/weaviate-go-client", + link: "https://github.com/weaviate/weaviate-go-client", + icon: "fa-brands fa-github", + }, +]; + +:::note Go client (SDK) + +最新の Go クライアントはバージョン `v||site.go_client_version||` です。 + + + +::: + +Weaviate Go クライアントは Go 1.16+ と互換性があります。 + +## インストール +クライアントは旧式の Go modules システムをサポートしていません。Weaviate クライアントをインポートする前に、コード用のリポジトリを作成してください。 + +リポジトリを作成します: + +```bash +go mod init github.com/weaviate-go-client +go mod tidy +``` + +最新の安定版 Go クライアントライブラリを取得するには、次を実行します: + +```bash +go get github.com/weaviate/weaviate-go-client/v4 +``` + +## 例 + +この例では、Weaviate インスタンスへ接続し、スキーマを取得します: + +``` go +package main + +import ( + "context" + "fmt" + "github.com/weaviate/weaviate-go-client/v5/weaviate" +) + +func GetSchema() { + cfg := weaviate.Config{ + Host: "localhost:8080", + Scheme: "http", + } + client, err := weaviate.NewClient(cfg) + if err != nil { + panic(err) + } + + schema, err := client.Schema().Getter().Do(context.Background()) + if err != nil { + panic(err) + } + fmt.Printf("%v", schema) +} + +func main() { + GetSchema() +} +``` + +## 認証 + +import ClientAuthIntro from '/docs/weaviate/client-libraries/_components/client.auth.introduction.mdx' + + + +### WCD 認証 + +import ClientAuthWCD from '/docs/weaviate/client-libraries/_components/client.auth.wcs.mdx' + + + +### API キー認証 + +:::info Weaviate Go クライアントバージョン `4.7.0` で追加されました。 +::: + +import ClientAuthApiKey from '/docs/weaviate/client-libraries/_components/client.auth.api.key.mdx' + + + + +```go +cfg := weaviate.Config{ + Host: "weaviate.example.com", + Scheme: "http", + AuthConfig: auth.ApiKey{Value: "my-secret-key"}, + Headers: nil, +} +client, err := weaviate.NewClient(cfg) +if err != nil{ + fmt.Println(err) +} +``` + +### OIDC 認証 + +import ClientAuthOIDCIntro from '/docs/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx' + + + +#### リソースオーナー パスワードフロー + +import ClientAuthFlowResourceOwnerPassword from '/docs/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx' + + + +```go +cfg := weaviate.Config{ + Host: "weaviate.example.com", + Scheme: "http", + AuthConfig: auth.ResourceOwnerPasswordFlow{ + Username: "Your user", + Password: "Your password", + Scopes: []string{"offline_access"}, // optional, depends on the configuration of your identity provider (not required with WCD) + }, + Headers: nil, +} +client, err := weaviate.NewClient(cfg) +if err != nil{ + fmt.Println(err) +} +``` + +#### クライアントクレデンシャルフロー + +import ClientAuthFlowClientCredentials from '/docs/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx' + + + +```go +cfg := weaviate.Config{ + Host: "weaviate.example.com", + Scheme: "http", + AuthConfig: auth.ClientCredentials{ + ClientSecret: "your_client_secret", + Scopes: []string{"scope1 scope2"}, // optional, depends on the configuration of your identity provider (not required with WCD) + }, + Headers: nil, +} +client, err := weaviate.NewClient(cfg) +if err != nil{ + fmt.Println(err) +} +``` + +#### リフレッシュトークンフロー + +import ClientAuthBearerToken from '/docs/weaviate/client-libraries/_components/client.auth.bearer.token.mdx' + + + +```go +cfg := weaviate.Config{ + Host: "weaviate.example.com", + Scheme: "http", + AuthConfig: auth.BearerToken{ + AccessToken: "some token", + RefreshToken: "other token", + ExpiresIn: uint(500), // in seconds + }, + Headers: nil, +} +client, err := weaviate.NewClient(cfg) +if err != nil{ + fmt.Println(err) +} +``` + +## カスタムヘッダー + +初期化時に追加されるカスタムヘッダーをクライアントに渡すことができます: + +```go +cfg := weaviate.Config{ + Host:"weaviate.example.com", + Scheme: "http", + AuthConfig: nil, + Headers: map[string]string{ + "header_key1": "value", + "header_key2": "otherValue", + }, +} +client, err := weaviate.NewClient(cfg) +if err != nil{ + fmt.Println(err) +} +``` + +## リファレンス + +Go クライアントでカバーされているすべての [RESTful エンドポイント](/weaviate/api/rest) と [GraphQL 関数](/weaviate/api) のリファレンスは、これらのリファレンスページ上のコードブロックで解説されています。 + +## 設計 + +### ビルダー・パターン + +Go クライアントの関数は「ビルダー・パターン」で設計されています。これは複雑なクエリオブジェクトを構築するためのパターンです。たとえば、RESTful の GET リクエストに近いデータ取得や、より複雑な GraphQL クエリのリクエストを行う関数は、複数のオブジェクトを組み合わせて構築され、複雑さを軽減します。ビルダーオブジェクトにはオプションのものと必須のものがあり、すべて [RESTful API リファレンスページ](/weaviate/api/rest) と [GraphQL リファレンスページ](/weaviate/api) にドキュメントがあります。 + +上記のコードスニペットは `RESTful GET /v1/schema` に類似したシンプルなクエリを示しています。まずパッケージを読み込み、実行中のインスタンスへ接続してクライアントを初期化します。その後、`.Getter()` で `.Schema` を取得してクエリを構築します。クエリは `.Go()` 関数で送信されます。このオブジェクトは、構築して実行したいすべての関数で必須です。 + +## 移行ガイド + +### `v2` から `v4` への移行 + +#### 不要な `.Objects()` の削除 + +Before: + +```go +client.GraphQL().Get().Objects().WithClassName... +``` + +After: + +```go +client.GraphQL().Get().WithClassName +``` + +#### GraphQL `Get().WithNearVector()` のビルダーパターン化 + +`v2` では `client.GraphQL().Get()` に `nearVector` 引数を指定する際、文字列を渡す必要がありました。そのため、ユーザーは GraphQL API の構造を理解している必要がありました。`v4` では次のようにビルダーパターンを採用してこの問題を解決しています。 + +Before: + +```go +client.GraphQL().Get(). + WithNearVector("{vector: [0.1, -0.2, 0.3]}")... +``` + +After + +```go +nearVector := client.GraphQL().NearVectorArgBuilder(). + WithVector([]float32{0.1, -0.2, 0.3}) + +client.GraphQL().Get(). + WithNearVector(nearVector)... +``` + +#### すべての `where` フィルターが同一のビルダーを使用 + +`v2` ではフィルターの指定方法が文字列だったり構造化されていたりとまちまちでした。`v4` では統一され、常に同じビルダーパターンを使用できます。 + +##### GraphQL Get + +Before: + +```go +// using filter encoded as string +where := `where :{ + operator: Equal + path: ["id"] + valueText: "5b6a08ba-1d46-43aa-89cc-8b070790c6f2" +}` + +client.GraphQL().Get(). + Objects(). + WithWhere(where)... +``` + +```go +// using deprecated graphql arg builder +where := client.GraphQL().WhereArgBuilder(). + WithOperator(graphql.Equal). + WithPath([]string{"id"}). + WithValueString("5b6a08ba-1d46-43aa-89cc-8b070790c6f2") + +client.GraphQL().Get(). + Objects(). + WithWhere(where)... +``` + +After: + +```go +where := filters.Where(). + WithPath([]string{"id"}). + WithOperator(filters.Equal). + WithValueString("5b6a08ba-1d46-43aa-89cc-8b070790c6f2") + +client.GraphQL().Get(). + WithWhere(where)... +``` + +##### GraphQL Aggregate + +Before: + +```go +where := client.GraphQL().WhereArgBuilder(). + WithPath([]string{"id"}). + WithOperator(graphql.Equal). + WithValueString("5b6a08ba-1d46-43aa-89cc-8b070790c6f2") + +client.GraphQL().Aggregate(). + Objects(). + WithWhere(where)... +``` + +After: + +```go +where := filters.Where(). + WithPath([]string{"id"}). + WithOperator(filters.Equal). + WithValueString("5b6a08ba-1d46-43aa-89cc-8b070790c6f2") + +client.GraphQL().Aggregate(). + WithWhere(where)... +``` + +##### Classification + +Before: + +```go +valueInt := 100 +valueText := "Government" + +sourceWhere := &models.WhereFilter{ + ValueInt: &valueInt, + Operator: string(graphql.GreaterThan), + Path: []string{"wordCount"}, +} + +targetWhere := &models.WhereFilter{ + ValueString: &valueText, + Operator: string(graphql.NotEqual), + Path: []string{"name"}, +} + +client.Classifications().Scheduler(). + WithSourceWhereFilter(sourceWhere). + WithTargetWhereFilter(targetWhere)... +``` + +After: + +```go +sourceWhere := filters.Where(). + WithOperator(filters.GreaterThan). + WithPath([]string{"wordCount"}). + WithValueInt(100) + +targetWhere := filters.Where(). + WithOperator(filters.NotEqual). + WithPath([]string{"name"}). + WithValueString("Government") + +client.Classifications().Scheduler(). + WithSourceWhereFilter(sourceWhere). + WithTargetWhereFilter(targetWhere)... +``` + +#### GraphQL `Get().WithFields()` + +`v2` の `.WithFields()` は GraphQL 文字列を受け取り、GraphQL フィールド構造の理解が必要でした。現在は可変長引数の関数で指定できます。例: + +Before: + +```go +client.GraphQL.Get().WithClassName("MyClass").WithFields("name price age")... +``` + +After: + +```go +client.GraphQL.Get().WithClassName("MyClass"). + WithFields(graphql.Field{Name: "name"},graphql.Field{Name: "price"}, graphql.Field{Name: "age"})... +``` + +#### GraphQL `Get().WithGroup()` + +`v2` の `.WithGroup()` は GraphQL 文字列を受け取り、GraphQL フィールド構造の理解が必要でした。現在はビルダーで指定できます。例: + +Before: + +```go +client.GraphQL.Get().WithClassName("MyClass") + .WithGroup("{type:merge force:1.0}") +``` + +After: + +```go +group := client.GraphQL().GroupArgBuilder() + .WithType(graphql.Merge).WithForce(1.0) + +client.GraphQL.Get().WithClassName("MyClass").WithGroup(group) +``` + +#### GraphQL `Data().Validator()` プロパティのリネーム + +`v2` ではスキーマを指定するメソッド名がクライアントの他の場所と一貫していませんでした。`v4` で修正されています。以下のようにリネームしてください。 + +Before: +```go +client.Data().Validator().WithSchema(properties) +``` + +After: +```go +client.Data().Validator().WithProperties(properties) +``` + +## リリース + +Go のクライアントライブラリのリリース履歴は、[GitHub releases ページ](https://github.com/weaviate/weaviate-go-client/releases)をご覧ください。 + +
+ Weaviate と対応クライアントバージョンの一覧はこちらをクリック + +import ReleaseHistory from '/_includes/release-history.md'; + + + +
+ +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/index.mdx new file mode 100644 index 000000000..b2ee8d185 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/index.mdx @@ -0,0 +1,66 @@ +--- +title: クライアント ライブラリ / SDK +sidebar_position: 0 +description: "複数のプログラミング言語でシームレスに統合できる Weaviate クライアント ライブラリと SDK の概要。" +image: og/docs/client-libraries.jpg +# hide_table_of_contents: true +# tags: ['client libraries', 'cli'] +--- + +Weaviate には GraphQL 、 gRPC 、 RESTful API を直接使用するか、利用可能なクライアント ライブラリを使用してアクセスできます。現在、Weaviate がサポートしているのは次のとおりです: + +import CardsSection from "/src/components/CardsSection"; + +export const clientLibrariesData = [ + { + title: "Python Client", + description: + "Install and use the official Python client (v4) to interact with Weaviate.", + link: "/weaviate/client-libraries/python/", + icon: "fab fa-python", + }, + { + title: "TypeScript / JavaScript Client", + description: + "Use the official client (v3) with Node.js.", + link: "/weaviate/client-libraries/typescript/", + icon: "fab fa-js", + }, + { + title: "Go Client", + description: + "Install and use the official Go client library to integrate Weaviate into Go applications.", + link: "/weaviate/client-libraries/go", + icon: "fab fa-golang", + }, + { + title: "Java Client", + description: + "Install and use the official Java client library for interacting with Weaviate.", + link: "/weaviate/client-libraries/java", + icon: "fab fa-java", + }, +]; + +
+ +
+ +import ClientCapabilitiesOverview from "/_includes/client.capabilities.mdx"; + + + +### コミュニティ製クライアント + +素晴らしいコミュニティ メンバーによって作成された [community clients](./community.md) も存在します。これらのクライアントはコア Weaviate チームではなく、コミュニティ メンバー自身によって保守されています。貢献したい場合は、メンテナーへ直接ご連絡ください。 + +:::note ご希望の言語が見つかりませんか? +クライアントを提供したい、または特定のクライアントをリクエストしたい場合は、[フォーラム](https://forum.weaviate.io/) でお知らせください。 +::: + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/java.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/java.md new file mode 100644 index 000000000..f978c2c8c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/java.md @@ -0,0 +1,503 @@ +--- +title: Java +sidebar_position: 50 +description: "Weaviate と Go アプリケーションおよびサービスを統合するための公式 Java クライアントライブラリのドキュメント。" +image: og/docs/client-libraries.jpg +# tags: ['java', 'client library'] +--- + +import QuickLinks from "/src/components/QuickLinks"; + +export const javaCardsData = [ + { + title: "weaviate/java-client", + link: "https://github.com/weaviate/java-client", + icon: "fa-brands fa-github", + }, +]; + +:::note Java クライアント (SDK) + +最新の Java クライアントのバージョンは `v||site.java_client_version||` です。 + + + +::: + +:::info v4 で導入された破壊的変更 +`package` と `import` のパスが `technology.semi.weaviate` から `io.weaviate` に変更されました。 + +詳細は [移行ガイド](#from-3xx-to-400) を参照してください。 +::: + +## インストールとセットアップ +最新の安定版 Java クライアントライブラリを取得するには、次の依存関係をプロジェクトに追加してください。 + +```xml + + io.weaviate + client + 4.7.0 + +``` + +この API クライアントは Java 8 以降と互換性があります。 + +プロジェクト内でのクライアントの使用例は次のとおりです。 + +```java +package io.weaviate; + +import io.weaviate.client.Config; +import io.weaviate.client.WeaviateClient; +import io.weaviate.client.base.Result; +import io.weaviate.client.v1.misc.model.Meta; + +public class App { + public static void main(String[] args) { + Config config = new Config("http", "localhost:8080"); + WeaviateClient client = new WeaviateClient(config); + Result meta = client.misc().metaGetter().run(); + if (meta.getError() == null) { + System.out.printf("meta.hostname: %s\n", meta.getResult().getHostname()); + System.out.printf("meta.version: %s\n", meta.getResult().getVersion()); + System.out.printf("meta.modules: %s\n", meta.getResult().getModules()); + } else { + System.out.printf("Error: %s\n", meta.getError().getMessages()); + } + } +} +``` + +## 認証 + +import ClientAuthIntro from '/docs/weaviate/client-libraries/_components/client.auth.introduction.mdx' + + + +### WCD 認証 + +import ClientAuthWCD from '/docs/weaviate/client-libraries/_components/client.auth.wcs.mdx' + + + +### API キー認証 + +:::info Weaviate Java クライアントバージョン `4.0.2` で追加されました。 +::: + +import ClientAuthApiKey from '/docs/weaviate/client-libraries/_components/client.auth.api.key.mdx' + + + +```java +import io.weaviate.client.Config; +import io.weaviate.client.WeaviateAuthClient; + +Config config = new Config("https", "WEAVIATE_INSTANCE_URL"); +WeaviateClient client = WeaviateAuthClient.apiKey(config, "YOUR-WEAVIATE-API-KEY"); // Replace with your Weaviate instance API key +``` + +### OIDC 認証 + +import ClientAuthOIDCIntro from '/docs/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx' + + + +#### リソースオーナーパスワードフロー + +import ClientAuthFlowResourceOwnerPassword from '/docs/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx' + + + +```java +import io.weaviate.client.Config; +import io.weaviate.client.WeaviateAuthClient; + +Config config = new Config("http", "weaviate.example.com:8080"); +WeaviateAuthClient.clientPassword( + config, + "Your user", + "Your password", + Arrays.asList("scope1", "scope2") // optional, depends on the configuration of your identity provider (not required with WCD) +); +``` + +#### クライアントクレデンシャルフロー + +import ClientAuthFlowClientCredentials from '/docs/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx' + + + +```java +import io.weaviate.client.Config; +import io.weaviate.client.WeaviateAuthClient; + +Config config = new Config("http", "weaviate.example.com:8080"); +WeaviateAuthClient.clientCredentials( + config, + "your_client_secret", + Arrays.asList("scope1" ,"scope2") // optional, depends on the configuration of your identity provider +); +``` + +#### リフレッシュトークンフロー + +import ClientAuthBearerToken from '/docs/weaviate/client-libraries/_components/client.auth.bearer.token.mdx' + + + +```java +import io.weaviate.client.Config; +import io.weaviate.client.WeaviateAuthClient; + +Config config = new Config("http", "weaviate.example.com:8080"); +WeaviateAuthClient.bearerToken( + config, + "Your_access_token", + 500, // lifetime in seconds + "Your_refresh_token", +); +``` + +## カスタムヘッダー + +クライアント初期化時に追加されるカスタムヘッダーを渡すことができます。 + +```java +import io.weaviate.client.Config; +import io.weaviate.client.WeaviateClient; + +public class App { + public static void main(String[] args) { + Map headers = new HashMap() { { + put("header_key", "value"); + } }; + Config config = new Config("http", "localhost:8080", headers); + WeaviateClient client = new WeaviateClient(config); + } +} +``` + +## 参照 + +すべての [RESTful エンドポイント](/weaviate/api/rest) と [GraphQL 関数](../api/graphql/index.md) のリファレンスは Java クライアントでサポートされており、各リファレンスページのコードブロックで解説しています。 + +## 型付き GraphQL 応答 + +Weaviate Java クライアントは、GraphQL クエリの応答を自動的に Java オブジェクトへデシリアライズします。これにより手動で JSON を解析する必要がなくなり、コレクションデータを扱う際にコンパイル時の型安全性が得られます。 + +たとえば、次のクエリの応答を受け取るために `Pizzas` クラスを定義できます。 + +```java +@Getter +public static class Pizzas { + @SerializedName(value = "Pizza") + List pizzas; + + @Getter + public static class Pizza extends GraphQLGetBaseObject { + String name; + String description; + String bestBefore; + Float price; + } +} + +try (WeaviateAsyncClient asyncClient = client.async()) { + return asyncClient.graphQL().get() + .withClassName("Pizza") + .withFields(Field.builder().name("name").build(), Field.builder().name("description").build()) + .run(Pizzas.class) + .get(); +} +``` + +返却される応答は `GraphQLTypedResponse` オブジェクトになります。 + +```java +Result> result = getResults(); + +List pizzas = result.getResult().getData().getObjects().getPizzas(); + +Pizzas.Pizza pizza = pizzas.get(0); + +// access Pizza specific properties +Float price = pizza.getPrice(); + +// access _additional values like vector (and others) +Float[] vector = pizza.getAdditional().getVector(); +Float certainty = pizza.getAdditional().getCertainty(); +``` + +## 設計 + +### ビルダー パターン + +Java クライアントの各関数は「 Builder パターン」で設計されています。 このパターンは複雑なクエリ オブジェクトを構築するために使用されます。 つまり、( RESTful の GET リクエストに似たリクエストで Weaviate からデータを取得する場合や、より複雑な GraphQL クエリを行う場合など)1 つ 1 つのオブジェクトを組み合わせて関数を構築し、複雑さを低減します。 ビルダー オブジェクトの中にはオプションのものもあれば、特定の機能を実行するために必須のものもあります。 詳細は [RESTful API リファレンス](/weaviate/api/rest) と [GraphQL リファレンス](../api/graphql/index.md) に記載されています。 + +上記のコード スニペットは、`RESTful GET /v1/meta` に相当するシンプルなクエリを示しています。 クライアントはパッケージをインポートし、起動中のインスタンスへ接続することで初期化します。 その後、`.misc()` に対して `.metaGetter()` を呼び出してクエリを構築します。 クエリは `.run()` 関数で送信されるため、このオブジェクトは作成して実行したいすべての関数で必須になります。 + +## 移行ガイド + +### `3.x.x` から `4.0.0` への移行 + +#### `technology.semi.weaviate` から `io.weaviate` パッケージへ移動 + +Before: +```java +package technology.semi.weaviate; +import technology.semi.weaviate.client.*; +``` + +After: +```java +package io.weaviate; +import io.weaviate.client.*; +``` + +### `2.4.0` から `3.0.0` への移行 + +#### 非推奨 (@Deprecated) メソッド `Aggregate::withFields(Fields fields)` を削除 + +Before: +```java +// import io.weaviate.client.v1.graphql.query.fields.Field; +// import io.weaviate.client.v1.graphql.query.fields.Fields; + +Fields fields = Fields.builder().fields(new Field[]{name, description}).build(); +client.graphQL().aggregate().withFields(fields)... +``` + +After: +```java +client.graphQL().aggregate().withFields(name, description)... +``` + +#### 非推奨 (@Deprecated) メソッド `Get::withFields(Fields fields)` を削除 + +Before: +```java +// import io.weaviate.client.v1.graphql.query.fields.Field; +// import io.weaviate.client.v1.graphql.query.fields.Fields; + +Fields fields = Fields.builder().fields(new Field[]{name, description}).build(); +client.graphQL().get().withFields(fields)... +``` + +After: +```java +client.graphQL().get().withFields(name, description)... +``` + +#### 非推奨 (@Deprecated) メソッド `Get::withNearVector(Float[] vector)` を削除 + +Before: +```java +client.graphQL().get().withNearVector(new Float[]{ 0f, 1f, 0.8f })... +``` + +After: +```java +// import io.weaviate.client.v1.graphql.query.argument.NearVectorArgument; + +NearVectorArgument nearVector = NearVectorArgument.builder().vector(new Float[]{ 0f, 1f, 0.8f }).certainty(0.8f).build(); +client.graphQL().get().withNearVector(nearVector)... +``` + +#### すべての `where` フィルターが同一実装を使用 + +`batch delete` 機能の導入に伴い、`filters.WhereFilter` の統一実装が追加され、`classifications.WhereFilter`、`graphql.query.argument.WhereArgument`、`graphql.query.argument.WhereFilter` を置き換えました。 + +##### GraphQL + +Before: +```java +// import io.weaviate.client.v1.graphql.query.argument.GeoCoordinatesParameter; +// import io.weaviate.client.v1.graphql.query.argument.WhereArgument; +// import io.weaviate.client.v1.graphql.query.argument.WhereOperator; + +GeoCoordinatesParameter geo = GeoCoordinatesParameter.builder() + .latitude(50.51f) + .longitude(0.11f) + .maxDistance(3000f) + .build(); +WhereArgument where = WhereArgument.builder() + .valueGeoRange(geo) + .operator(WhereOperator.WithinGeoRange) + .path(new String[]{ "add "}) + .build(); + +client.graphQL().aggregate().withWhere(where)... +``` + +After: +```java +// import io.weaviate.client.v1.filters.Operator; +// import io.weaviate.client.v1.filters.WhereFilter; + +WhereFilter where = WhereFilter.builder() + .valueGeoRange(WhereFilter.GeoRange.builder() + .geoCoordinates(WhereFilter.GeoCoordinates.builder() + .latitude(50.51f) + .longitude(0.11f) + .build() + ) + .distance(WhereFilter.GeoDistance.builder() + .max(3000f) + .build() + ) + .build() + ) + .operator(Operator.WithinGeoRange) + .path(new String[]{ "add" }) + .build(); + +client.graphQL().aggregate().withWhere(where)... +``` + +Before: +```java +// import io.weaviate.client.v1.graphql.query.argument.WhereArgument; +// import io.weaviate.client.v1.graphql.query.argument.WhereOperator; + +WhereArgument where = WhereArgument.builder() + .valueText("txt") + .operator(WhereOperator.Equal) + .path(new String[]{ "add" }) + .build(); + +client.graphQL().aggregate().withWhere(where)... +``` + +After: +```java +// import io.weaviate.client.v1.filters.Operator; +// import io.weaviate.client.v1.filters.WhereFilter; + +WhereFilter where = WhereFilter.builder() + .valueText("txt") + .operator(Operator.Equal) + .path(new String[]{ "add" }) + .build(); + +client.graphQL().aggregate().withWhere(where)... +``` + +Before: +```java +// import io.weaviate.client.v1.graphql.query.argument.WhereArgument; +// import io.weaviate.client.v1.graphql.query.argument.WhereFilter; +// import io.weaviate.client.v1.graphql.query.argument.WhereOperator; + +WhereArgument where = WhereArgument.builder() + .operands(new WhereFilter[]{ + WhereFilter.builder() + .valueInt(10) + .path(new String[]{ "wordCount" }) + .operator(WhereOperator.LessThanEqual) + .build(), + WhereFilter.builder() + .valueText("word") + .path(new String[]{ "word" }) + .operator(WhereOperator.LessThan) + .build() + }) + .operator(WhereOperator.And) + .build(); + +client.graphQL().aggregate().withWhere(where)... +``` + +After: +```java +// import io.weaviate.client.v1.filters.Operator; +// import io.weaviate.client.v1.filters.WhereFilter; + +WhereFilter where = WhereFilter.builder() + .operands(new WhereFilter[]{ + WhereFilter.builder() + .valueInt(10) + .path(new String[]{ "wordCount" }) + .operator(Operator.LessThanEqual) + .build(), + WhereFilter.builder() + .valueText("word") + .path(new String[]{ "word" }) + .operator(Operator.LessThan) + .build(), + }) + .operator(Operator.And) + .build(); + +client.graphQL().aggregate().withWhere(where)... +``` + +##### 分類 + +Before: +```java +// import io.weaviate.client.v1.classifications.model.GeoCoordinates; +// import io.weaviate.client.v1.classifications.model.Operator; +// import io.weaviate.client.v1.classifications.model.WhereFilter; +// import io.weaviate.client.v1.classifications.model.WhereFilterGeoRange; +// import io.weaviate.client.v1.classifications.model.WhereFilterGeoRangeDistance; + +WhereFilter where = WhereFilter.builder() + .valueGeoRange(WhereFilterGeoRange.builder() + .geoCoordinates(GeoCoordinates.builder() + .latitude(50.51f) + .longitude(0.11f) + .build()) + .distance(WhereFilterGeoRangeDistance.builder() + .max(3000d) + .build()) + .build()) + .operator(Operator.WithinGeoRange) + .path(new String[]{ "geo" }) + .build(); + +client.classifications().scheduler().withTrainingSetWhereFilter(where)... +``` + +After: +```java +// import io.weaviate.client.v1.filters.Operator; +// import io.weaviate.client.v1.filters.WhereFilter; + +WhereFilter where = WhereFilter.builder() + .valueGeoRange(WhereFilter.GeoRange.builder() + .geoCoordinates(WhereFilter.GeoCoordinates.builder() + .latitude(50.51f) + .longitude(0.11f) + .build()) + .distance(WhereFilter.GeoDistance.builder() + .max(3000f) + .build()) + .build()) + .operator(Operator.WithinGeoRange) + .path(new String[]{ "geo" }) + .build(); + +client.classifications().scheduler().withTrainingSetWhereFilter(where)... +``` + +## リリース + +Java クライアント ライブラリのリリース履歴については、[GitHub のリリース ページ](https://github.com/weaviate/java-client/releases) をご覧ください。 + +
+ Weaviate と対応するクライアント バージョンの表を表示 + +import ReleaseHistory from '/_includes/release-history.md'; + + + +
+ +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/async.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/async.md new file mode 100644 index 000000000..ca6297804 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/async.md @@ -0,0 +1,214 @@ +--- +title: 非同期 API +sidebar_position: 40 +description: "高パフォーマンスでノンブロッキングな Weaviate 操作を実現する非同期 Python クライアントのドキュメント。" +image: og/docs/client-libraries.jpg +# tags: ['python', 'client library'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCode from '!!raw-loader!/_includes/code/client-libraries/python_v4.py'; +import FastAPIExample from '!!raw-loader!/_includes/code/client-libraries/minimal_fastapi.py'; + +:::info `weaviate-client` `v4.7.0` で追加 +非同期 Python クライアントは、`weaviate-client` バージョン `4.7.0` 以降で利用できます。 +::: + +Python クライアントライブラリはデフォルトで [同期 API](./index.mdx) を提供しますが、並列アプリケーション向けに非同期 API も利用できます。 + +非同期処理を行う場合は、`weaviate-client` `v4.7.0` 以降で利用可能な `WeaviateAsyncClient` async クライアントを使用してください。 + +`WeaviateAsyncClient` async クライアントは、`WeaviateClient` [同期クライアント](./index.mdx) とほぼ同じ関数およびメソッドをサポートしていますが、async クライアントは [`asyncio` イベントループ](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio-event-loop) で実行される `async` 関数内で使用するよう設計されています。 + +## インストール + +async クライアントはすでに `weaviate-client` パッケージに含まれています。[Python クライアントライブラリのドキュメント](./index.mdx#installation) に従ってインストールしてください。 + +## インスタンス化 + +async クライアント `WeaviateAsyncClient` オブジェクトは、[ヘルパー関数を使用して](#instantiation-helper-functions) あるいは [クラスのインスタンスを明示的に生成して](#explicit-instantiation) 作成できます。 + +### インスタンス化ヘルパー関数 + + +これらのインスタンス化ヘルパー関数は同期クライアントのヘルパー関数と似ており、同等の async クライアントオブジェクトを返します。 + +- `use_async_with_local` +- `use_async_with_weaviate_cloud` +- `use_async_with_custom` + +ただし、async ヘルパー関数は同期版と異なり、サーバーへ接続しません。 + +async ヘルパー関数を使用する場合は、サーバーに接続するために async メソッド `.connect()` を呼び出し、終了前に `.close()` を呼び出してクリーンアップしてください([コンテキストマネージャ](#context-manager) を使用する場合を除く)。 + + +async ヘルパー関数は、外部 API キー、接続タイムアウト値、および認証情報に関して同期版と同じパラメーターを受け取ります。 + + + + + + + + + + + + + + + + + + + + + + +### 明示的なインスタンス化 + +カスタムパラメーターを渡す必要がある場合は、`weaviate.WeaviateAsyncClient` クラスを使用してクライアントをインスタンス化します。これはクライアントオブジェクトを生成する最も柔軟な方法です。 + + + +接続を直接インスタンス化した場合、サーバーへ接続するには(非同期化された)`.connect()` メソッドを呼び出す必要があります。 + + + +## 同期メソッドと非同期メソッド + +async クライアントオブジェクトは、[`asyncio` イベントループ](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio-event-loop) で実行される `async` 関数内で使用するよう設計されています。 + +そのため、クライアントメソッドの大半は `Coroutine` オブジェクトを返す `async` 関数ですが、一部のメソッドは同期的であり同期コンテキストで使用できます。 + +一般的な目安として、Weaviate へリクエストを送信するメソッドは async 関数であり、ローカルコンテキストで完結するメソッドは同期関数です。 + +### 非同期メソッドの識別方法 + +非同期メソッドはメソッドシグネチャで識別できます。async メソッドは `async` キーワードで定義され、`Coroutine` オブジェクトを返します。 + +メソッドシグネチャを確認するには、Python の `help()` 関数を使用するか、[Visual Studio Code](https://code.visualstudio.com/docs) や [PyCharm](https://www.jetbrains.com/help/pycharm/viewing-reference-information.html) などのコード補完をサポートする IDE を利用してください。 + +### 非同期メソッドの例 + +Weaviate にリクエストを送信する操作はすべて async 関数です。例えば、次の各操作は async 関数です。 + +- `async_client.connect()`: Weaviate サーバーへ接続 +- `async_client.collections.create()`: 新しいコレクションを作成 +- `.data.insert_many()`: オブジェクトのリストをコレクションに追加 + + + +### 同期メソッドの例 + +ローカルコンテキストで実行されるメソッドは同期である場合が多いです。例えば、次の操作はいずれも同期関数です。 + +- `async_client.collections.use("")`: 既存のコレクションと対話するための Python オブジェクトを作成します(コレクションを作成するわけではありません) +- `async_client.is_connected()`: Weaviate サーバーへの最新の接続状況を確認します + +## コンテキストマネージャー + +async クライアントは、非同期コンテキストマネージャー内で次のようなパターンで使用できます。 + + + +コンテキストマネージャーで async クライアントを使用する場合、`.connect()` や `.close()` を明示的に呼び出す必要はありません。クライアントが接続と切断を自動的に処理します。 + +## 非同期使用例 + +async クライアントオブジェクトは、[同期版 Python クライアント](./index.mdx) とほぼ同じ機能を提供しますが、いくつかの重要な違いがあります。まず、async クライアントは [`asyncio` イベントループ](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio-event-loop) で動作する `async` 関数内での使用を前提としています。そのため、多くのメソッドは `async` 関数であり、[`Coroutine` オブジェクト](https://docs.python.org/3/library/asyncio-task.html#coroutine) を返します。 + +async クライアントのメソッドを実行するには、別の `async` 関数内で `await` する必要があります。Python スクリプトで `async` 関数を実行するには、`asyncio.run(my_async_function)` またはイベントループを直接使用できます。 + +```python +loop = asyncio.new_event_loop() +loop.run_until_complete(my_async_function()) +``` + +### データ挿入 + +この例では、新しいコレクションを作成し、async クライアントを使用してオブジェクトのリストを挿入します。 + +async 関数内でコンテキストマネージャーを使用している点に注目してください。これはデータ挿入中にクライアントがサーバーに接続されていることを保証するためです。 + + + +### 検索 & RAG + +この例では、async クライアントを使用してハイブリッド検索結果に対して検索拡張生成 (RAG) を実行します。 + +async 関数内でコンテキストマネージャーを使用している点に注目してください。これはデータ挿入中にクライアントがサーバーに接続されていることを保証するためです。 + + + +### 大量データ挿入 + +サーバーサイドのバッチ操作には、同期クライアントの [`batch` 操作](../../manage-objects/import.mdx) を使用することを推奨します。`batch` 操作は、すでに並行リクエストによって大量データを効率的に処理できるよう設計されています。 + +async クライアントでも `insert` と `insert_many` メソッドを提供しており、非同期コンテキストで使用できます。 + +### アプリケーションレベルの例 + +async クライアントの一般的なユースケースに、複数のリクエストを同時に処理する Web アプリケーションがあります。以下は、モジュラーな Web API マイクロサービスを作成するための人気フレームワーク FastAPI と async クライアントを統合した最小限の例です。 + + + +この例を実行すると、FastAPI サーバーが `http://localhost:8000` で起動します。`/` と `/search` エンドポイントを使用してサーバーと対話できます。 + +:::note データ挿入は表示していません +この例は最小構成であり、コレクションの作成やオブジェクトの挿入は含まれていません。`Movie` というコレクションが既に存在していることを前提としています。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/index.mdx new file mode 100644 index 000000000..804fb25da --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/index.mdx @@ -0,0 +1,394 @@ +--- +title: Python +sidebar_position: 10 +description: "Weaviate を Python アプリケーションやサービスに統合するための公式 Python クライアントライブラリのドキュメント。" +image: og/docs/client-libraries.jpg +# tags: ['python', 'client library', 'experimental'] +--- + +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PythonCode from "!!raw-loader!/_includes/code/client-libraries/get_started.py"; +import QuickLinks from "/src/components/QuickLinks"; + +export const pythonCardsData = [ + { + title: "weaviate/weaviate-python-client", + link: "https://github.com/weaviate/weaviate-python-client", + icon: "fa-brands fa-github", + }, + { + title: "Reference manual (docstrings)", + link: "https://weaviate-python-client.readthedocs.io/en/latest/", + icon: "fa-solid fa-book", + }, +]; + +:::note Python client (SDK) + +最新の Python クライアントはバージョン `v||site.python_client_version||` です。 + + + +::: + +このページでは Weaviate Python クライアント(`v4` リリース)について概説します。Python クライアントに特化しない使用例などは、[How-to マニュアル & Guides](../../guides.mdx) をご覧ください。 + +## インストール + +Python クライアントライブラリは Python 3.8+ で開発・テストされています。[PyPI.org](https://pypi.org/project/weaviate-client/) から入手でき、次のコマンドでインストール可能です。 + +```bash +pip install -U weaviate-client +``` + +
+ ベータ版のインストール方法 + +```bash +pip install --pre -U "weaviate-client==4.*"` +``` + +
+ +
+ 要件: Weaviate バージョン互換性 & gRPC + +#### Weaviate バージョン互換性 + +`v4` Python クライアントは Weaviate `1.23.7` 以上が必要です。一般的に、Python クライアントと Weaviate データベースは最新バージョンのご利用を推奨します。 + +Weaviate Cloud では、2024-01-31 以降に作成された Sandbox は `v4` クライアントと互換性があります。この日付以前に作成された Sandbox は `v4` クライアントと互換性がありません。 + +#### gRPC + +`v4` クライアントは内部で RPC を使用します。そのため、Weaviate サーバーへの gRPC 用ポートを開放しておく必要があります。 + +
+ docker-compose.yml の例 + +Docker で Weaviate を実行している場合、デフォルトポート(`50051`)を次のように `docker-compose.yml` にマッピングできます。 + +```yaml +ports: + - 8080:8080 + - 50051:50051 +``` + +
+ +
+ +#### Weaviate エージェント + +[Weaviate Agents](../../../agents/index.md) を使用するために、オプションの agents エクストラ付きで Weaviate クライアントライブラリをインストールできます。以下のコマンドを実行してください。 + +```bash +pip install -U weaviate-client[agents] +``` + +## はじめる + +import BasicPrereqs from "/_includes/prerequisites-quickstart.md"; + + + +以下の Python 例では、Weaviate を使い始めるための主要な手順を順に説明しています。 + +1. **[Weaviate に接続](docs/weaviate/connections/index.mdx)**: ローカル(または Cloud)環境の Weaviate インスタンスへ接続します。 +1. **[コレクションを作成](../../manage-collections/index.mdx)**: `Question` コレクションのデータスキーマを定義し、Ollama モデルでデータをベクトル化します。 +1. **[データをインポート](../../manage-objects/import.mdx)**: サンプルの Jeopardy 問題を取得し、Weaviate のバッチインポートで効率的に取り込み、ベクトル埋め込みを自動生成します。 +1. **[データベースを検索/クエリ](../../search/index.mdx)**: ベクトル検索を実行し、`biology` と意味的に類似した質問を検索します。 + +import VectorsAutoSchemaError from "/_includes/error-note-vectors-autoschema.mdx"; + + + + + +より多くのコード例については、[How-to マニュアル & Guides](../../guides.mdx) をご確認ください。 + +## 非同期使用 + +Python クライアントライブラリはデフォルトで `WeaviateClient` クラスによる同期 API を提供します(本ページで説明)。`weaviate-client` `v4.7.0` 以降では、`WeaviateAsyncClient` クラスによる非同期 API も利用可能です。詳細は [async クライアント API ページ](./async.md) を参照してください。 + +## リリース + +Python クライアントライブラリのリリース履歴と変更ログは、[GitHub のリリースページ](https://github.com/weaviate/weaviate-python-client/releases) をご覧ください。 + +
+ Weaviate と対応クライアントバージョンの表はこちらをクリック + +import ReleaseHistory from "/_includes/release-history.md"; + + + +
+ + + +#### ベクトライザー API 変更 `v4.16.0` + + + +Weaviate Python クライアント `v4.16.0` から、コレクションを作成する際の ベクトライザー 設定 API に複数の変更があります: +- `.vectorizer_config` は `.vector_config` に置き換えられました +- `Configure.NamedVectors` は `Configure.Vectors` と `Configure.MultiVectors` に置き換えられました +- `Configure.NamedVectors.none` と `Configure.Vectorizer.none` は `Configure.Vectors.self_provided` と `Configure.MultiVectors.self_provided` に置き換えられました + +#### `v3` から `v4` への移行 + +Python `v3` クライアントから `v4` クライアントへ移行する場合は、この [専用ガイド](./v3_v4_migration.md) を参照してください。 + +#### ベータリリース + +
+ 移行ガイド - ベータリリース + +#### `v4.4b9` における変更点 + +##### `weaviate.connect_to_x` メソッド + +`timeout` 引数は `additional_config` 引数の一部になりました。入力として `weaviate.config.AdditionalConfig` クラスを受け取ります。 + +##### クエリ + +`query` 名前空間内のすべてのオプション引数は、キーワード引数としてのみ指定する必要があります。 + +クエリ引数を解析する実行時ロジックが追加され、正しい型が強制されます。 + +##### バッチ処理 + +バックグラウンドで異なるバッチ方式を用いる 3 種類のアルゴリズムが導入されました: + +- `client.batch.dynamic()` +- `client.batch.fixed_size()` +- `client.batch.rate_limit()` + +`client.batch.dynamic() as batch` は、以前の `client.batch as batch`(非推奨、正式リリース時に削除予定)のドロップインリプレースメントです。 + +```python +with client.batch.dynamic() as batch: + ... +``` + +は次と同等です: + +```python +with client.batch as batch: + ... +``` + +`client.batch.fixed_size() as batch` は、固定サイズのみを使用するバッチングアルゴリズムを設定する方法です。 + +```python +with client.batch.dynamic() as batch: + ... +``` + +は次と同等です: + +```python +client.batch.configure_fixed_size() +with client.batch as batch: + ... +``` + +`client.batch.rate_limit() as batch` は、サードパーティ ベクトル化 API のレートリミットに達するのを回避する新しい方法です。`rate_limit()` メソッドで `request_per_minute` を指定することで、サードパーティ API が処理可能な速度でオブジェクトを Weaviate に送信するようバッチングアルゴリズムを制御できます。 + +これらのメソッドは完全にローカライズされたコンテキストマネージャを返します。つまり、あるバッチの `failed_objects` や `failed_references` は後続の呼び出しには含まれません。 + +最後に、バッチ送信を担当するバックグラウンドスレッドで例外が発生した場合、メインスレッドで再スローされ、静かに失敗することはありません。 + +##### フィルター + +`Filter.by_property` の引数 `prop` は `name` に改名されました。 + +参照カウントは `Filter([ref])` ではなく `Filter.by_ref_count(ref)` で実現できます。 + +#### `v4.4b8` における変更点 + +##### 参照フィルター + +参照フィルターの構文が簡略化されました。新しい構文は次のとおりです: + +```python +Filter.by_ref("ref").by_property("target_property") +``` + +#### `v4.4b7` における変更点 + +##### ライブラリのインポート + +`weaviate` から直接インポートする方法は非推奨になりました。代わりに `import weaviate.classes as wvc` を使用してください。 + +##### クライアント接続のクローズ + +v4.4b7 以降、クライアント接続を明示的にクローズする必要があります。クローズする方法は 2 つあります。 + +`client.close()` を使用してクライアント接続を明示的にクローズします。 + +```python +import weaviate +client = weaviate.connect_to_local() + +print(client.is_ready()) + +client.close() +``` + +コンテキストマネージャを使用して接続を自動でクローズさせることもできます。 + +```python +import weaviate + +with weaviate.connect_to_local() as client: + print(client.is_ready()) + +# Python closes the client when you leave the 'with' block +``` + +##### バッチ処理 + +v4.4b7 クライアントでは `client.batch` に変更があります。 + +- `client.batch` ではコンテキストマネージャが必須になりました。 +- マニュアルモードは削除され、`.create_objects` でバッチを送信できなくなりました。 +- バッチサイズと同時リクエスト数は動的に割り当てられます。値を指定するには `batch.configure_fixed_size` を使用してください。 +- `add_reference` メソッドが更新されました。 +- `to_object_collection` メソッドは削除されました。 + +更新後の `client.batch` パラメータ + +| 旧値 | v4.4b7 の値 | +| :--------------------------------------- | :------------------------------------------- | +| from_object_uuid: UUID | from_uuid: UUID | +| from_object_collection: str | from_collection: str | +| from_property_name: str | from_property: str | +| to_object_uuid: UUID | to: Union[WeaviateReference, List[UUID]] | +| to_object_collection: Optional[str] = None | | +| tenant: Optional[str] = None | tenant: Optional[str] = None | + +##### フィルター構文 + +フィルター構文は v4.4b7 で更新されました。 + +**注意**: [参照フィルター構文](#reference-filters) は 4.4b8 で簡略化されています。 + +| 旧構文 | v4.4b7 の新構文 | +| :---------------------------------------------------- | :-------------------------------------------------------------------------------- | +| Filter(path=property) | Filter.by_property(property) | +| Filter(path=["ref", "target_class", "target_property"]) | Filter.by_ref().link_on("ref").by_property("target_property") | +| FilterMetadata.ByXX | Filter.by_id()
Filter.by_creation_time()
Filter.by_update_time() | + +pre-4.4b7 のフィルター構文は非推奨です。新しい v4.4b7 構文は次のようになります。 + +```python +import weaviate +import datetime +import weaviate.classes as wvc + +client = weaviate.connect_to_local() + +jeopardy = client.collections.use("JeopardyQuestion") +response = jeopardy.query.fetch_objects( + filters=wvc.query.Filter.by_property("round").equal("Double Jeopardy!") & + wvc.query.Filter.by_creation_time().greater_or_equal(datetime.datetime(2005, 1, 1)) | + wvc.query.Filter.by_creation_time().greater_or_equal(datetime.datetime(2000, 12, 31)), + limit=3 + ) + + +client.close() +``` + +##### `reference_add_many` の更新 + +`reference_add_many` の構文が更新され、 `DataReferenceOneToMany` は `DataReference` になりました。 + +```python +collection.data.reference_add_many( + [ + DataReference( + from_property="ref", + from_uuid=uuid_from, + to_uuid=*one or a list of UUIDs*, + ) + ] +) +``` + +##### 参照 + +複数ターゲット参照が更新されました。新しい関数は次のとおりです: + +- `ReferenceProperty.MultiTarget` +- `DataReference.MultiTarget` +- `QueryReference.MultiTarget` + +複数ターゲット参照には `ReferenceToMulti` を使用してください。 + +#### 旧クライアントの変更点 + +##### 参照 + +- コレクションの作成、オブジェクトの挿入、およびクエリーの際に、参照は `references` パラメーターを通じて追加されるようになりました。 +- `FromReference` クラスは `QueryReference` と呼ばれるようになりました。 + +##### クラス/パラメーターの再編成 + +- `weaviate.classes` サブモジュールはさらに以下に分割されました: + - `weaviate.classes.config` + - `weaviate.classes.data` + - `weaviate.classes.query` + - `weaviate.classes.generic` +- `wvc.config.Configure` および `wvc.config.Reconfigure` の `vector_index_config` パラメーターのファクトリー関数は、例えば次のように変更されました: + ```python + client.collections.create( + name="MyCollection", + # highlight-start + vector_index_config=wvc.config.Configure.VectorIndex.hnsw( + distance_metric=wvc.config.VectorDistances.COSINE, + vector_cache_max_objects=1000000, + quantizer=wvc.config.Configure.VectorIndex.Quantizer.pq() + ), + # highlight-end + ) + ``` + - `vector_index_type` パラメーターは削除されました。 +- `Property` コンストラクター メソッドの `vectorize_class_name` パラメーターは `vectorize_collection_name` に変更されました。 +- `[collection].data.update()` / `.replace()` の *args の順序が変更され、更新時にプロパティを省略できるようになりました。 +- `[collection].data.reference_add` / `.reference_delete` / `.reference_replace` で、 `ref` キーワードは `to` に改名されました。 +- `collections.create()` / `get()` において、ジェネリックを指定するための `data_model` キーワード引数は `data_model_properties` に変更されました。 +- `[object].metadata.uuid` は `[object].uuid` になりました。 +- `[object].metadata.creation_time_unix` は `[object].metadata.creation_time` になりました。 +- `[object].metadata.last_update_time_unix` は `[object].metadata.last_update` になりました。 +- `quantitizer` は `quantizer` に改名されました。 +- 返却データに ベクトル を含めるには、 `include_vector` パラメーターを使用してください。 + + +##### データ型 + +- 作成日時および最終更新日時のメタデータは `datetime` オブジェクトを返すようになり、 `MetadataQuery` ではパラメーター名が `creation_time` と `last_update_time` に変更されました。 + - `metadata.creation_time.timestamp() * 1000` は従来と同じ値を返します。 +- `query.fetch_object_by_id()` は内部で REST ではなく gRPC を使用するようになり、他のクエリーと同じ形式でオブジェクトを返します。 +- `UUID` と `DATE` プロパティは型付きオブジェクトとして返されます。 + +
+ +## コード例と追加リソース + +import CodeExamples from "/_includes/clients/code-examples.mdx"; + + + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/notes-best-practices.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/notes-best-practices.mdx new file mode 100644 index 000000000..a7e279ca0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/notes-best-practices.mdx @@ -0,0 +1,472 @@ +--- +title: メモとベストプラクティス +sidebar_position: 2 +description: "Python クライアントのベストプラクティス、最適化のヒント、および Weaviate に推奨される実装パターン。" +image: og/docs/client-libraries.jpg +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCode from '!!raw-loader!/_includes/code/client-libraries/python_v4.py'; +import BatchVectorCode from '!!raw-loader!/_includes/code/howto/manage-data.import.py'; + +## クライアントのインスタンス化 + +Weaviate インスタンスへ接続する方法はいくつかあります。クライアントを生成するには、次のいずれかのスタイルを使用します。 + +- [接続ヘルパー関数](#connection-helper-functions) +- [明示的なインスタンス化](#explicit-instantiation) + +### 接続ヘルパー関数 + +- `weaviate.connect_to_weaviate_cloud()` + - 以前は `connect_to_wcs()` +- `weaviate.connect_to_local()` +- `weaviate.connect_to_embedded()` +- `weaviate.connect_to_custom()` + + + + + + + + + + + + + + + + + + + + + + + + +`v4` クライアントのヘルパー関数には、クライアントをカスタマイズするためのオプションパラメーターがあります。 + +- [外部 API キーの指定](#external-api-keys) +- [タイムアウト値の指定](#timeout-values) +- [認証情報の指定](#authentication) + +#### 外部 API キー + +Cohere や OpenAI などのサービス向け API キーを追加するには、`headers` パラメーターを使用します。 + + + +#### タイムアウト値 + +クライアントのタイムアウト値(秒)を設定できます。`Timeout` クラスを使用して、初期化チェック、クエリ、および挿入操作のタイムアウト値を構成します。 + + + +:::tip `generate` クエリのタイムアウト + +`generate` サブモジュールを使用している際にエラーが発生する場合は、クエリのタイムアウト値(`Timeout(query=60)`)を増やしてみてください。 +
`generate` サブモジュールは、大規模言語モデルを使用してテキストを生成します。このサブモジュールは、言語モデルおよびその API の応答速度に依存します。 +
タイムアウト値を長く設定することで、クライアントが言語モデルの応答をより長く待機できるようになります。 +::: + +#### 認証 + +いくつかの `connect` ヘルパー関数は認証情報を受け取ります。たとえば、`connect_to_weaviate_cloud` は WCD API キーまたは OIDC 認証情報を受け付けます。 + + + + + + + + + + + +import WCDOIDCWarning from '/_includes/wcd-oidc.mdx'; + + + + + + +Client Credentials フローで OIDC 認証を行う場合は、`AuthClientCredentials` クラスを使用します。 + +Refresh Token フローで OIDC 認証を行う場合は、`AuthBearerToken` クラスを使用します。 + +ヘルパー関数で必要なカスタマイズが行えない場合は、[`WeaviateClient`](#explicit-instantiation) クラスを使用してクライアントを生成してください。 + +### 明示的なインスタンス化 + +カスタムパラメーターを渡す必要がある場合は、`weaviate.WeaviateClient` クラスを使用してクライアントをインスタンス化してください。これがクライアントオブジェクトをインスタンス化する最も柔軟な方法です。 + +接続を直接インスタンス化した場合は、サーバーへ接続するために `.connect()` メソッドを呼び出す必要があります。 + + + +### カスタム SSL 証明書の使用 + + Python クライアントは SSL 証明書の受け渡しを直接サポートしていません。自己署名証明書(例: エンタープライズ環境)を使用する必要がある場合、次の 2 つの方法があります。 + +#### オプション 1: 既存ライブラリーへ証明書を追加 + +Weaviate クライアントライブラリーが利用している `certifi` などの基盤ライブラリーにカスタム SSL 証明書を追加できます。 + +#### オプション 2: 環境変数を設定 + +環境変数 `GRPC_DEFAULT_SSL_ROOTS_FILE_PATH` と `SSL_CERT_FILE` を証明書ファイルのパスに設定します。インスタンス化時には `additional_config=AdditionalConfig(trust_env=True)` も設定してください。これを行わないと、クライアントライブラリーは環境変数を使用しません。 + + + +## 初期接続チェック + +Weaviate サーバーへ接続を確立するとき、クライアントはいくつかのチェックを実行します。これにはサーバーバージョンの確認や、REST ポートと gRPC ポートが利用可能かどうかの確認が含まれます。 + +`skip_init_checks` を `True` に設定すると、これらのチェックをスキップできます。 + + + +ほとんどの場合、`skip_init_checks` は既定値の `False` のまま使用することを推奨します。ただし、接続に問題がある場合の一時的な対策として `skip_init_checks=True` が役立つことがあります。 + +追加の接続設定については、[タイムアウト値](#timeout-values) を参照してください。 + +## `client.collections.use()` と `client.collections.get()` の違い + +コレクションオブジェクトを作成する慣用的な方法は `client.collections.use()` です。`client.collections.get()` と同じ動作ですが、`use()` はネットワークリクエストを行わないことがより明確に示されています。 + +`client.collections.get()` はコレクションスキーマをサーバーから取得するメソッドと誤解されやすいため、この変更を行いました。 + +将来的に `client.collections.get()` は非推奨になる可能性があります。 + +## バッチインポート + + `v4` クライアントでは、バッチインポートを実行する方法が 2 つあります。クライアントオブジェクトから直接行う方法と、コレクションオブジェクトから行う方法です。 + +単一のコレクションまたはテナントに対してバッチインポートを行う場合は、コレクションオブジェクトを使用することを推奨します。マルチテナンシー構成などで複数コレクションにわたってオブジェクトをインポートする場合は、`client.batch` を使用すると便利です。 + +### バッチサイズ設定 + +バッチ動作を構成する方法は `dynamic`、`fixed_size`、`rate_limit` の 3 つがあります。 + +| Method | Description | When to use | +| :-- | :-- | :-- | +| `dynamic` | インポート中にサーバー負荷に応じてバッチサイズと同時リクエスト数が動的に調整されます。 | 推奨される開始ポイントです。 | +| `fixed_size` | バッチサイズと同時リクエスト数をユーザーが指定した固定値にします。 | 固定パラメーターを指定したい場合。 | +| `rate_limit` | Weaviate へ送信するオブジェクト数をレート制限します(n_objects / 分で指定)。 | サードパーティのベクトライゼーション API のレート制限を回避したい場合。 | + +#### 使用方法 + +以下のようにコンテキストマネージャーを使用することを推奨します。 + +これらのメソッドは、バッチごとに新しいコンテキストマネージャーを返します。`failed_objects` や `failed_references` など、あるバッチから返された属性は後続の呼び出しには含まれません。 + + + + + + + + + + + + + + + + + + + +バッチ送信を担当するバックグラウンドスレッドがバッチ処理中に例外を送出した場合、そのエラーはメインスレッドへ伝搬します。 + +### エラーハンドリング + +バッチインポート中に失敗したオブジェクトやリファレンスは保存され、後で取得できます。また、失敗したオブジェクトとリファレンスの実行中のカウントも保持されます。 + +コンテキストマネージャー内では `batch.number_errors` でカウンターにアクセスできます。 + +失敗したオブジェクトの一覧は `batch.failed_objects`、失敗したリファレンスの一覧は `batch.failed_references` から取得できます。 + +これらのリストは新しいバッチ処理を開始するとリセットされます。したがって、新しいバッチインポートブロックを開始する前に必ず取得してください。 + + + + + +### バッチ ベクトル化 + +:::info `v1.25` で追加されました。 +::: + +import BatchVectorizationOverview from '/_includes/code/client-libraries/batch-import.mdx'; + + + +コレクションを作成するときに ベクトライザー を設定すると、クライアントが自動で ベクトル化 を処理します。 + + + + + + + +ベクトル化 の設定を変更するには、クライアント オブジェクトを更新します。次の例では複数の ベクトライザー を追加しています。 + +- **Cohere**: サービス API キーを設定します。リクエスト レートを設定します。 +- **OpenAI**: サービス API キーを設定します。ベース URL を設定します。 +- **VoyageAI**: サービス API キーを設定します。 + + + + + + + +## ヘルパー クラス + +クライアント ライブラリには、IDE 支援と型ヒントを提供する多数の追加 Python クラスがあります。以下のように個別にインポートできます。 + +``` +from weaviate.classes.config import Property, ConfigFactory +from weaviate.classes.data import DataObject +from weaviate.classes.query import Filter +``` + +しかし、次のようにクラス全体をまとめてインポートすると便利な場合もあります。ドキュメントでは両方の使用スタイルが登場します。 + +``` +import weaviate.classes as wvc +``` + +探索しやすいように、これらのクラスはサブモジュールに整理されています。 + +
+ サブモジュール一覧を見る + +| モジュール | 説明 | +| ------------------------------- | ---------------------------------- | +| `weaviate.classes.config` | コレクションの作成 / 変更 | +| `weaviate.classes.data` | CUD 操作 | +| `weaviate.classes.query` | クエリ / 検索操作 | +| `weaviate.classes.aggregate` | 集約操作 | +| `weaviate.classes.generic` | 汎用 | +| `weaviate.classes.init` | 初期化 | +| `weaviate.classes.tenants` | テナント | +| `weaviate.classes.batch` | バッチ操作 | + +
+ +## 接続の終了 + +クライアント接続は必ず閉じる必要があります。`client.close()` を使用するか、コンテキスト マネージャを使って自動で接続を閉じることもできます。 + +### `try` / `finally` を使った `client.close()` + +`try` ブロックが完了したとき(または例外が発生したとき)にクライアント接続を閉じます。 + + + +### コンテキスト マネージャ + +`with` ブロックを抜けるとクライアント接続が閉じられます。 + + + +## 例外処理 + +クライアント ライブラリはさまざまなエラー条件で例外を送出します。たとえば次のようなものがあります。 + +- `weaviate.exceptions.WeaviateConnectionError` : 接続失敗時。 +- `weaviate.exceptions.WeaviateQueryError` : クエリ失敗時。 +- `weaviate.exceptions.WeaviateBatchError` : バッチ操作失敗時。 +- `weaviate.exceptions.WeaviateClosedClientError` : クローズ済みクライアントへの操作時。 + +これらの例外はすべて `weaviate.exceptions.WeaviateBaseError` を継承しており、以下のようにこの基底クラスで捕捉できます。 + + + +クライアント ライブラリで送出される例外は、[このモジュール](https://github.com/weaviate/weaviate-python-client/blob/main/weaviate/exceptions.py) で確認できます。 + +各メソッドで送出される可能性のある例外については、クライアント ライブラリの docstring でも確認できます。Python で `help` 関数を使う、Jupyter ノートブックで `?` 演算子を使う、または VSCode のホバー ツールチップなど IDE を利用してください。 + +## スレッド セーフティ + +Python クライアントは基本的にスレッド セーフになるよう設計されていますが、`requests` ライブラリに依存しているため完全なスレッド セーフティは保証されません。 + +これは今後改善を検討している領域です。 + +:::warning Thread safety +クライアント内のバッチング アルゴリズムはスレッド セーフではありません。Python クライアントをマルチスレッド環境で使用する際は、よりスムーズで予測可能な動作となるようご注意ください。 +::: + +マルチスレッド シナリオでバッチングを行う場合、任意の時点でバッチング ワークフローを実行するスレッドは 1 つだけにしてください。同時に 2 つのスレッドが同じ `client.batch` オブジェクトを使用することはできません。 + +## レスポンスオブジェクトの構造 + +各クエリのレスポンスオブジェクトには、通常複数の属性が含まれます。次のクエリを例に考えてみます。 + + + +各レスポンスには `objects` や `generated` などの属性が含まれます。さらに `objects` 内の各オブジェクトには、`uuid`、`vector`、`properties`、`references`、`metadata`、`generated` などの複数の属性が含まれます。 + + + +レスポンスのペイロードを制限するには、返却するプロパティやメタデータを指定できます。 + + + +## 入力引数のバリデーション + +クライアントライブラリはデフォルトで入力引数のバリデーションを実行し、入力の型が期待される型と一致していることを確認します。 + +パフォーマンスを向上させるために、このバリデーションを無効化することもできます。たとえば コレクション オブジェクトのインスタンス化時や `collections.get`、`collections.create` で `skip_argument_validation` パラメーターを `True` に設定します。 + + + +本番環境でクライアントライブラリを使用し、入力引数の型が確実に正しいと分かっている場合に便利です。 + +## Jupyter Notebook でのタブ補完 + +ブラウザで Jupyter Notebook 上の Python クライアントを実行している場合、編集中に `Tab` キーを押すとコード補完が利用できます。VSCode で Jupyter Notebook を実行している場合は、`control` + `space` を押してください。 + +## 生の GraphQL クエリ + +生の GraphQL クエリを送信するには、`client.graphql_raw_query` メソッドを使用します(`v3` クライアントでは以前 `client.query.raw` でした)。このメソッドは文字列を引数に取ります。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/python_v3.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/python_v3.md new file mode 100644 index 000000000..324dd7bc9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/python_v3.md @@ -0,0 +1,923 @@ +--- +title: "レガシー (v3) API (非推奨)" +sidebar_position: 80 +description: "レガシーアプリケーションの互換性維持のみを目的とした、非推奨の Python v3 クライアント向けドキュメントです。" +image: og/docs/client-libraries.jpg +# tags: ['python', 'client library'] +--- + +:::caution `v3` client is deprecated +このドキュメントはレガシーである `v3` クライアントおよび API に関するものです。 +
+ +`v4.10.0` 以降、[Weaviate Python クライアントのインストール](https://pypi.org/project/weaviate-client/)には `v3` API(つまり `weaviate.Client` クラス)が含まれません。これにより、開発者体験を最適化し、最新の Weaviate 機能をサポートできるようになりました。 +
+ +`v3` クライアントには、今後もしばらくの間は重大なセキュリティアップデートとバグ修正が提供されますが、新機能の追加は行われません。 +
+ +**これは何を意味するのでしょうか?** +
+ +最新の Weaviate Database の開発成果を利用するために、コードベースを [`v4` クライアント API](./index.mdx) へ移行することを推奨します。 +
+ +ドキュメントには[移行ガイド](./v3_v4_migration.md)があり、多くのコード例で `v3` と `v4` の構文を併記しています。今後も移行を容易にする専用リソースを追加していく予定です。 +
+ +既存のコードベースと Weaviate Database を当面変更しない予定の場合は、`requirements.txt` などの要件ファイルでバージョンを固定してください。例: + +```bash + weaviate-client>=3.26.7,<4.0.0 +``` + +コード移行は手間がかかることがありますが、最終的な体験と機能セットがその価値を十分に上回ると確信しています。 +
+ +移行ドキュメントやリソースに関する具体的な要望がございましたら、[GitHub リポジトリ](https://github.com/weaviate/docs/issues)までお気軽にお知らせください。 +::: + +## インストールとセットアップ + +### 要件 + +`v3` クライアントは、Weaviate `1.22` で導入された gRPC API とは併用できません。Weaviate `1.22` 以降でも `v3` クライアントを使用できますが、gRPC API による改善の恩恵は受けられません。gRPC API を利用する場合は `v4` クライアントをご使用ください。 + +### インストール + +`v3` Python ライブラリは [PyPI.org](https://pypi.org/project/weaviate-client/) で利用可能です。パッケージは [pip](https://pypi.org/project/pip/) を使用してインストールできます。クライアントは Python 3.7 以上で開発・テストされています。 + +```bash +pip install "weaviate-client==3.*" +``` + +### セットアップ + +Python スクリプト内では次のようにクライアントを使用できます。 + +```python +import weaviate + +client = weaviate.Client("https://WEAVIATE_INSTANCE_URL") # Replace WEAVIATE_INSTANCE_URL with your instance URL. + +assert client.is_ready() # Will return True if the client is connected & the server is ready to accept requests +``` + +あるいは、以下のような追加引数を指定することも可能です。 + +```python +import weaviate + +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # URL of your Weaviate instance + auth_client_secret=auth_config, # (Optional) If the Weaviate instance requires authentication + timeout_config=(5, 15), # (Optional) Set connection timeout & read timeout time in seconds + additional_headers={ # (Optional) Any additional headers; e.g. keys for API inference services + "X-Cohere-Api-Key": "YOUR-COHERE-API-KEY", # Replace with your Cohere key + "X-HuggingFace-Api-Key": "YOUR-HUGGINGFACE-API-KEY", # Replace with your Hugging Face key + "X-OpenAI-Api-Key": "YOUR-OPENAI-API-KEY", # Replace with your OpenAI key + } +) + +assert client.is_ready() # Will return True if the client is connected & the server is ready to accept requests +``` + +## 認証 + +import ClientAuthIntro from '/docs/weaviate/client-libraries/_components/client.auth.introduction.mdx' + + + +### WCD 認証 + +import ClientAuthWCD from '/docs/weaviate/client-libraries/_components/client.auth.wcs.mdx' + + + +### API キー認証 + +:::info Weaviate Python クライアント バージョン `3.14.0` で追加されました。 +::: + +import ClientAuthApiKey from '/docs/weaviate/client-libraries/_components/client.auth.api.key.mdx' + + + +```python +import weaviate + +auth_config = weaviate.auth.AuthApiKey(api_key="YOUR-WEAVIATE-API-KEY") # Replace with your Weaviate instance API key + +# Instantiate the client with the auth config +client = weaviate.Client( + url="https://WEAVIATE_INSTANCE_URL", # Replace with your Weaviate endpoint + auth_client_secret=auth_config +) +``` + +### OIDC 認証 + +import ClientAuthOIDCIntro from '/docs/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx' + + + +#### Resource Owner Password フロー + +import ClientAuthFlowResourceOwnerPassword from '/docs/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx' + + + +```python +import weaviate + +resource_owner_config = weaviate.AuthClientPassword( + username = "user", + password = "pass", + scope = "offline_access" # optional, depends on the configuration of your identity provider (not required with WCD) + ) + +# Initiate the client with the auth config +client = weaviate.Client("http://localhost:8080", auth_client_secret=resource_owner_config) +``` + +#### Client Credentials フロー + +import ClientAuthFlowClientCredentials from '/docs/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx' + + + +```python +import weaviate + +client_credentials_config = weaviate.AuthClientCredentials( + client_secret = "client_secret", + scope = "scope1 scope2" # optional, depends on the configuration of your identity provider (not required with WCD) + ) + +# Initiate the client with the auth config +client = weaviate.Client("https://localhost:8080", auth_client_secret=client_credentials_config) +``` + +#### Refresh Token フロー + +import ClientAuthBearerToken from '/docs/weaviate/client-libraries/_components/client.auth.bearer.token.mdx' + + + +```python +import weaviate + +bearer_config = weaviate.AuthBearerToken( + access_token="some token" + expires_in=300 # in seconds, by default 60s + refresh_token="other token" # Optional +) + +# Initiate the client with the auth config +client = weaviate.Client("https://localhost:8080", auth_client_secret=bearer_config) +``` + +## カスタムヘッダー + +クライアント初期化時にカスタムヘッダーを渡すことができます。 + +```python +client = weaviate.Client( + url="https://localhost:8080", + additional_headers={"HeaderKey": "HeaderValue"}, +) +``` + +## ニューラル検索フレームワーク + +Weaviate を基盤としてベクトルを保存・検索・取得する多様なニューラル検索フレームワークがあります。 + +- deepset の [haystack](https://www.deepset.ai/weaviate-vector-search-engine-integration) +- Jina の [DocArray](https://github.com/docarray/docarray) + + + +# 参照ドキュメント + +この Weaviate ドキュメントサイトでは、すべての RESTful エンドポイントおよび GraphQL 関数を Python クライアントで利用する方法をご覧いただけます。各リファレンスには、Python(およびその他)のクライアントでその関数を使用する例を示したコードブロックが含まれています。とはいえ、Python クライアントには追加機能もあり、これらは weaviate-python-client.readthedocs.io にある完全版クライアントドキュメントで説明されています。以下では、そのうちいくつかの機能を紹介します。 + +### 例: client.schema.create(schema) + +RESTful の `v1/schema` エンドポイントを使用してクラスを 1 つずつ追加する代わりに、Python クライアントを使って JSON 形式のスキーマ全体を一度にアップロードできます。次のように `client.schema.create(schema)` 関数を使用してください: + +```python +import weaviate + +client = weaviate.Client("http://localhost:8080") + +schema = { + "classes": [{ + "class": "Publication", + "description": "A publication with an online source", + "properties": [ + { + "dataType": [ + "text" + ], + "description": "Name of the publication", + "name": "name" + }, + { + "dataType": [ + "Article" + ], + "description": "The articles this publication has", + "name": "hasArticles" + }, + { + "dataType": [ + "geoCoordinates" + ], + "description": "Geo location of the HQ", + "name": "headquartersGeoLocation" + } + ] + }, { + "class": "Article", + "description": "A written text, for example a news article or blog post", + "properties": [ + { + "dataType": [ + "text" + ], + "description": "Title of the article", + "name": "title" + }, + { + "dataType": [ + "text" + ], + "description": "The content of the article", + "name": "content" + } + ] + }, { + "class": "Author", + "description": "The writer of an article", + "properties": [ + { + "dataType": [ + "text" + ], + "description": "Name of the author", + "name": "name" + }, + { + "dataType": [ + "Article" + ], + "description": "Articles this author wrote", + "name": "wroteArticles" + }, + { + "dataType": [ + "Publication" + ], + "description": "The publication this author writes for", + "name": "writesFor" + } + ] + }] +} + +client.schema.create(schema) +``` + +#### 例: Weaviate と Python クライアントの入門ブログポスト + +Weaviate の Python クライアントを使ったフル例は、[この Towards Data Science の記事](https://towardsdatascience.com/quickstart-with-weaviate-python-client-e85d14f19e4f)でご覧いただけます。 + +## バッチ処理 + +バッチ処理とは、単一の API リクエストで `objects` と `references` を一括でインポート/作成する方法です。Python では次の 3 つの方法を利用できます。 + +1. ***Auto-batching*** +2. ***Dynamic-batching*** +3. ***Manual-batching*** + +一般的には、コンテキストマネージャ内で `client.batch` を使用することを推奨します。コンテキストを抜ける際に自動でフラッシュされるため、最も簡単にバッチ機能を利用できます。 + +バッチインポート速度に最も影響する主なパラメーターは次のとおりです。 + +| Parameter | Type | 推奨
値 | 目的 | +| :- | :- | :- | :- | +| `batch_size` | integer | 50 - 200 | 初期バッチサイズ | +| `num_workers` | integer | 1 - 2 | 同時実行ワーカーの最大数 | +| `dynamic` | boolean | True | `batch_size` に基づきバッチサイズを動的に調整するか | + +### マルチスレッドバッチインポート + +:::info Weaviate Python クライアント バージョン `3.9.0` で追加されました。 +::: + +マルチスレッドバッチインポートは `Auto-batching` と `Dynamic-batching` の両方で動作します。 + +利用するには、`.configure(...)`(`.__call__(...)` と同じ)でバッチ設定の引数 `num_workers` にワーカー(スレッド)の数を指定します。詳しくは後述の [Batch configuration](#batch-configuration) をご覧ください。 + +:::warning +マルチスレッドはデフォルトでは無効(`num_workers=1`)です。ご利用の Weaviate インスタンスを過負荷にしないようご注意ください。 +::: + +**Example** + +```python +client.batch( # or client.batch.configure( + batch_size=100, + dynamic=True, + num_workers=4, +) +``` + +### Auto-batching + +この方法では、Python クライアントが `object` と `reference` のインポート/作成をすべて処理します。つまり、オブジェクトやクロスリファレンスを明示的に作成する必要はありません。インポート/作成したいものをすべて `Batch` に追加するだけで、`Batch` がオブジェクトとクロスリファレンスの作成を行います。Auto-batching を有効にするには、`batch_size` を正の整数(デフォルトは `None`)に設定します(詳細は [Batch configuration](#batch-configuration) を参照)。`Batch` は「オブジェクト数 + リファレンス数 == `batch_size`」になったタイミングで、オブジェクトを作成し、その後クロスリファレンスを作成します。例を以下に示します。 + +```python +import weaviate +from weaviate.util import generate_uuid5 +client = weaviate.Client("http://localhost:8080") + +# create schema +schema = { + "classes": [ + { + "class": "Author", + "properties": [ + { + "name": "name", + "dataType": ["text"] + }, + { + "name": "wroteBooks", + "dataType": ["Book"] + } + ] + }, + { + "class": "Book", + "properties": [ + { + "name": "title", + "dataType": ["text"] + }, + { + "name": "ofAuthor", + "dataType": ["Author"] + } + ] + } + ] +} + +client.schema.create(schema) + +author = { + "name": "Jane Doe", +} +book_1 = { + "title": "Jane's Book 1" +} +book_2 = { + "title": "Jane's Book 2" +} + +client.batch.configure( + batch_size=5, # int value for batch_size enables auto-batching, see Batch configuration section below +) + +with client.batch as batch: + # add author + uuid_author = generate_uuid5(author, "Author") + batch.add_data_object( + data_object=author, + class_name="Author", + uuid=uuid_author, + ) + # add book_1 + uuid_book_1 = generate_uuid5(book_1, "Book") + batch.add_data_object( + data_object=book_1, + class_name="Book", + uuid=uuid_book_1, + ) + # add references author ---> book_1 + batch.add_reference( + from_object_uuid=uuid_author, + from_object_class_name="Author", + from_property_name="wroteBooks", + to_object_uuid=uuid_book_1, + to_object_class_name="Book", + ) + # add references author <--- book_1 + batch.add_reference( + from_object_uuid=uuid_book_1, + from_object_class_name="Book", + from_property_name="ofAuthor", + to_object_uuid=uuid_author, + to_object_class_name="Author", + ) + # add book_2 + uuid_book_2 = generate_uuid5(book_2, "Book") + batch.add_data_object( + data_object=book_2, + class_name="Book", + uuid=uuid_book_2, + ) + # add references author ---> book_2 + batch.add_reference( + from_object_uuid=uuid_author, + from_object_class_name="Author", + from_property_name="wroteBooks", + to_object_uuid=uuid_book_2, + to_object_class_name="Book", + ) + # add references author <--- book_2 + batch.add_reference( + from_object_uuid=uuid_book_2, + from_object_class_name="Book", + from_property_name="ofAuthor", + to_object_uuid=uuid_author, + to_object_class_name="Author", + ) + +# NOTE: When exiting context manager the method `batch.flush()` is called +# done, everything is imported/created +``` + +### Dynamic-batching + +この方法も、Python クライアントがオブジェクトとクロスリファレンスのインポート/作成を動的に処理します([Auto-batching](#auto-batching) と同様、ユーザーが明示的に行う必要はありません)。Dynamic-batching を有効にするには、`batch_size` を正の整数(デフォルトは `None`)に設定し、さらに `dynamic` を `True`(デフォルトは `False`)にします(詳細は [Batch configuration](#batch-configuration) を参照)。この方法では、最初の `Batch` 作成後に `recommended_num_objects` と `recommended_num_references` が計算され、その初期値として `batch_size` が使用されます。`Batch` は現在のオブジェクト数が `recommended_num_objects` に達するか、リファレンス数が `recommended_num_references` に達した時点で、オブジェクトまたはリファレンスを作成します。例を以下に示します。 + +```python +import weaviate +from weaviate.util import generate_uuid5 +client = weaviate.Client("http://localhost:8080") + +# create schema +schema = { + "classes": [ + { + "class": "Author", + "properties": [ + { + "name": "name", + "dataType": ["text"] + }, + { + "name": "wroteBooks", + "dataType": ["Book"] + } + ] + }, + { + "class": "Book", + "properties": [ + { + "name": "title", + "dataType": ["text"] + }, + { + "name": "ofAuthor", + "dataType": ["Author"] + } + ] + } + ] +} + +client.schema.create(schema) + +author = { + "name": "Jane Doe", +} +book_1 = { + "title": "Jane's Book 1" +} +book_2 = { + "title": "Jane's Book 2" +} + +client.batch.configure( + batch_size=5, # int value for batch_size enables auto-batching, see Batch configuration section below + dynamic=True, # makes it dynamic +) + +with client.batch as batch: + # add author + uuid_author = generate_uuid5(author, "Author") + batch.add_data_object( + data_object=author, + class_name="Author", + uuid=uuid_author, + ) + # add book_1 + uuid_book_1 = generate_uuid5(book_1, "Book") + batch.add_data_object( + data_object=book_1, + class_name="Book", + uuid=uuid_book_1, + ) + # add references author ---> book_1 + batch.add_reference( + from_object_uuid=uuid_author, + from_object_class_name="Author", + from_property_name="wroteBooks", + to_object_uuid=uuid_book_1, + to_object_class_name="Book", + ) + # add references author <--- book_1 + batch.add_reference( + from_object_uuid=uuid_book_1, + from_object_class_name="Book", + from_property_name="ofAuthor", + to_object_uuid=uuid_author, + to_object_class_name="Author", + ) + # add book_2 + uuid_book_2 = generate_uuid5(book_2, "Book") + batch.add_data_object( + data_object=book_2, + class_name="Book", + uuid=uuid_book_2, + ) + # add references author ---> book_2 + batch.add_reference( + from_object_uuid=uuid_author, + from_object_class_name="Author", + from_property_name="wroteBooks", + to_object_uuid=uuid_book_2, + to_object_class_name="Book", + ) + # add references author <--- book_2 + batch.add_reference( + from_object_uuid=uuid_book_2, + from_object_class_name="Book", + from_property_name="ofAuthor", + to_object_uuid=uuid_author, + to_object_class_name="Author", + ) +# NOTE: When exiting context manager the method `batch.flush()` is called +# done, everything is imported/created +``` + +### Manual-batching + +この方法では、`Batch` の操作をすべてユーザーが制御します。つまり、`Batch` はインポート/作成を自動では行わず、全てユーザーに委ねます。例を以下に示します。 + +```python +import weaviate +from weaviate.util import generate_uuid5 +client = weaviate.Client("http://localhost:8080") + +# create schema +schema = { + "classes": [ + { + "class": "Author", + "properties": [ + { + "name": "name", + "dataType": ["text"] + }, + { + "name": "wroteBooks", + "dataType": ["Book"] + } + ] + }, + { + "class": "Book", + "properties": [ + { + "name": "title", + "dataType": ["text"] + }, + { + "name": "ofAuthor", + "dataType": ["Author"] + } + ] + } + ] +} + +client.schema.create(schema) + +author = { + "name": "Jane Doe", +} +book_1 = { + "title": "Jane's Book 1" +} +book_2 = { + "title": "Jane's Book 2" +} + +client.batch.configure( + batch_size=None, # None disable any automatic functionality +) + +with client.batch as batch: + # add author + uuid_author = generate_uuid5(author, "Author") + batch.add_data_object( + data_object=author, + class_name="Author", + uuid=uuid_author, + ) + # add book_1 + uuid_book_1 = generate_uuid5(book_1, "Book") + batch.add_data_object( + data_object=book_1, + class_name="Book", + uuid=uuid_book_1, + ) + result = batch.create_objects() # <----- implicit object creation + + # add references author ---> book_1 + batch.add_reference( + from_object_uuid=uuid_author, + from_object_class_name="Author", + from_property_name="wroteBooks", + to_object_uuid=uuid_book_1, + to_object_class_name="Book", + ) + # add references author <--- book_1 + batch.add_reference( + from_object_uuid=uuid_book_1, + from_object_class_name="Book", + from_property_name="ofAuthor", + to_object_uuid=uuid_author, + to_object_class_name="Author", + ) + result = batch.create_references() # <----- implicit reference creation + + + # add book_2 + uuid_book_2 = generate_uuid5(book_2, "Book") + batch.add_data_object( + data_object=book_2, + class_name="Book", + uuid=uuid_book_2, + ) + result = batch.create_objects() # <----- implicit object creation + + # add references author ---> book_2 + batch.add_reference( + from_object_uuid=uuid_author, + from_object_class_name="Author", + from_property_name="wroteBooks", + to_object_uuid=uuid_book_2, + to_object_class_name="Book", + ) + # add references author <--- book_2 + batch.add_reference( + from_object_uuid=uuid_book_2, + from_object_class_name="Book", + from_property_name="ofAuthor", + to_object_uuid=uuid_author, + to_object_class_name="Author", + ) + result = batch.create_references() # <----- implicit reference creation + +# NOTE: When exiting context manager the method `batch.flush()` is called +# done, everything is imported/created +``` + +### Batch configuration + +`Batch` オブジェクトは `batch.configure()` メソッド、または `batch()`(`__call__`)メソッドで設定できます。両者は同じ関数です。上記の例では `batch_size` と `dynamic` を設定しましたが、利用可能なパラメーターは以下のとおりです。 + +- `batch_size` - (`int` または `None`、デフォルト `None`): `int` を指定すると Auto/Dynamic-batching が有効になります。Auto-batching では「オブジェクト数 + リファレンス数 == `batch_size`」になるとオブジェクト → リファレンスの順で作成します(詳細は [Auto-batching](#auto-batching) を参照)。Dynamic-batching では初期値として `recommended_num_objects` と `recommended_num_references` に使用されます(詳細は [Dynamic-batching](#dynamic-batching) を参照)。`None` の場合は Manual-batching となり、自動作成は行われません。 +- `dynamic` - (`bool`, デフォルト `False`): Dynamic-batching の有効/無効を切り替えます。`batch_size` が `None` の場合は無効です。 +- `creation_time` - (`int` または `float`, デフォルト `10`): バッチのインポート/作成を行う時間間隔(秒)です。`recommended_num_objects` と `recommended_num_references` の計算に使用され、Dynamic-batching に影響します。 +- `callback` (Optional[Callable[[dict], None]], デフォルト `weaviate.util.check_batch_result`): `batch.create_objects()` と `batch.create_references()` の結果に対して呼び出されるコールバック関数です。Auto/Dynamic-batching におけるエラーハンドリングに使用されます。`batch_size` が `None` の場合は影響しません。 +- `timeout_retries` - (`int`, デフォルト `3`): `TimeoutError` になる前にバッチのインポート/作成を再試行する回数です。 +- `connection_error_retries` - (`int`, デフォルト `3`): `ConnectionError` になる前にバッチのインポート/作成を再試行する回数です。**注:** `weaviate-client 3.9.0` で追加されました。 +- `num_workers` - (`int`, デフォルト `1`): バッチインポートを並列化する最大スレッド数です。Manual-batching 以外(AUTO または DYNAMIC)のみで使用されます。***Weaviate インスタンスを過負荷にしないようご注意ください。*** **注:** `weaviate-client 3.9.0` で追加されました。 + +NOTE: このメソッドを呼び出すたびに、必要な設定をすべて指定してください。指定しない設定はデフォルト値に置き換えられます。 +```python +client.batch( + batch_size=100, + dynamic=False, + creation_time=5, + timeout_retries=3, + connection_error_retries=5, + callback=None, + num_workers=1, +) +``` + +### ヒント & コツ + +* コミット/作成前にバッチへ追加できるオブジェクト/リファレンスの数に制限はありません。ただし、バッチが大きすぎると TimeOut エラーが発生する場合があります。これは、Weaviate が指定された時間内にバッチ内のすべてのオブジェクトを処理・作成できなかったことを意味します(タイムアウト設定は [こちら](https://weaviate-python-client.readthedocs.io/en/latest/weaviate.html#weaviate.Client) や [こちら](https://weaviate-python-client.readthedocs.io/en/latest/weaviate.html#weaviate.Client.timeout_config) を参照)。タイムアウト設定を 60 秒以上にする場合は docker-compose.yml/Helm chart の変更が必要です。 +* Python クライアントの `batch` クラスは次の 3 通りの使い方ができます。 + * ケース 1: すべてユーザーが実行。ユーザーはオブジェクト/オブジェクト参照を追加し、任意のタイミングで作成します。データ型を作成するには `create_objects`、`create_references`、`flush` を使用します。この場合、Batch インスタンスの `batch_size` は `None` です(`configure` または `__call__` のドキュメントを参照)。コンテキストマネージャでも使用できます。 + * ケース 2: バッチが満杯になると自動作成。Batch インスタンスの `batch_size` を正の整数に設定します(`configure` または `__call__` を参照)。このとき `batch_size` は追加されたオブジェクトとリファレンスの合計に対応します。ユーザーによるバッチ作成は必須ではありませんが、行うことも可能です。要件を満たさない最後のバッチを作成するには `flush` を使用します。コンテキストマネージャでも使用できます。 + * ケース 3: ケース 2 と似ていますが、Dynamic-batching を使用します。すなわち、オブジェクトまたはリファレンスのいずれかが `recommended_num_objects` または `recommended_num_references` に達した時点で自動作成されます。設定方法は `configure` または `__call__` のドキュメントを参照してください。 + * **コンテキストマネージャ対応**: `with` 文と共に使用できます。コンテキストを抜ける際に `flush` を自動で呼び出します。`configure` または `__call__` と組み合わせて、上記の任意のケースに設定できます。 + +### エラー処理 + +`Batch` でオブジェクトを作成する方が、オブジェクト/リファレンスを個別に作成するより高速ですが、その分いくつかのバリデーションステップをスキップします。バリデーションをスキップすると、作成に失敗するオブジェクトや、追加に失敗するリファレンスが発生する場合があります。このとき `Batch` 自体は失敗しませんが、個々のオブジェクト/リファレンスが失敗する可能性があります。そのため、`batch.create_objects()` や `batch.create_references()` の戻り値をチェックし、すべてがエラーなくインポート/作成されたか確認することを推奨します。以下に、個々の `Batch` オブジェクト/リファレンスでエラーを検出・処理する方法を示します。 + +まず、エラーをチェックして出力する関数を定義します。 +```python +def check_batch_result(results: dict): + """ + Check batch results for errors. + + Parameters + ---------- + results : dict + The Weaviate batch creation return value. + """ + + if results is not None: + for result in results: + if "result" in result and "errors" in result["result"]: + if "error" in result["result"]["errors"]: + print(result["result"]) +``` + +次に、この関数を使用してアイテム(オブジェクト/リファレンス)レベルのエラーメッセージを出力します。Auto/Dynamic-batching を用い、`create` メソッドを暗黙的に呼び出さない場合の例を示します。 + +```python +client.batch( + batch_size=100, + dynamic=True, + creation_time=5, + timeout_retries=3, + connection_error_retries=3, + callback=check_batch_result, +) + +# done, easy as that +``` + +Manual-batching では、戻り値に対してこの関数を呼び出せます。 +```python +# on objects +result = client.batch.create_object() +check_batch_result(result) + +# on references +result = client.batch.create_references() +check_batch_result(result) +``` + + +
+ 例コード + +以下の Python コードは、バッチ内の個々のデータオブジェクトでエラーを処理する方法を示しています。 + +```python +import weaviate + +client = weaviate.Client("http://localhost:8080") + +def check_batch_result(results: dict): + """ + Check batch results for errors. + + Parameters + ---------- + results : dict + The Weaviate batch creation return value, i.e. returned value of the client.batch.create_objects(). + """ + if results is not None: + for result in results: + if 'result' in result and 'errors' in result['result']: + if 'error' in result['result']['errors']: + print("We got an error!", result) + +object_to_add = { + "name": "Jane Doe", + "writesFor": [{ + "beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80" + }] +} + +client.batch.configure( + # `batch_size` takes an `int` value to enable auto-batching + # (`None` is used for manual batching) + batch_size=100, + # dynamically update the `batch_size` based on import speed + dynamic=False, + # `timeout_retries` takes an `int` value to retry on time outs + timeout_retries=3, + # checks for batch-item creation errors + # this is the default in weaviate-client >= 3.6.0 + callback=check_batch_result, + consistency_level=weaviate.data.replication.ConsistencyLevel.ALL, # default QUORUM +) + +with client.batch as batch: + batch.add_data_object(object_to_add, "Author", "36ddd591-2dee-4e7e-a3cc-eb86d30a4303", vector=[1,2]) + # lets force an error, adding a second object with unmatching vector dimensions + batch.add_data_object(object_to_add, "Author", "cb7d0da4-ceaa-42d0-a483-282f545deed7", vector=[1,2,3]) +``` + +同じ方法はリファレンスの追加にも適用できます。特にリファレンスをバッチで送信する場合、オブジェクトやリファレンスレベルのバリデーションが一部スキップされます。上記のように単一データオブジェクトで検証を行うことで、エラーが見逃される可能性を低減できます。 + +
+ + +## 設計 + +### GraphQL クエリビルダー パターン + +複雑な GraphQL クエリ(例: フィルターを使用する場合)を扱う際、クライアントではビルダー パターンを使用してクエリを組み立てます。以下は、複数のフィルターを持つクエリの例です: + +```python +import weaviate +client = weaviate.Client("http://localhost:8080") + +where_filter = { + "path": ["wordCount"], + "operator": "GreaterThan", + "valueInt": 1000 +} + +near_text_filter = { + "concepts": ["fashion"], + "certainty": 0.7, + "moveAwayFrom": { + "concepts": ["finance"], + "force": 0.45 + }, + "moveTo": { + "concepts": ["haute couture"], + "force": 0.85 + } +} + +query_result = client.query\ + .get("Article", ["title"])\ + .with_where(where_filter)\ + .with_near_text(near_text_filter)\ + .with_limit(50)\ + .do() + +print(query_result) +``` + +クエリを実行するには `.do()` メソッドを使用する必要がある点にご注意ください。 + +:::tip +`.build()` を使用すると、生成される GraphQL クエリ を確認できます +::: + +```python +query_result = client.query\ + .get("Article", ["title"])\ + .with_where(where_filter)\ + .with_near_text(near_text_filter)\ + .with_limit(50) + +query_result.build() + +>>> '{Get{Article(where: {path: ["wordCount"] operator: GreaterThan valueInt: 1000} limit: 50 nearText: {concepts: ["fashion"] certainty: 0.7 moveTo: {force: 0.85 concepts: ["haute couture"]} moveAwayFrom: {force: 0.45 concepts: ["finance"]}} ){title}}}' + +``` + +## ベストプラクティスと注意事項 + +### スレッド セーフティ + +Python クライアントは基本的にスレッド セーフになるよう設計されていますが、`requests` ライブラリに依存しているため、完全なスレッド セーフティは保証されません。 + +この点については将来的に改善を検討しています。 + +:::warning Thread safety +クライアントのバッチ処理アルゴリズムはスレッド セーフではありません。Python クライアントをマルチスレッド環境で使用する際は、この点を念頭に置き、よりスムーズで予測しやすい動作を確保してください。 +::: + +マルチスレッド環境でバッチ処理を行う場合は、任意の時点でバッチ ワークフローを実行するスレッドが 1 つだけになるようにしてください。複数のスレッドが同じ `client.batch` オブジェクトを同時に使用することはできません。 + +## リリース + +[GitHub のリリース ページ](https://github.com/weaviate/weaviate-python-client/releases) にアクセスすると、Python クライアント ライブラリのリリース履歴を確認できます。 + +
+ Weaviate と対応するクライアント バージョンの一覧を表示するにはここをクリック + +import ReleaseHistory from '/_includes/release-history.md'; + + + +
+ +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/v3_v4_migration.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/v3_v4_migration.md new file mode 100644 index 000000000..9ff55ce9a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/python/v3_v4_migration.md @@ -0,0 +1,279 @@ +--- +title: v3 から v4 への移行 +sidebar_position: 50 +description: "非推奨の v3 から現行の v4 クライアント ライブラリーへ Python アプリケーションをアップグレードするための移行ガイド。" +image: og/docs/client-libraries.jpg +# tags: ['python', 'client library'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PythonCode from '!!raw-loader!/_includes/code/client-libraries/python_v4.py'; + +:::note Python client version +現在の Python クライアント バージョンは `v||site.python_client_version||` です +::: + +` v4 ` の Weaviate Python クライアント API はユーザー エクスペリエンスを向上させるために全面的に書き直されました。そのため、` v3 ` API とは大きく異なり、Weaviate とのやり取り方法を学び直す必要があります。 + +多少のオーバーヘッドが発生するかもしれませんが、` v4 ` API は開発者エクスペリエンスを大きく向上させると考えています。たとえば、` v4 ` クライアントを使用すると gRPC API を介した高速化をフルに活用でき、強い型付けによる IDE の静的解析支援も受けられます。 + +API の変更範囲が広いため、このガイドではすべての変更点を網羅していません。ここでは主要な変更点と、コードをどのように高いレベルで移行するかを説明します。 + +コード例については、[こちらの推奨セクション](#how-to-migrate-your-code) からサイト全体のドキュメントを参照してください。 + +## インストール + +` v3 ` から ` v4 ` へ移行するには、以下を行います。 + +1. クライアント ライブラリーをアップグレードします。 + + ```bash + pip install -U weaviate-client + ``` + +2. 互換性のあるバージョンの Weaviate にアップグレードします。各マイナー Python クライアント バージョンは、対応するマイナー Weaviate バージョンと密接に結び付いています。 + - 例として、Weaviate ` v1.27.x ` は Python クライアント ` v4.9.x ` と共に開発されました。 + - 一般的には、Weaviate とクライアントの最新バージョンを使用することを推奨します。バージョン互換性マトリクスは [リリース ノート](../../release-notes/index.md#weaviate-database-and-client-releases) で確認できます。 + +3. Weaviate に対して gRPC 用のポートが開いていることを確認します。 + - デフォルト ポートは 50051 です。 + +
+ docker-compose.yml の例 + + Docker で Weaviate を実行している場合、` 50051 ` のデフォルト ポートをマッピングするには、`docker-compose.yml` ファイルに次を追加します。 + + ```yaml + ports: + - 8080:8080 + - 50051:50051 + ``` + +
+ +## クライアントのインスタンス化 + +` v4 ` クライアントは `WeaviateClient` オブジェクトによってインスタンス化されます。`WeaviateClient` オブジェクトはすべての API 操作へのメイン エントリ ポイントです。 + +`WeaviateClient` オブジェクトを直接インスタンス化することもできますが、ほとんどの場合は `connect_to_local` や `connect_to_weaviate_cloud` などの接続ヘルパー関数を使用する方が簡単です。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 主な変更点 + +` v4 ` クライアント API は ` v3 ` API とは大きく異なります。` v4 ` クライアントの主なユーザー向け変更点は次のとおりです。 + +- ヘルパー クラスの大幅な活用 +- コレクションとのやり取り +- ビルダー パターンの廃止 + +### ヘルパー クラス + +` v4 ` クライアントはヘルパー クラスを広範に利用します。これらのクラスは強い型付けを提供し、静的型チェックを可能にします。また、IDE の自動補完機能を通じてコーディングを容易にします。 + +コーディング中はオートコンプリートを頻繁に確認してください。API の変更点やクライアント オプションに関する有用なガイダンスが得られます。 + +import QuickStartCode from '!!raw-loader!/_includes/code/graphql.filters.nearText.generic.py'; + + + + + + + + + + + + + + +`wvc` 名前空間は、` v4 ` API でよく使用されるクラスを公開しています。この名前空間は主な用途に基づいてさらにサブモジュールに分かれています。 + + + + + +### コレクションの操作 + +Weaviate Database に接続すると、v4 API では `WeaviateClient` オブジェクトが、v3 API では `Client` オブジェクトが返されます。 + +`v3` API の操作は `client` オブジェクト(`Client` のインスタンス)を中心に設計されており、CRUD や検索などのサーバー操作をここから実行していました。 + +`v4` API では、Weaviate とのやり取りを開始する入口が別のパラダイムに変わっています。 + +サーバーレベルの操作(例: `client.is_ready()` でのレディネス確認や `client.cluster.nodes()` でのノード状況取得)は引き続き `client`(`WeaviateClient` のインスタンス)で行います。 + +CRUD と検索操作は、対象となる特定のコレクションを反映するために `Collection` オブジェクトに対して実行します。 + +以下の例は、`Collection` 型ヒントを持つ関数を示しています。 + + + +コレクションオブジェクトは自分自身の名前を属性として保持しています。そのため、`near_text` クエリなどの操作を行う際にコレクション名を指定する必要がありません。v4 のコレクションオブジェクトは、v3 のクライアントオブジェクトで利用できた幅広い操作と比べて、よりフォーカスされた名前空間を持っています。これによりコードが簡潔になり、エラーの可能性が減少します。 + +import ManageDataCode from '!!raw-loader!/_includes/code/howto/manage-data.read.py'; +import ManageDataCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.read-v3.py'; + + + + + + + + + + + +### 用語の変更(例: class → collection) + +Weaviate エコシステム内のいくつかの用語が変更され、それに合わせてクライアントも更新されました。 + +- Weaviate の「Class」は「Collection」と呼ばれるようになりました。コレクションはデータオブジェクトとそのベクトル埋め込みをまとめて格納します。 +- 「Schema」は「Collection Configuration」と呼ばれるようになり、コレクション名、ベクトライザー、インデックス設定、プロパティ定義などを含む設定の集合です。 + +アーキテクチャおよび用語の変更に伴い、API の大部分が変更されました。Weaviate とのやり取り方法に違いがあると考えてください。 + +たとえば、`client.collections.list_all()` は `client.schema.get()` の置き換えです。 + +[コレクションの管理](../../manage-collections/index.mdx) には、コレクションを扱うための詳細と追加サンプルコードがあります。各種クエリやフィルターについては [検索](../../search/index.mdx) を参照してください。 + +### JSON からのコレクション作成 + +JSON 定義からコレクションを作成することは引き続き可能です。既存データを移行する際などに便利でしょう。たとえば、[既存の定義を取得](../../manage-collections/collection-operations.mdx#read-a-single-collection-definition) し、それを用いて新しいコレクションを作成できます。 + + + +### ビルダーパターンの廃止 + +クエリを構築するビルダーパターンは削除されました。ビルダーパターンは混乱を招きやすく、静的解析では検出できない実行時エラーが発生しがちでした。 + +代わりに、`v4` API では特定のメソッドとそのパラメーターを使ってクエリを構築します。 + +import SearchSimilarityCode from '!!raw-loader!/_includes/code/howto/search.similarity.py'; +import SearchSimilarityCodeV3 from '!!raw-loader!/_includes/code/howto/search.similarity-v3.py'; + + + + + + + + + + + +さらに、多くの引数は `MetadataQuery` や `Filter` などのヘルパークラスを用いて構築されるようになり、IDE の支援や静的解析によって利用が容易になり、エラーも減少します。 + +## コード移行の方法 + +移行ではコードベースに大幅な変更が必要になる可能性があります。まずは [Python クライアントライブラリのドキュメント](./index.mdx) を確認し、インスタンス化の詳細や各サブモジュールを把握してください。 + +その後、[コレクション管理](../../manage-collections/index.mdx) や [クエリ](../../search/index.mdx) のハウツーガイドを参照してください。 + +特に次のページをご覧ください。 + +- [コレクションの管理](../../manage-collections/index.mdx) +- [バッチインポート](../../manage-objects/import.mdx) +- [クロスリファレンス](../../manage-collections/cross-references.mdx) +- [基本検索](../../search/basics.md) +- [類似検索](../../search/similarity.md) +- [フィルター](../../search/filters.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/index.mdx new file mode 100644 index 000000000..7f90c98bc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/index.mdx @@ -0,0 +1,165 @@ +--- +title: JavaScript と TypeScript +sidebar_position: 10 +description: Web アプリケーションに Weaviate を統合するための公式 TypeScript/JavaScript クライアントライブラリのドキュメント。 +image: og/docs/client-libraries.jpg +# tags: ['TypeScript', 'client library'] +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import QuickLinks from "/src/components/QuickLinks"; +import TSv3Code from "!!raw-loader!/_includes/code/client-libraries/get-started.ts"; + +export const typescriptCardsData = [ + { + title: "weaviate/typescript-client", + link: "https://github.com/weaviate/typescript-client", + icon: "fa-brands fa-github", + }, + { + title: "Reference manual", + link: "https://weaviate.github.io/typescript-client/index.html", + icon: "fa-solid fa-book", + }, +]; + +:::note JavaScript/TypeScript クライアント (SDK) + +最新の TypeScript クライアントのバージョンは `v||site.typescript_client_version||` です。 + + + +::: + +import TSClientIntro from "/_includes/clients/ts-client-intro.mdx"; + + + +## インストール + +このセクションでは、v3 TypeScript クライアントのインストールと設定方法を説明します。 + +#### パッケージのインストール + +v3 クライアントパッケージの名前は `weaviate-client` に変わりました。TypeScript クライアントライブラリは [npm](https://www.npmjs.com/) を使用してインストールします。 + +```bash +npm install weaviate-client +``` + +#### クライアントのインポート + +v3 クライアントは `ES Modules` を使用します。ドキュメントにあるサンプルコードのほとんども `ES Module` 形式を採用しています。 + +コードが `CommonJS` 互換を必要とする場合は、`CommonJS` のインポート方法を使用してください。 + + + + +```ts +import weaviate from "weaviate-client"; +``` + + + + +```ts +const weaviate = require("weaviate-client").default; +``` + + + + +#### TypeScript のセットアップ + +以下の変更をプロジェクトの設定ファイルに加えてください: + +- `package.json` に `"type": "module"` を追加します +- [`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) に次のコードを追加します + +
+ tsconfig.json ファイル + +```json +{ + "compilerOptions": { + "target": "ESNext", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "esModuleInterop": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "strict": true + }, + "include": ["src/index.ts"] // this compiles only src/.index.ts, to compile all .ts files, use ["*.ts"] +} +``` + +
+ +## はじめに + +import BasicPrereqs from "/_includes/prerequisites-quickstart.md"; + + + +次のコードは以下を示します: + +1. ローカルの Weaviate インスタンスへ接続する。 +1. 新しいコレクションを作成する。 +1. バッチインポートでデータベースにデータを投入し、データをベクトル化する。 +1. ベクトル検索を実行する。 + + + +## 非同期処理の利用 + +v3 クライアントのメソッドは `collection.use()` を除き、すべて ES6 の Promise を使用する非同期コードです。そのため、関数呼び出しの後に `.then()` を使用するか、コード全体を `async/await` ブロックでラップする必要があります。 + +非同期コードでエラーが発生した場合、Promise は該当するエラーメッセージを返します。`async`/`await` を使用している場合、拒否された Promise はスローされた例外として扱われます。 + +## リリース + +[GitHub のリリースページ](https://github.com/weaviate/typescript-client/releases) で、TypeScript クライアントライブラリのリリース履歴と変更ログを確認できます。 + +
+ Weaviate と対応するクライアントバージョンの一覧はこちらをクリック + +import ReleaseHistory from "/_includes/release-history.md"; + + + +
+ + + +#### ベクトライザー API の変更点 `v3.8.0` + +Weaviate JS/TS クライアント `v3.8.0` から、コレクションを作成する際のベクトライザー設定 API に複数の変更が加えられました: +- `configure.vectorizer` は `configure.vectors` に置き換えられました +- ユーザーが [マルチ ベクトル](../../manage-collections/vector-config.mdx#define-multi-vector-embeddings-eg-colbert-colpali) を扱えるよう、`configure.multiVectors` が追加されました +- `configure.vectorizer.none` は `configure.vectors.selfProvided` に置き換えられました + +#### `v2` から `v3` への移行 + +Weaviate TypeScript クライアント v2 から v3 へプロジェクトを移行する場合は、詳細について [移行ページ](/weaviate/client-libraries/typescript/v2_v3_migration) をご覧ください。 + +## コード例と追加リソース + +import CodeExamples from "/_includes/clients/code-examples.mdx"; + + + +## ご質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/notes-best-practices.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/notes-best-practices.mdx new file mode 100644 index 000000000..c95e2426f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/notes-best-practices.mdx @@ -0,0 +1,206 @@ +--- +title: 注意事項とベストプラクティス +sidebar_position: 2 +description: TypeScript クライアント最適化ガイドラインと Web 開発向け推奨実装パターン。 +image: og/docs/client-libraries.jpg +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PythonCode from "!!raw-loader!/_includes/code/client-libraries/python_v4.py"; +import BatchVectorCode from "!!raw-loader!/_includes/code/howto/manage-data.import.py"; + +## クライアントのインスタンス化 + +v3 クライアントは、アプリケーションを Weaviate インスタンスに接続するためのヘルパー関数を提供します。 + +v3 クライアントは [Embedded Weaviate](/deploy/installation-guides/embedded) をサポートしていません。 +v2 クライアントは Embedded Weaviate をサポートしています。 + +### Weaviate への接続 + + + + +```ts +import weaviate from "weaviate-client"; + +const client = await weaviate.connectToWeaviateCloud("WEAVIATE_INSTANCE_URL", { + // Replace WEAVIATE_INSTANCE_URL with your instance URL + authCredentials: new weaviate.ApiKey("WEAVIATE_INSTANCE_API_KEY"), + headers: { + "X-OpenAI-Api-Key": process.env.OPENAI_API_KEY || "", // Replace with your inference API key + }, +}); + +console.log(client); +``` + + + + +```ts +import weaviate from "weaviate-client"; + +const client = await weaviate.connectToLocal(); + +console.log(client); +``` + + + + +```ts +import weaviate from "weaviate-client"; + +const client = await weaviate.connectToCustom({ + httpHost: "localhost", + httpPort: 8080, + grpcHost: "localhost", + grpcPort: 50051, + grpcSecure: true, + httpSecure: true, + authCredentials: new weaviate.ApiKey("WEAVIATE_INSTANCE_API_KEY"), + headers: { + "X-Cohere-Api-Key": process.env.COHERE_API_KEY || "", // Replace with your inference API key + }, +}); + +console.log(client); +``` + + + + +### クライアントのクローズ メソッド + +import TSClientClose from "/_includes/clients/ts-client-close.mdx"; + + + +### 認証 + +import ClientAuthApiKey from "/docs/weaviate/client-libraries/_components/client.auth.api.key.mdx"; + + + +```ts +import weaviate, { WeaviateClient } from "weaviate-client"; + +// Instantiate the client with the auth config +const client: WeaviateClient = await weaviate.connectToWeaviateCloud( + "WEAVIATE_INSTANCE_URL", // Replace WEAVIATE_INSTANCE_URL with your instance URL + { + authCredentials: new weaviate.ApiKey("WEAVIATE_INSTANCE_API_KEY"), // Add your WCD API KEY here + } +); + +console.log(client); +``` + +サードパーティーサービスの API キーなど、カスタムヘッダーを含める場合は、クライアントを初期化するときに `headers` セクションへ追加します。 + +```ts +import weaviate, { WeaviateClient } from "weaviate-client"; + +const client: WeaviateClient = await weaviate.connectToWeaviateCloud( + "WEAVIATE_INSTANCE_URL", // Replace WEAVIATE_INSTANCE_URL with your instance URL + { + authCredentials: new weaviate.ApiKey("WEAVIATE_INSTANCE_API_KEY"), // Add your WCD API KEY here + headers: { + someHeaderName: "header-value", + }, + } +); +``` + +クライアントは Weaviate インスタンスへリクエストを送るたびに、これらのヘッダーを送信します。 + +### 初期接続チェック + +Weaviate サーバーへ接続を確立する際、クライアントは一連のチェックを行います。これにはサーバーバージョンの確認や、REST ポートと gRPC ポートが利用可能かどうかの確認が含まれます。 + +これらのチェックをスキップするには、`skipInitChecks` を `true` に設定します。 + +```js +import weaviate from 'weaviate-client'; +Add commentMore actions +const client = await weaviate.connectToLocal({ + skipInitChecks: true, +}) +``` + +ほとんどの場合、`skipInitChecks` はデフォルトの `false` のままにすることを推奨します。ただし接続の問題がある場合、一時的に `skipInitChecks: true` を設定すると役立つことがあります。 + +追加の接続設定については、[タイムアウト値](#タイムアウト値) をご覧ください。 + +## ジェネリクス + +TypeScript ユーザーはカスタム ジェネリクスを定義できます。ジェネリクスを使用すると、オブジェクトやそのプロパティを扱いやすくなります。コンパイル時の型チェックにより、`insert()` や `create()` などの操作が安全かつエラーなく行えるようになります。 + +```js +import weaviate from "weaviate-client"; + +type Article = { + title: string, + body: string, + wordcount: number, +}; + +const collection = client.collections.get < Article > "Article"; +await collection.data.insert({ + // compiler error since 'body' field is missing in '.insert' + title: "TS is awesome!", + wordcount: 9001, +}); +``` + +## イテレーター メソッド + +カーソル API に新しいイテレーター メソッドが追加されました。コレクション全体に対して同じ処理を繰り返す場合は `iterator()` を使用します。 + +```js +const articles = client.collections.use("Article"); + +for await (const article of articles.iterator()) { + // do something with article. + console.log(article); // we print each object in the collection +} +``` + +## 型安全性 + +v3 クライアントでは、カスタム TypeScript 型とユーザー定義ジェネリクスにより、強力な型付けが可能です。 + +型定義は Weaviate クライアントパッケージを格納しているフォルダー内にあります。パッケージは `node/` ディレクトリ配下のフォルダーに格納され、各バンドルごとにサブフォルダー内へカスタム型定義が配置されています。 + +たとえば、`index.d.ts` ファイルには `cjs` バンドル用の型定義が含まれています。 + +```bash +node/cjs/index.d.ts +``` + +v3 クライアントは、JavaScript 開発をより型安全にする内部機能も追加しています。 + +### タイムアウト値 + +クライアントに対して秒単位のタイムアウト値を設定できます。`timeout` プロパティを使用して、初期化チェック、クエリ、および挿入操作のタイムアウトを設定します。 + +```js +import weaviate from 'weaviate-client'; + +const client = await weaviate.connectToLocal({ + timeout: { + query: 20, + insert: 120, + init: 10, + } +}) +``` +:::tip `generate` クエリのタイムアウト + +`generate` サブモジュールを使用中にエラーが発生する場合は、クエリのタイムアウト値(`query: 60` など)を増やしてみてください。

`generate` サブモジュールは、大規模言語モデルを用いてテキストを生成します。このサブモジュールは、言語モデルおよびそれを提供する API の速度に依存します。

タイムアウト値を増やすことで、クライアントが言語モデルからの応答をより長く待機できるようになります。 +::: + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/typescript-v2.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/typescript-v2.mdx new file mode 100644 index 000000000..25909c583 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/typescript-v2.mdx @@ -0,0 +1,440 @@ +--- +title: JS/TS クライアント v2 +sidebar_position: 20 +description: "既存のアプリケーションの保守および互換性のためのレガシー TypeScript クライアント v2 のドキュメント." +image: og/docs/client-libraries.jpg +# tags: ['TypeScript', 'client library'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +:::note TypeScript client version +TypeScript クライアントのバージョンは `v||site.typescript_client_version||` です。新しいプロジェクトでは [TypeScript v3 クライアント](./index.mdx) をご利用ください。 +::: + +TypeScript クライアントは、 JavaScript および TypeScript のスクリプトの両方で使用できます。 + +## インストールとセットアップ + +TypeScript クライアントライブラリをインストールするには、 [npm](https://www.npmjs.com/) を使用します。 + +```bash +npm install weaviate-ts-client +``` + +## 使い方と型定義 + +インストール後、以下の例のように TypeScript と JavaScript のスクリプトでクライアントを使用できます。 + +### 使い方 + + + + +```js +const { default: weaviate } = require('weaviate-ts-client'); + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your Weaviate endpoint +}); + +client + .schema + .getter() + .do() + .then(res => { + console.log(res); + }) + .catch(err => { + console.error(err) + }); +``` + + + + +```ts +import weaviate from 'weaviate-ts-client'; + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your Weaviate endpoint +}); + +const response = await client + .schema + .getter() + .do(); +console.log(response); +``` + + + + +:::tip Troubleshooting imports with TypeScript +TypeScript で import 文に問題がある場合 (例: `weaviate` が `undefined` になるなど)、 `tsconfig.json` の `"compilerOptions"` に `"esModuleInterop": true` を追加してみてください。 +::: + +### 型定義 + +型定義はパッケージの `types` サブディレクトリにある `*.d.ts` ファイルに含まれています。例としては [npm パッケージページ](https://www.npmjs.com/package/weaviate-ts-client?activeTab=code) をご参照ください。 + +## 認証 + +import ClientAuthIntro from '/docs/weaviate/client-libraries/_components/client.auth.introduction.mdx' + + + + +### API キー認証 + +import ClientAuthApiKey from '/docs/weaviate/client-libraries/_components/client.auth.api.key.mdx' + + + + + + +```js +const { default: weaviate } = require('weaviate-ts-client'); + +// Instantiate the client with the auth config +const client = weaviate.client({ + scheme: 'https', + host: 'edu-demo.weaviate.network', // Replace with your Weaviate endpoint + apiKey: new weaviate.ApiKey('learn-weaviate'), // Replace with your Weaviate instance API key +}); +``` + + + + +```ts +import weaviate, { WeaviateClient, ApiKey } from 'weaviate-ts-client'; + +// Instantiate the client with the auth config +const client: WeaviateClient = weaviate.client({ + scheme: 'https', + host: 'edu-demo.weaviate.network', // Replace with your Weaviate endpoint + apiKey: new ApiKey('learn-weaviate'), // Replace with your Weaviate instance API key +}); +``` + + + + +### OIDC 認証 + +import ClientAuthOIDCIntro from '/docs/weaviate/client-libraries/_components/client.auth.oidc.introduction.mdx' + + + +:::info Background refresh processes with TS +TypeScript クライアントで OIDC を使用する場合、バックグラウンドでのトークンリフレッシュ処理がスクリプトの終了をブロックすることがあります。不要な場合は、次のいずれかをお試しください。 +1. OIDC 設定で `silentRefresh` パラメーターを `false` に設定する。 +1. スクリプトが終了するタイミングやトークンリフレッシュが不要になったタイミングで `client.oidcAuth?.stopTokenRefresh()` を実行してプロセスを停止する。 +::: + +#### Resource Owner Password フロー + +import ClientAuthFlowResourceOwnerPassword from '/docs/weaviate/client-libraries/_components/client.auth.flow.resource.owner.password.mdx' + + + + + + +```js +const { default: weaviate } = require('weaviate-ts-client'); + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + authClientSecret: new weaviate.AuthUserPasswordCredentials({ + username: 'user123', + password: 'password', + silentRefresh: true, // Default: true - if false, you must refresh the token manually; if true, this background process will prevent a script from exiting. + scopes: ['offline_access'] // optional, depends on the configuration of your identity provider (not required with WCD) + }) +}); +``` + + + + +```ts +import weaviate, { WeaviateClient, AuthUserPasswordCredentials } from 'weaviate-ts-client'; + +const client: WeaviateClient = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + authClientSecret: new AuthUserPasswordCredentials({ + username: 'user123', + password: 'password', + silentRefresh: true, // Default: true - if false, you must refresh the token manually; if true, this background process will prevent a script from exiting. + scopes: ['offline_access'] // optional, depends on the configuration of your identity provider (not required with WCD) + }) +}); +``` + + + + +#### Client Credentials フロー + +import ClientAuthFlowClientCredentials from '/docs/weaviate/client-libraries/_components/client.auth.flow.client.credentials.mdx' + + + + + + +```js +const { default: weaviate } = require('weaviate-ts-client'); + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + authClientSecret: new weaviate.AuthClientCredentials({ + clientSecret: 'supersecuresecret', + silentRefresh: true, // Default: true - if false, you must refresh the token manually; if true, this background process will prevent a script from exiting. + scopes: ['scope1', 'scope2'] // optional, depends on the configuration of your identity provider + }) +}); +``` + + + + +```ts +import weaviate, { WeaviateClient, AuthClientCredentials } from 'weaviate-ts-client'; + +const client: WeaviateClient = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + authClientSecret: new AuthClientCredentials({ + clientSecret: 'supersecuresecret', + silentRefresh: true, // Default: true - if false, you must refresh the token manually; if true, this background process will prevent a script from exiting. + scopes: ['scope1', 'scope2'] // optional, depends on the configuration of your identity provider + }) +}); +``` + + + + + +#### リフレッシュトークンフロー + +import ClientAuthBearerToken from '/docs/weaviate/client-libraries/_components/client.auth.bearer.token.mdx' + + + + + + +```js +const { default: weaviate } = require('weaviate-ts-client'); + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + authClientSecret: new weaviate.AuthAccessTokenCredentials({ + accessToken: 'abcd1234', + expiresIn: 900, + refreshToken: 'efgh5678', + silentRefresh: true, // Default: true - if false, you must refresh the token manually; if true, this background process will prevent a script from exiting. + }) +}); +``` + + + + +```ts +import weaviate, { WeaviateClient, AuthAccessTokenCredentials } from 'weaviate-ts-client'; + +const client: WeaviateClient = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + authClientSecret: new AuthAccessTokenCredentials({ + accessToken: 'abcd1234', + expiresIn: 900, + refreshToken: 'efgh5678', + silentRefresh: true, // Default: true - if false, you must refresh the token manually; if true, this background process will prevent a script from exiting. + }) +}); +``` + + + + +## カスタムヘッダー + +クライアントにはカスタムヘッダーを渡すことができ、初期化時に追加されます。 + + + + +```js +const { default: weaviate } = require('weaviate-ts-client'); + +const client = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + headers: { headerName: 'HeaderValue' } +}); +``` + + + + +```ts +import weaviate, { WeaviateClient } from 'weaviate-ts-client'; + +const client: WeaviateClient = weaviate.client({ + scheme: 'https', + host: 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + headers: { headerName: 'HeaderValue' } +}); +``` + + + + +これらのヘッダーは、クライアントが行うすべてのリクエストに含まれます。 + +## 参照 + +:::note JS to TS migration +一部の古いコード例は JavaScript で書かれており、まだ更新されていません。新しいコード例は TypeScript を使用しています。 +::: + +TypeScript クライアントで扱われる [RESTful エンドポイント](/weaviate/api/rest) と [GraphQL 機能](/weaviate/api) のコードブロックは、現在 JavaScript の例が掲載されています。 + +## 設計 + +### ビルダーパターン + +TypeScript クライアントは [Builder パターン](https://en.wikipedia.org/wiki/Builder_pattern) に従って設計されています。このパターンは複雑なクエリオブジェクトを構築するために使用されます。つまり、(RESTful の GET リクエストでデータを取得したり、より複雑な GraphQL クエリを実行したりする際に)呼び出しをチェーンさせることで複雑さを軽減します。ビルダーオブジェクトには任意のものと、特定の機能を実行するために必須のものがあります。ビルダーの例は [RESTful API リファレンス](/weaviate/api/rest) と [GraphQL リファレンス](/weaviate/api) に掲載されています。 + +このページ冒頭のコードスニペットは、RESTful リクエスト `GET /v1/schema` に対応するシンプルなクエリを示しています。パッケージを読み込みローカルインスタンスへ接続してクライアントを初期化します。その後 `.schema` を `.getter()` で取得してクエリを構築します。クエリは `.do()` 呼び出しで送信されます。`do()` は構築して実行したいあらゆる関数で必須です。 + +### 一般的な注意事項 +- すべてのメソッドは ES6 Promise を使用して非同期コードを扱います。そのため、関数呼び出し後に `.then()` を使用するか、`async` / `await` をサポートする必要があります。 +- エラーが発生した場合、Promise はそのエラーメッセージで reject されます。(`async` / `await` を使用している場合、reject された Promise は throw された例外と同様に扱われます) +- クライアント内部では `isomorphic-fetch` を使用して REST 呼び出しを行いますので、ブラウザと NodeJS アプリケーションのどちらでも変更なしで動作します。 + +## JavaScript ユーザーのための TypeScript + +TypeScript は JavaScript のスーパーセットです。しかし、いくつかの違いがあります。このセクションでは、 TypeScript を初めて使用する JavaScript ユーザー向けにヒントを紹介します。 + +### TypeScript ファイルの実行 + +TypeScript ファイルを実行するには、まず JavaScript に変換します。`npm` の `typescript` パッケージには `tsc` ユーティリティが含まれています。`tsc` を使用して TypeScript ファイルを変換(トランスパイル)します。 + +`typescript` パッケージをインストールします。グローバルに利用したい場合は `-g` フラグを追加してください。 + +```bash +npm install typescript +``` + +Weaviate TypeScript クライアントのように、追加の設定が必要なパッケージもあります。TypeScript プロジェクトのルートディレクトリには `tsconfig.json` ファイルがあります。以下を `tsconfig.json` に追加してください。 + +- コンパイラオプション + - `"target": "esnext"` + - `"module": "esnext"` + - `"moduleResolution": "node"` +- `"include": ["*.ts"]`(または特定のファイル) +- `"lib": [ "es2018" ]` + +`tsconfig.json` を使用する場合、コマンドラインでファイル名を指定しないでください。TypeScript ファイルは `tsconfig.json` に指定します。`tsc` は単体で実行したときのみ `tsconfig.json` を読み込みます。 + +```bash +tsc +``` + +`node` はモジュール内でのみ `import` 文を許可します。`import` 文を使用できるように、`package.json` に以下を追加してください。 + +```json +{ + "type": "module" +} +``` + +### 例 + +この例を実行するには、次の手順を完了してください。 + +- `typescript` パッケージをインストールする。 +- `tsconfig.json` と `package.json` を前述のとおり更新する。 +- サンプルコードをコピーする。 +- コードを `sample.ts` として `tsconfig.json` と `package.json` と同じディレクトリに保存する。 +- コードを変換し、実行する。 + +`sample.ts` を作成するために次のコードを使用します。 + +
+ サンプル TypeScript コード + +```ts +import weaviate from 'weaviate-ts-client'; + +const client = weaviate.client({ + scheme: 'https', + host: 'edu-demo.weaviate.network', + apiKey: new weaviate.ApiKey('learn-weaviate'), +}); + +console.log(client.misc) +``` +
+ +`sample.ts` を変換します。 + +```bash +tsc +``` + +変換されたファイルを実行します。 + +```bash +node sample.js +``` + +出力は次のようになります。 + +
+ サンプル出力 + +```json +{ + "clientId": "wcs", + "href": "https://auth.wcs.api.weaviate.io/auth/realms/SeMI/.well-known/openid-configuration" +} +``` +
+ +## クライアントリリース + +
+ Weaviate と対応するクライアントバージョンの表を表示するにはここをクリック + +import ReleaseHistory from '/_includes/release-history.md'; + + + +
+ +## クライアント変更履歴 + +クライアントの変更履歴は各リリースごとに GitHub で確認できます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/v2_v3_migration.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/v2_v3_migration.mdx new file mode 100644 index 000000000..6a9ea2b48 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/client-libraries/typescript/v2_v3_migration.mdx @@ -0,0 +1,462 @@ +--- +title: v2 から v3 への移行 +sidebar_position: 70 +description: TypeScript アプリケーションを v2 から最新の v3 クライアントライブラリへ移行するためのアップグレードガイド。 +image: og/docs/client-libraries.jpg +# tags: ['typescript', 'client library'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import TSv2Code from '!!raw-loader!/_includes/code/client-libraries/migrate-ts2.ts'; +import TSv3Code from '!!raw-loader!/_includes/code/client-libraries/migrate-ts3.ts'; +import TSv3Additional from '!!raw-loader!/_includes/code/client-libraries/migrate-additional-ts3.ts'; +import TSv2Additional from '!!raw-loader!/_includes/code/client-libraries/migrate-additional-ts2.ts'; + +import TSClientIntro from '/_includes/clients/ts-client-intro.mdx'; + + + +## インストール + +TypeScript クライアント v3 をインストールするには、次の手順に従ってください。 + +1. **Node.js を更新** + + v3 クライアントには `Node v18` 以上が必要です。 + +1. **新しいクライアントパッケージをインストール** + + ```bash + npm install weaviate-client + ``` + +1. **Weaviate をアップグレード** + + v3 クライアントには Weaviate Database `1.23.7` 以上が必要です。可能な限り、Weaviate Database と Weaviate クライアントの最新バージョンを使用してください。 + +1. **gRPC ポートを開放** + + デフォルトの gRPC ポートは 50051 です。 + +
+ docker-compose.yml + + Docker コンテナ内の Weaviate gRPC ポートをローカルポートにマッピングするには、`docker-compose.yml` ファイルに次のコードを追加します。 + + ```yaml + ports: + - 8080:8080 + - 50051:50051 + ``` +
+ +## クライアントの生成 + +`weaviate` オブジェクトは、すべての API 操作のメインエントリーポイントです。v3 クライアントは `weaviate` オブジェクトを生成し、あなたの Weaviate インスタンスへ [接続を作成](/weaviate/connections) します。 + +ほとんどの場合、接続ヘルパー関数のいずれかを使用して Weaviate インスタンスへ接続することを推奨します。 + +- `connectToWCD` +- `connectToLocal` +- `connectToCustom` + +カスタム設定を使用して、クライアントを直接生成することもできます。 + + + + + + + + + + + + + +## v3 の変更点 + +このセクションでは、TypeScript クライアント v3 の主な特徴を紹介します。 + +### 設計方針 + +v3 クライアントは、コレクションを通じて Weaviate データベース内のオブジェクトを操作することを中心に設計されています。 + +アプリケーションコードはコレクションを表すオブジェクトを作成し、そのオブジェクトを通じて検索や CRUD 操作を実行します。 + +次の例は `JeopardyQuestion` コレクションからオブジェクトを取得します。 + +```js +const myCollection = client.collections.use('JeopardyQuestion'); + +const result = await myCollection.query.fetchObjects() + +console.log(JSON.stringify(result, null, 2)); +``` + +### Node のみ対応 + +gRPC プロトコルは高速で、内部的にも多くの利点があります。しかし残念ながら、gRPC はブラウザベースのクライアント開発をサポートしていません。 + +v3 クライアントは gRPC を使用して Weaviate インスタンスへ接続します。そのため、クライアントは Node.js を用いたサーバーサイド開発をサポートし、ブラウザベースの Web クライアント開発はサポートしていません。 + +ブラウザベースのアプリケーションを開発する場合は、[v2 クライアント](/weaviate/client-libraries/typescript/typescript-v2) をご利用ください。 + +### コレクションの操作 + +v2 クライアントでは CRUD や検索操作に `client` オブジェクトを使用します。v3 クライアントでは、`client` オブジェクトの代わりに `collection` オブジェクトを使用します。 + +接続を作成した後は、各操作でコレクションを指定する必要がありません。これによりミスを減らせます。 + + + + + + + + + + +`collection` オブジェクトはコードベース全体で再利用できます。 + + + +### ビルダー パターンの廃止 + +v2 クライアントはビルダー パターンを使用してクエリを構築します。ビルダー パターンはわかりにくく、無効なクエリを引き起こす可能性があります。 + +v3 クライアントではビルダー パターンを使用しません。その代わり、特定のメソッドとメソッド パラメーターを使用します。 + + + + + + + + + + +### バッチ挿入 + +`insertMany()` メソッドは `objectBatcher()` を置き換え、バッチ挿入を簡単にします。 + +5,000 件を超えるオブジェクトを挿入する場合は、バッチ処理の一部として `insertMany()` を使用してください。 + +バッチ処理の詳細については、[バッチ挿入](../../manage-objects/import.mdx) を参照してください。 + + + + + + + + + + +### クライアントの Close メソッド + +import TSClientClose from '/_includes/clients/ts-client-close.mdx'; + + + +### データのフィルタリング + +`Filter` ヘルパー クラスにより、条件付きフィルターの利用が容易になります。v3 クライアントでは `Filter` の使用方法が簡素化され、コードがよりクリーンで簡潔になります。 + + + + + + + + + + +### generate 名前空間 + +v3 クライアントでは生成クエリ用に新しい名前空間 `generate` が追加されました。これにより、生成クエリとベクトル検索を区別しやすくなります。 + + + + + + + + + + +### 返却オブジェクト + +新しいクライアントでは返却オブジェクトがよりシンプルになりました。オブジェクトの UUID、メタデータ、生成クエリの結果などの重要な情報に簡単にアクセスできます。 + + + + + + + + + + + + +## コード比較 + +これらのサンプルでは、クライアント v2 コードと v3 コードを比較します。 + +比較用サンプルでは、両クライアントで共通するコード部分を省略しています。完全な v2 と v3 のクライアントスクリプトは[こちら](#sample-scripts)にあります。 + +### インポート + + + + + + + + + + +### Weaviate Cloud への接続 + + + + + + + + + + +### コレクションの作成 + + + + + + + + + + +### バッチ挿入 + + + + + + + + + + +### データのクエリ実行 + + + + + + + + + + +### コレクションの削除 + + + + + + + + + + + +### サンプルスクリプト + +このセクションのクライアント比較コードを、完全な形で示したスクリプトです。 + + + + + + + + + + +その他のコード例については、以下を参照してください。 + +- [検索](/weaviate/search) +- [コレクション管理](/weaviate/manage-collections) +- [Weaviate への接続](/weaviate/connections) + +## コードの移行方法 + +v2 クライアントコードを v3 に更新するには、次の手順を行います。 + +1. [ v3 クライアントパッケージ](https://www.npmjs.com/package/weaviate-client) をインストールします。 +1. v2 コードを編集し、v3 クライアントパッケージを [インポート](/weaviate/client-libraries/typescript#import-the-client) します。 +1. v2 の [クライアント生成](/weaviate/client-libraries/typescript) コードを編集します。 +1. コードを編集し、[ collection first](#design-philosophy) のクライアント指向を反映させます。 + +v2 のコードを v3 相当へすべて置き換えるまで、順次更新してください。 + +## クライアントの変更ログ + +各リリースのクライアント [変更ログ](https://github.com/weaviate/typescript-client/releases) は GitHub で確認できます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/cluster.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/cluster.md new file mode 100644 index 000000000..ebe5dafcc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/cluster.md @@ -0,0 +1,170 @@ +--- +title: 水平スケーリング +sidebar_position: 30 +description: "高可用性 Weaviate デプロイメントのためのマルチノード クラスター アーキテクチャと水平スケーリング戦略。" +image: og/docs/concepts.jpg +# tags: ['architecture', 'horizontal scaling', 'cluster', 'replication', 'sharding'] +--- + +Weaviate は、クラスター内で複数ノードを構成して実行することで水平スケーリングできます。ここでは、Weaviate をスケールさせるさまざまな方法、スケーリング時に考慮すべき要素、および水平スケーリングに関連する Weaviate のアーキテクチャについて説明します。 + +## 基本概念 + +### シャード + +Weaviate のコレクションは 1 つ以上の「シャード」で構成され、これがデータ保存および取得の基本単位となります。シャードは独自の ベクトル インデックス、転置インデックス、オブジェクトストアを持ちます。各シャードは異なるノードに配置でき、分散データ保存と処理を可能にします。 + +![シャードの概要](./img/shards_explained.png) + +シングルテナント コレクションにおけるユニーク シャード数は、コレクション作成時にのみ設定できます。ほとんどの場合、Weaviate にシャード数を任せれば十分ですが、パフォーマンスやデータ分散の理由で手動設定したい場合もあります。 + +マルチテナント コレクションでは、各テナントが 1 つのシャードに相当します。つまり、マルチテナント コレクションのユニーク シャード数はテナント数と同じです。 + +![コレクション内のシャード](./img/shards_in_collections.png) + +### レプリカ + +設定に応じて、各シャードは 1 つ以上の「レプリカ」を持ち、異なるノードに配置できます。これは「高可用性」構成と呼ばれ、同じデータが複数ノードに存在します。これにより読み取りスループットと耐障害性が向上します。 + +希望するレプリカ数(レプリケーションファクター)は Weaviate で設定できます。これは [`REPLICATION_MINIMUM_FACTOR` 環境変数](/docs/deploy/configuration/env-vars/index.md) でクラスター全体のデフォルトとして設定するか、[コレクション単位](/docs/weaviate/manage-collections/multi-node-setup.mdx#replication-settings)で設定してグローバルデフォルトを上書きできます。 + +## Weaviate をスケールさせる動機 +一般的には、水平スケールを行う動機は(少なくとも) 3 つあり、それぞれ異なる構成につながります。 + +### 動機 1: データセット最大サイズ +[HNSW グラフのメモリフットプリント](./resources.md#the-role-of-memory) により、データセットを複数サーバー(「ノード」)に分散したい場合があります。この構成では、単一コレクションを複数シャードに分け、それらをノード間で分散させます。 + +Weaviate はインポート時とクエリ時に必要なオーケストレーションを自動で行います。 + +複数シャードを実行する際のトレードオフについては [シャーディングとレプリケーション](#sharding-vs-replication) を参照してください。 + +**解決策: クラスター内の複数ノードにシャーディング** + +:::note +クラスター全体でのシャーディング機能は Weaviate `v1.8.0` で追加されました。 +::: + +### 動機 2: クエリ スループット向上 +単一の Weaviate ノードで処理できるより多くのクエリを受ける場合、追加ノードを配置してユーザーのクエリに応答させることが望ましいです。 + +複数ノードにシャーディングする代わりに、同一データを複数ノードへレプリケートできます。このプロセスも全自動で、レプリケーションファクターを指定するだけです。シャーディングとレプリケーションを組み合わせることも可能です。 + +**解決策: クラスター内の複数ノードへクラスをレプリケート** + +### 動機 3: 高可用性 + +Weaviate で重要な負荷を処理する際、ノードが完全に障害を起こしてもクエリを提供し続けたい場合があります。障害はソフトウェアまたは OS レベルのクラッシュ、あるいはハードウェア障害が原因かもしれません。予期せぬクラッシュ以外にも、ゼロダウンタイムのアップデートや保守作業を許容できます。 + +高可用性構成を運用するには、クラスを複数ノード間でレプリケートする必要があります。 + +**解決策: クラスター内の複数ノードへクラスをレプリケート** + +## シャーディングとレプリケーション + +上記の動機で、クラスを複数ノードにシャーディングする場合とレプリケートする場合、またはその両方が必要となる場面を説明しました。ここでは、シャードおよび / またはレプリカ構成の影響を紹介します。 + +:::note +以下のシナリオはすべて、シャーディング数やレプリケーションファクターを増やす際にクラスターサイズも合わせて調整することを前提としています。シャード数またはレプリケーションファクターがクラスターのノード数より少ない場合、以下の利点は適用されません。* +::: + +### シャーディングを増やす利点 +* より大きなデータセットを扱える +* インポート速度が向上する + +複数 CPU を効率的に使用するには、コレクションに複数シャードを作成してください。最速のインポートには、単一ノードであっても複数シャードを作成することを推奨します。 + +### シャーディングを増やす欠点 +* シャード ノードを追加してもクエリ スループットは向上しない + +### レプリケーションを増やす利点 +* システムが高可用性になる +* レプリケーションを増やすとクエリ スループットがほぼ線形に向上する + +### レプリケーションを増やす欠点 +* レプリカ ノードを追加してもインポート速度は向上しない + +### シャーディングキー(パーティションキー) +Weaviate はオブジェクトの特性を基に、どのシャードに属するかを決定します。`v1.8.0` 時点では、シャーディングキーは常にオブジェクトの UUID です。シャーディングアルゴリズムには 64bit Murmur-3 ハッシュを使用しています。今後、他のプロパティやアルゴリズムが追加される可能性があります。 + +なお、マルチテナント コレクションでは各テナントが 1 つのシャードに相当します。 + +## シャード レプリカの移動 + +:::info `v1.32` で追加 +::: + +シャード レプリカを 1 つのノードから別のノードへ移動またはコピーできます。これはノード間の負荷を均衡させたい場合や、コレクションの一部のレプリケーションファクターを変更したい場合に有用です。 + +詳細な操作手順は [こちら](/docs/deploy/configuration/replica-movement.mdx) を参照してください。 + +### シャード レプリカ移動のユースケース + +1. **負荷分散**: 特定ノードの負荷が高い場合、シャード レプリカを移動することでクラスター全体の負荷を均等化できます。 +2. **スケーリング**: クラスターをスケーリング(例: 負荷増加に対応するノード追加)する際、新しいノードへシャード レプリカを移動し、データを均等に分散させます。 +3. **ノード保守または交換**: ノードが保守(例: ハードウェアのアップグレード)や交換を必要とする場合、保守期間中も可用性を維持できるよう、シャード レプリカを一時的または交換用ノードへ移動します。 + +## ノードディスカバリー + +デフォルトでは、クラスター内の Weaviate ノードは [Hashicorp の Memberlist](https://github.com/hashicorp/memberlist) を使用した gossip ライク プロトコルでノード状態や障害状況を通信します。 + +Weaviate は、特にクラスター運用時に Kubernetes 上での実行を最適化しています。[Weaviate Helm チャート](/deploy/installation-guides/k8s-installation.md#weaviate-helm-chart) は `StatefulSet` とヘッドレス `Service` を利用してノードディスカバリーを自動設定します。必要なのは希望ノード数を指定することだけです。 + +
+ ノードディスカバリー用 FQDN + +:::caution `v1.25.15` で追加され `v1.30` で削除 + +これは実験的機能でした。利用時はご注意ください。 + +::: + +IP アドレスベースのノードディスカバリーが最適でない場合があります。そのような場合は、`RAFT_ENABLE_FQDN_RESOLVER` と `RAFT_FQDN_RESOLVER_TLD` [環境変数](/deploy/configuration/env-vars/index.md#multi-node-instances) を設定して、完全修飾ドメイン名 (FQDN) ベースのノードディスカバリーを有効化できます。 + +この機能を有効にすると、Weaviate はメタデータ(例: Raft)通信においてノード名を IP アドレスへ解決する際、FQDN リゾルバーを使用します。 + +:::info FQDN: メタデータ変更のみに適用 +この機能は、[Raft をコンセンサスメカニズムとして使用する](./replication-architecture/cluster-architecture.md#metadata-replication-raft)メタデータ変更にのみ利用されます。データの読み書き操作には影響しません。 +::: + +#### FQDN を使用したノード検出の例 + + FQDN を使用すると、複数のクラスタ間で IP アドレスが再利用されている場合に、あるクラスタのノードが別のクラスタのノードを誤って検出してしまう状況を回避できます。 + + また、サービス (たとえば Kubernetes) を使用している場合に、サービスの IP が実際のノードの IP と異なり、サービスがノードへの接続をプロキシするケースでも有用です。 + +#### FQDN ノード検出の環境変数 + +`RAFT_ENABLE_FQDN_RESOLVER` は Boolean フラグです。 このフラグを有効にすると、 FQDN リゾルバーが有効になります。 `true` に設定すると、 Weaviate は FQDN リゾルバーを使用してノード名をノードの IP アドレスへ解決します。 `false` に設定すると、 Weaviate は memberlist ルックアップを使用してノード名をノードの IP アドレスへ解決します。 既定値は `false` です。 + +`RAFT_FQDN_RESOLVER_TLD` は文字列で、ノード ID を IP アドレスに解決するときに `[node-id].[tld]` という形式で末尾に付加されます。ここで `[tld]` はトップレベルドメインです。 + + この機能を使用するには、 `RAFT_ENABLE_FQDN_RESOLVER` を `true` に設定してください。 + +
+ +## シャードおよび/またはレプリケーションシャードのノードアフィニティ + + Weaviate は、空きディスク容量が最も多いノードを選択しようとします。 + + これは、新しいクラスを作成するときにのみ適用され、既存の単一クラスにデータを追加するときには適用されません。 + +
+ v1.18.1 以前の挙動 + + バージョン `v1.8.0` から `v1.18.0` では、ユーザーは特定のシャードまたはレプリケーションシャードのノードアフィニティを指定できませんでした。 + + シャードは、ランダムに選ばれたノードから開始して、ラウンドロビン方式で「ライブ」ノードに割り当てられていました。 + +
+ +## 整合性と現時点での制限 + +* `v1.25.0` から、 Weaviate は選出されたリーダーによって調整されるログベースのアルゴリズムである [ Raft コンセンサスアルゴリズム](https://raft.github.io/) を採用しました。 これにより、スキーマを同時に変更できるという追加の利点が得られます。
Kubernetes ユーザーの場合は、アップグレード前に [`1.25 移行ガイド`](/deploy/migration/weaviate-1-25.md) をご覧ください。 アップグレードするには、既存の StatefulSet を削除する必要があります。 +* `v1.8.0` 以降、クラスタ全体にスキーマ変更をブロードキャストするプロセスでは、二相トランザクションの形式が使用されていますが、現時点ではトランザクションの実行中にノード障害が発生すると耐えられません。 +* `v1.8.0` 以降、クラスタの動的スケーリングはまだ完全にはサポートされていません。 既存のクラスタに新しいノードを追加することは可能ですが、シャードの所有権には影響しません。 データが存在する場合、ノードを削除する前にシャードが他のノードへ移動されないため、既存のノードはまだ削除できません。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/data.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/data.md new file mode 100644 index 000000000..c85a3426b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/data.md @@ -0,0 +1,521 @@ +--- +title: データ構造 +sidebar_position: 10 +description: "Weaviate におけるコア データオブジェクトの概念、スキーマ設計、およびデータ整理の基本原則。" +image: og/docs/concepts.jpg +--- + +import SkipLink from '/src/components/SkipValidationLink' + +## データオブジェクトの概念 + +Weaviate の各データオブジェクトは `collection` に属し、1 つ以上の `properties` を持ちます。 + +Weaviate は `data objects` をクラスベースのコレクションに格納します。データオブジェクトは JSON ドキュメントとして表現されます。通常、オブジェクトには機械学習モデルから生成された `vector` が含まれます。このベクトルは `embedding`、`vector embedding` と呼ばれることもあります。 + +各コレクションには同じ `class` のオブジェクトが含まれます。これらのオブジェクトは共通の `schema` で定義されます。 + +```mermaid +flowchart LR + + subgraph Collection["🗄️ Collection"] + direction LR + CollectionConfig["Collection Configuration

(e.g. data schema,
embedding model integration,
index configurations,
replication config, etc.)"] + end + + subgraph search ["Indexes"] + direction LR + Indexes["Indexes"] + + subgraph vector ["Vector Search"] + direction TB + VectorIndex["Vector Index"] + IndexStructure["Index Structure"] + VectorCache["Vector Cache"] + end + + subgraph text ["Filtering / Text Search"] + direction LR + InvertedIndex["Inverted Index"] + BM25Index["BM25 Index"] + FilterIndex["Filter Index"] + end + end + + subgraph storage ["Data Storage"] + direction TB + ObjectStore["Object Store"] + ObjectData["Object Data / Metadata"] + VectorData["Vector Data"] + end + + %% Connections + Collection --> Indexes + Collection --> ObjectStore + + Indexes --> VectorIndex + Indexes --> InvertedIndex + + VectorIndex --> IndexStructure + VectorIndex --> VectorCache + + InvertedIndex --> BM25Index + InvertedIndex --> FilterIndex + + ObjectStore --> ObjectData + ObjectStore --> VectorData + + %% Style Collection node + style Collection fill:#ffffff,stroke:#130C49,color:#130C49,stroke-width:2px + + %% Style Config components (purple color) + style CollectionConfig fill:#f5f5f5,stroke:#9575CD,color:#130C49 + + %% Style Memory components (warm color) + style Indexes fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style VectorIndex fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style InvertedIndex fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style VectorCache fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style IndexStructure fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style BM25Index fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style FilterIndex fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + + %% Style Disk components (cool color) + style ObjectStore fill:#E3F2FD,stroke:#64B5F6,color:#130C49 + style ObjectData fill:#E3F2FD,stroke:#64B5F6,color:#130C49 + style VectorData fill:#E3F2FD,stroke:#64B5F6,color:#130C49 + + %% Style subgraphs + style search fill:#ffffff,stroke:#7AD6EB,stroke-width:2px,color:#130C49 + style vector fill:#ffffff,stroke:#61BD73,stroke-width:2px,color:#130C49 + style text fill:#ffffff,stroke:#61BD73,stroke-width:2px,color:#130C49 + style storage fill:#ffffff,stroke:#7AD6EB,stroke-width:2px,color:#130C49 +``` + +import InitialCaps from '/_includes/schemas/initial-capitalization.md' + + + +### JSON ドキュメントとしてのオブジェクト + +たとえば、 Alice Munro という著者の情報を保存するとします。JSON 形式では次のようになります。 + +```json +{ + "name": "Alice Munro", + "age": 91, + "born": "1931-07-10T00:00:00.0Z", + "wonNobelPrize": true, + "description": "Alice Ann Munro is a Canadian short story writer who won the Nobel Prize in Literature in 2013. Munro's work has been described as revolutionizing the architecture of short stories, especially in its tendency to move forward and backward in time." +} +``` + +### ベクトル + +データオブジェクトには `vector` 表現を付加することもできます。ベクトルは数値の配列で、`"vector"` プロパティに保存されます。 + +この例では、`Alice Munro` のデータオブジェクトには小さなベクトルが付いています。このベクトルは、 Alice に関するテキストや画像などの情報を、機械学習モデルが数値の配列へ変換したものです。 + +```json +{ + "id": "779c8970-0594-301c-bff5-d12907414002", + "class": "Author", + "properties": { + "name": "Alice Munro", + (...) + }, + "vector": [ + -0.16147631, + -0.065765485, + -0.06546908 + ] +} +``` + +データのベクトルを生成するには、Weaviate のベクトライザー [modules](./modules.md) のいずれかを使用するか、ご自身のベクトライザーを利用できます。 + +### コレクション + +コレクションは、同じスキーマ定義を共有するオブジェクトの集合です。 + +この例では、`Author` コレクションにはさまざまな著者を表すオブジェクトが格納されています。 + + + +コレクションは次のようになります。 + +```json +[{ + "id": "dedd462a-23c8-32d0-9412-6fcf9c1e8149", + "class": "Author", + "properties": { + "name": "Alice Munro", + "age": 91, + "born": "1931-07-10T00:00:00.0Z", + "wonNobelPrize": true, + "description": "Alice Ann Munro is a Canadian short story writer who won the Nobel Prize in Literature in 2013. Munro's work has been described as revolutionizing the architecture of short stories, especially in its tendency to move forward and backward in time." + }, + "vector": [ + -0.16147631, + -0.065765485, + -0.06546908 + ] +}, { + "id": "779c8970-0594-301c-bff5-d12907414002", + "class": "Author", + "properties": { + "name": "Paul Krugman", + "age": 69, + "born": "1953-02-28T00:00:00.0Z", + "wonNobelPrize": true, + "description": "Paul Robin Krugman is an American economist and public intellectual, who is Distinguished Professor of Economics at the Graduate Center of the City University of New York, and a columnist for The New York Times. In 2008, Krugman was the winner of the Nobel Memorial Prize in Economic Sciences for his contributions to New Trade Theory and New Economic Geography." + }, + "vector": [ + -0.93070928, + -0.03782172, + -0.56288009 + ] +}] +``` + +各コレクションは独自のベクトル空間を持ちます。つまり、異なるコレクションでは同じオブジェクトでも異なる埋め込みを持つことができます。 + +### UUID + +Weaviate に保存されるすべてのオブジェクトには [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) が割り当てられます。UUID はあらゆるコレクションを通じて一意性を保証します。 + +常に同じオブジェクトが同じ UUID を持つようにしたい場合は、[決定論的 UUID を使用](../manage-objects/import.mdx#specify-an-id-value) できます。これは UUID を変更せずにオブジェクトを更新したいときに便利です。 + +ID を指定しなかった場合、Weaviate がランダムな UUID を自動生成します。 + +並び順が指定されていないリクエストでは、Weaviate は UUID の昇順で処理します。したがって、[オブジェクトの一覧取得](../search/basics.md#list-objects)、[cursor API](../manage-objects/read-all-objects.mdx) の利用、または [オブジェクトの削除](../manage-objects/delete.mdx#delete-multiple-objects-by-id) など、順序が指定されていないリクエストはすべて UUID の昇順で処理されます。 + +### クロスリファレンス + +import CrossReferencePerformanceNote from '/_includes/cross-reference-performance-note.mdx'; + + + +データオブジェクトに関連がある場合、それらの関係を表現するために [クロスリファレンス](../manage-collections/cross-references.mdx) を使用できます。Weaviate のクロスリファレンスは関連情報を取得するためのリンクのようなものです。関係を表現しますが、元のオブジェクトのベクトルは変更しません。 + +リファレンスを作成するには、片方のコレクションのプロパティを使用して、もう一方のコレクションで関連するプロパティの値を指定します。 + +#### クロスリファレンスの例 + +たとえば、「Paul Krugman writes for the New York Times」という文は、 Paul Krugman と New York Times の間の関係を示しています。この関係を表現するには、New York Times を表す `Publication` オブジェクトと、Paul Krugman を表す `Author` オブジェクトの間にクロスリファレンスを作成します。 + +New York Times の `Publication` オブジェクトは次のようになります。`"id"` フィールドにある UUID に注目してください。 + +```json +{ + "id": "32d5a368-ace8-3bb7-ade7-9f7ff03eddb6", + "class": "Publication", + "properties": { + "name": "The New York Times" + }, + "vector": [...] +} +``` + +Paul Krugman の `Author` オブジェクトには、関係を表す新しいプロパティ `writesFor` が追加されています。 + +```json +{ + "id": "779c8970-0594-301c-bff5-d12907414002", + "class": "Author", + "properties": { + "name": "Paul Krugman", + ... +// highlight-start + "writesFor": [ + { + "beacon": "weaviate://localhost/32d5a368-ace8-3bb7-ade7-9f7ff03eddb6", + "href": "/v1/objects/32d5a368-ace8-3bb7-ade7-9f7ff03eddb6" + } + ], +// highlight-end + }, + "vector": [...] +} +``` + +`beacon` サブプロパティの値は、New York Times の `Publication` オブジェクトの `id` の値です。 + +クロスリファレンスは方向性を持ちます。双方向リンクにするには、`Publication` コレクションに `hasAuthors` プロパティを追加し、`Author` コレクションを参照させます。 + +### 複数ベクトル埋め込み(名前付きベクトル) + +import MultiVectorSupport from '/_includes/multi-vector-support.mdx'; + + + +#### コレクション作成後に名前付きベクトルを追加する + +:::info Added in `v1.31` +::: + +名前付きベクトルは、コレクション作成後でも既存のコレクション定義に追加できます。これにより、コレクションを削除・再作成することなく、オブジェクトに新しいベクトル表現を追加できます。 + +既存のコレクション定義に新しい名前付きベクトルを追加した場合、**既存オブジェクトの新しい名前付きベクトルは空のまま** であることに注意してください。追加後に作成または更新されたオブジェクトのみが、新しいベクトル埋め込みを受け取ります。 + +これにより、コレクション内のすべての既存オブジェクトをベクトル化する時間やコストが大量に発生するといった予期しない副作用を防げます。 + +既存オブジェクトにも新しい名前付きベクトルを設定したい場合は、既存オブジェクトの UUID とベクトルを含めてオブジェクトを更新してください。これにより、新しい名前付きベクトルのベクトル化プロセスがトリガーされます。 + + + +:::caution レガシー(名前なし)ベクトライザーでは利用できません +コレクション作成後に名前付きベクトルを追加できる機能は、名前付きベクトルで設定されたコレクションにのみ利用できます。 +::: + +## データ スキーマ + +Weaviate では、データを追加する前に データ スキーマ が必要です。ただし、スキーマ を手動で作成する必要はありません。スキーマ を提供しない場合、Weaviate は入力データに基づいて スキーマ を生成します。 + +import SchemaDef from '/_includes/definition-schema.md'; + + + +:::note スキーマ と タクソノミー +Weaviate の データ スキーマ はタクソノミーとは少し異なります。タクソノミーには階層があります。タクソノミー・オントロジー・スキーマ の関係については、Weaviate の [ブログ記事](https://medium.com/semi-technologies/taxonomies-ontologies-and-schemas-how-do-they-relate-to-weaviate-9f76739fc695) をご覧ください。 +::: + +スキーマ は次の役割を果たします: + +1. コレクションとプロパティを定義します。 +1. 異なるエンベディングを使用するコレクション間も含め、コレクションをリンクするクロスリファレンスを定義します。 +1. モジュールの動作、ANN インデックス設定、リバース インデックス、その他の機能をコレクション単位で設定できます。 + +スキーマ の設定方法の詳細は、[スキーマ チュートリアル](../starter-guides/managing-collections/index.mdx) または [How-to: Manage collections](../manage-collections/index.mdx) をご覧ください。 + +## マルチテナンシー + +:::info Multi-tenancy availability +- `v1.20` で マルチテナンシー が追加されました +::: + +クラスタ内のデータを分離するには、マルチテナンシー を使用します。Weaviate はクラスタを シャード に分割し、各シャード は 1 つのテナントのデータのみを保持します。 + +```mermaid +%%{init: {'theme': 'base', 'themeVariables': { 'background': '#f5f5f5' }}}%% +flowchart TB + subgraph MultiDB ["Multi-Tenant"] + direction LR + subgraph MTCollection["🗄️ Collection"] + direction LR + MTCollectionConfig["Collection Configuration

(e.g. data schema,
embedding model integration,
index configurations,
replication config, etc.)"] + end + + ShardA["Tenant A Shard"] + IndexA["Indexes"] + StoreA["Object Store"] + + ShardB["Tenant B Shard"] + IndexB["Indexes"] + StoreB["Object Store"] + + ShardC["Tenant C Shard"] + IndexC["Indexes"] + StoreC["Object Store"] + + MTCollection --> ShardA + MTCollection --> ShardB + MTCollection --> ShardC + + ShardA --> IndexA + ShardA --> StoreA + + ShardB --> IndexB + ShardB --> StoreB + + ShardC --> IndexC + ShardC --> StoreC + end + + subgraph SingleDB ["Single Collection"] + direction LR + subgraph SingleCollection["🗄️ Collection"] + direction LR + SingleCollectionConfig["Collection Configuration

(e.g. data schema,
embedding model integration,
index configurations,
replication config, etc.)"] + end + + SingleIndexes["Indexes"] + SingleStore["Object Store"] + + SingleCollection --> SingleIndexes + SingleCollection --> SingleStore + end + + %% Style nodes - Single tenant + style SingleCollection fill:#ffffff,stroke:#130C49,color:#130C49,stroke-width:2px + style SingleIndexes fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style SingleStore fill:#E3F2FD,stroke:#64B5F6,color:#130C49 + + %% Style nodes - Multi tenant + style MTCollection fill:#ffffff,stroke:#130C49,color:#130C49,stroke-width:2px + style ShardA fill:#ffffff,stroke:#130C49,color:#130C49,stroke-width:2px + style ShardB fill:#ffffff,stroke:#130C49,color:#130C49,stroke-width:2px + style ShardC fill:#ffffff,stroke:#130C49,color:#130C49,stroke-width:2px + + %% Style tenant resources + style IndexA fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style IndexB fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style IndexC fill:#FFF3E0,stroke:#FFB74D,color:#130C49 + style StoreA fill:#E3F2FD,stroke:#64B5F6,color:#130C49 + style StoreB fill:#E3F2FD,stroke:#64B5F6,color:#130C49 + style StoreC fill:#E3F2FD,stroke:#64B5F6,color:#130C49 + + %% Style subgraphs + style SingleDB fill:transparent,stroke:#7AD6EB,stroke-width:2px,color:#130C49 + style MultiDB fill:transparent,stroke:#7AD6EB,stroke-width:2px,color:#130C49 + style MTCollectionConfig fill:#f5f5f5,stroke:#130C49,color:#130C49,stroke-width:2px + style SingleCollectionConfig fill:#f5f5f5,stroke:#130C49,color:#130C49,stroke-width:2px +``` + +シャーディングの利点: + +- データの分離 +- 高速で効率的なクエリ +- シンプルかつ堅牢なセットアップとクリーンアップ + +テナント シャード は軽量です。1 ノードあたり 50,000 個以上の アクティブ シャード を簡単に扱えます。つまり、およそ 20 ノード で 同時に 1M の アクティブ テナント をサポートできます。 + +マルチテナンシー は、複数の顧客のデータを保存したい場合や、複数のプロジェクトのデータを保存したい場合に特に有用です。 + +:::caution テナント削除 = テナントデータ削除 +テナントを削除すると、そのテナントに対応するシャードが削除されます。結果として、テナントを削除すると そのテナントのすべてのオブジェクトも削除されます。 +::: + +### テナント 状態 + +:::info Multi-tenancy availability +- テナントのアクティビティ ステータス設定は `v1.21` で追加 +- `OFFLOADED` ステータスは `v1.26` で追加 +::: + +テナントには、その利用可否と保存場所を示す アクティビティ ステータス (テナント状態) があります。テナントは `ACTIVE`、`INACTIVE`、`OFFLOADED`、`OFFLOADING`、`ONLOADING` のいずれかです。 + +- `ACTIVE` テナントは読み書きが可能な状態でロードされています。 +- その他の状態では、テナントは読み書き不可で、アクセスしようとするとエラーになります。 + - `INACTIVE` テナントはローカル ディスクに保存され、すぐにアクティブ化できます。 + - `OFFLOADED` テナントはクラウド ストレージに保存されます。頻繁にアクセスしないテナントの長期保存に便利です。 + - `OFFLOADING` テナントはクラウド ストレージへ移動中です。一時的な状態で、ユーザーは指定できません。 + - `ONLOADING` テナントはクラウド ストレージからロード中です。一時的な状態で、ユーザーは指定できません。`ONLOADING` テナントは `ACTIVE` または `INACTIVE` へウォームアップされている最中かもしれません。 + +テナントの管理詳細は [Multi-tenancy operations](../manage-collections/multi-tenancy.mdx) をご覧ください。 + +| Status | 利用可 | 説明 | ユーザー指定可 | +| :-- | :-- | :-- | :-- | +| `ACTIVE` | Yes | 読み書き可能な状態でロードされています。 | Yes | +| `INACTIVE` | No | ローカル ディスクに保存され、読み書き不可。アクセスするとエラーになります。 | Yes | +| `OFFLOADED` | No | クラウド ストレージに保存され、読み書き不可。アクセスするとエラーになります。 | Yes | +| `OFFLOADING` | No | クラウド ストレージへ移動中で、読み書き不可。アクセスするとエラーになります。 | No | +| `ONLOADING` | No | クラウド ストレージからロード中で、読み書き不可。アクセスするとエラーになります。 | No | + +:::info Tenant status renamed in `v1.26` +`v1.26` で `HOT` は `ACTIVE` に、`COLD` は `INACTIVE` に名称変更されました。 +::: + +:::info テナント状態の伝播 +テナント状態の変更がクラスタ全体に行き渡るまで、特にマルチノード クラスタでは時間がかかることがあります。 + +
+ +たとえば、オフロードされたテナントを再アクティブ化した後でも、データがすぐには利用可能にならない場合があります。同様に、テナントをオフロードした直後にデータがすぐに利用不可にならない場合もあります。これは、[テナント状態は最終的整合性](../concepts/replication-architecture/consistency.md#tenant-states-and-data-objects) を持ち、変更がクラスタ内のすべてのノードへ伝播する必要があるためです。 +::: + +#### オフロードされたテナント + +:::info Added in `v1.26.0` +::: + +import OffloadingLimitation from '/_includes/offloading-limitation.mdx'; + + + +テナントをオフロードするには、対応する `offload-` モジュールが Weaviate クラスタで [有効化](../configuration/modules.md) されている必要があります。 + +テナントをオフロードすると、そのテナント シャード 全体がクラウド ストレージへ移動します。これは、頻繁にアクセスしないテナントを長期保存するのに便利です。オフロードされたテナントは、クラスタへ再ロードされるまで読み書きできません。 + +### バックアップ + +:::caution バックアップには Inactive または Offloaded テナントは含まれません +マルチテナント コレクションのバックアップには `active` テナントのみが含まれ、`inactive` や `offloaded` テナントは含まれません。すべてのデータを含めるには、バックアップ作成前に [テナントをアクティブ化](../manage-collections/multi-tenancy.mdx#manage-tenant-states) してください。 +::: + +### テナンシー と ID + +各テナンシーは名前空間のようなものです。そのため、異なるテナントが同じオブジェクト ID を持つことも理論上は可能です。命名衝突を避けるため、マルチテナント クラスタではオブジェクト ID に テナント ID を組み合わせ、テナントをまたいで一意となる ID を生成します。 + +### テナンシー と クロスリファレンス + +マルチテナンシー では、一部のクロスリファレンスがサポートされています。 + +サポートされるクロスリファレンス: + +- マルチテナンシー オブジェクト から 非マルチテナンシー オブジェクト への参照 +- 同一テナント内での、マルチテナンシー オブジェクト 同士の参照 + +サポートされないクロスリファレンス: + +- 非マルチテナンシー オブジェクト から マルチテナンシー オブジェクト への参照 +- 異なるテナント間の マルチテナンシー オブジェクト 同士の参照 + +### 主な機能 + +- 各テナントは専用の高性能 ベクトル インデックスを持ちます。専用インデックスにより、共有インデックス空間を検索するのではなく、各テナントがクラスタ上で唯一のユーザーであるかのように高速に応答します。 +- 各テナントのデータは専用シャードに隔離されます。これにより、削除が高速で、他のテナントに影響しません。 +- スケールアウトするには、クラスタにノードを追加するだけです。Weaviate は既存テナントを再分散しませんが、新しいテナントは最もリソース使用率の低いノードに配置されます。 + +:::info 関連ページ +- [How-to: Manage Data | Multi-tenancy operations](../manage-collections/multi-tenancy.mdx) +- [Multi-tenancy ブログ](https://weaviate.io/blog/multi-tenancy-vector-search) +::: + +### 監視メトリクス + +モニタリング用にテナントをグループ化するには、システム設定ファイルで [`PROMETHEUS_MONITORING_GROUP = true`](/deploy/configuration/env-vars/index.md) を設定します。 + +### ノードあたりのテナント数 + +ノードあたりのテナント数は、オペレーティングシステムの制約によって決まります。テナント数は、プロセスごとの Linux の open file 制限を超えることはできません。 + +たとえば、`n1-standard-8` マシンで構築した 9 ノードのテストクラスターでは、約 170k のアクティブテナントを保持できます。ノードあたり 18,000 ~ 19,000 のテナントが存在します。 + +これらの数値はアクティブテナントにのみ関係します。未使用のテナントを [`inactive` に設定](../manage-collections/multi-tenancy.mdx#manage-tenant-states) した場合、プロセスごとの open file 制限は適用されません。 + +## 関連ページ + +以下もご参照ください。 + +- [How-to: マルチテナンシー操作](../manage-collections/multi-tenancy.mdx) +- リファレンス: REST API: Schema +- [How-to: コレクションを管理する](../manage-collections/index.mdx) + +## まとめ + +* スキーマはコレクションとプロパティを定義します。 +* コレクションには JSON ドキュメントで記述されたデータオブジェクトが含まれます。 +* データオブジェクトには ベクトル とプロパティを含めることができます。 +* ベクトル は機械学習モデルから生成されます。 +* 異なるコレクションは異なる ベクトル 空間を表します。 +* クロスリファレンスはスキーマ間でオブジェクトをリンクします。 +* マルチテナンシーは各テナントのデータを分離します。 + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/filtering.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/filtering.md new file mode 100644 index 000000000..63e3a365f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/filtering.md @@ -0,0 +1,161 @@ +--- +title: フィルタリング +sidebar_position: 26 +description: "意味的類似度と構造化されたスカラー フィルタリングを組み合わせたフィルタ付き ベクトル検索機能。" +image: og/docs/concepts.jpg +# tags: ['architecture', 'filtered vector search', 'pre-filtering'] +--- + +Weaviate は強力なフィルタ付き ベクトル検索機能を提供しており、ベクトル検索と構造化されたスカラー フィルターを組み合わせることができます。これにより、クエリ ベクトルに最も近いベクトルのうち、特定の条件を満たすものを検索できます。 + +Weaviate におけるフィルタ付き ベクトル検索はプリフィルタリングという概念に基づいています。これは、ベクトル検索を実行する前にフィルターを構築する方式です。一般的なプリフィルタリング実装とは異なり、Weaviate のプリフィルタリングはブルートフォース ベクトル検索を必要とせず、高い効率を実現しています。 + +`v1.27` から、Weaviate は [`ACORN`](#acorn) フィルター戦略を実装しました。このフィルタリング手法は、特にフィルターとクエリ ベクトルの相関が低い場合に、大規模データセットでの性能を大きく向上させます。 + +## ポストフィルタリングとプリフィルタリング + +プリフィルタリングを利用できないシステムでは、通常ポストフィルタリングを行います。これはまずベクトル検索を実行し、その後フィルター条件を満たさない結果を除外する方式です。これには次の 2 つの大きな欠点があります。 + +1. フィルターが既に絞り込まれた候補リストに適用されるため、検索結果に何件含まれるかを予測しづらい。 +2. フィルターが非常に厳しい場合(データセット全体のごく一部しか一致しない場合)、元のベクトル検索結果に一致するものが 1 件も含まれない可能性がある。 + +プリフィルタリングはこれらの制限を克服します。プリフィルタリングでは、ベクトル検索を開始する前に許可リスト(allow-list)を作成し、検索はこのリストに含まれる候補のみを対象とします。 + +:::note +著者によっては「プリフィルタリング」と「シングルステージフィルタリング」を区別し、前者はブルートフォース検索を伴い後者は伴わないと定義する場合があります。本ドキュメントではこの区別を行いません。Weaviate は転置インデックスと HNSW インデックスを組み合わせているため、プリフィルタリングでもブルートフォース検索に頼る必要がないからです。 +::: + +## Weaviate における効率的なプリフィルタ付き検索 + +[ストレージについてのセクション](./storage.md) で、シャードを構成する要素を詳細に説明しました。特に重要なのは、各シャードが HNSW インデックスのすぐ隣に転置インデックスを保持していることです。これにより効率的なプリフィルタリングが実現します。プロセスは次のとおりです。 + +1. 転置インデックス(従来の検索エンジンと同様)を使用して、対象候補の許可リストを作成します。このリストは `uint64` の ID の集合であり、大きくなっても効率が低下しません。 +2. ベクトル検索を実行し、許可リストを HNSW インデックスに渡します。インデックスは通常どおりノードのエッジを辿りますが、許可リストに含まれる ID だけを結果集合に追加します。終了条件はフィルターなしの検索と同じで、希望する件数に達し、追加候補が結果品質を向上させなくなった時点で検索を停止します。 + +## フィルターストラテジー + +`v1.27` 現在、HNSW インデックスタイプ向けに `sweeping` と `acorn` の 2 種類のフィルターストラテジーをサポートしています。 + +### ACORN + +:::info Added in `1.27` +::: + +Weaviate `1.27` では、新しいフィルタリングアルゴリズムとして [`ACORN`](https://arxiv.org/html/2403.04871v1) 論文をベースにした実装を追加しました。Weaviate ではこれを `ACORN` と呼びますが、実際の実装は論文に着想を得た独自実装です(本ドキュメントでの `ACORN` は Weaviate 実装を指します)。 + +`ACORN` アルゴリズムは、[HNSW インデックス](./indexing/vector-index.md#hierarchical-navigable-small-world-hnsw-index) でのフィルタ付き検索を高速化するため、次のように動作します。 + +- フィルターを満たさないオブジェクトは距離計算の対象外にします。 +- 複数ホップで候補の近傍を評価することで、HNSW グラフの関連領域へより早く到達します。 +- フィルターに一致する追加のエントリポイントをランダムにシードし、フィルタリング領域への収束を加速します。 + +`ACORN` アルゴリズムは、特にフィルターとクエリ ベクトルの相関が低い場合に有効です。つまり、フィルターがクエリ ベクトルに最も近いグラフ領域の多くのオブジェクトを除外する場合に効果を発揮します。 + +社内テストでは、相関が低く制限的なフィルター条件下で、特に大規模データセットにおいて `ACORN` が大幅に高速化することを確認しています。もしこれがボトルネックになっている場合は、`ACORN` の有効化を推奨します。 + +`v1.27` では、対象の HNSW ベクトルインデックスの [コレクション設定](../manage-collections/vector-config.mdx#set-vector-index-parameters) で `filterStrategy` フィールドを設定することで `ACORN` アルゴリズムを有効化できます。 + +### Sweeping + +既存であり、現在のデフォルトフィルターストラテジーは `sweeping` です。この方式は HNSW グラフを「スイープ(掃引)」する概念に基づいています。 + +アルゴリズムはルートノードから開始し、グラフを走査しながらクエリ ベクトルとの距離を評価し、フィルターの「許可リスト」をコンテキストとして保持します。フィルターを満たさないノードはスキップし、走査を継続します。このプロセスを、所定の件数に到達するまで繰り返します。 + +## `indexFilterable` {#indexFilterable} + +:::info Added in `1.18` +::: + +Weaviate `v1.18.0` では、Roaring Bitmap を利用してマッチベースのフィルタリングを高速化する `indexFilterable` インデックスを追加しました。Roaring Bitmap はデータをチャンクに分け、それぞれに適切なストレージ戦略を適用して効率化を図ります。これにより高いデータ圧縮率と高速な集合演算が実現し、Weaviate のフィルタリング速度が向上します。 + +大規模データセットを扱う場合、フィルタリング性能が大幅に向上する可能性が高いため、移行して再インデックスすることを推奨します。 + +また、弊社チームは基盤となる Roaring Bitmap ライブラリをメンテナンスし、問題への対処や改善を行っています。 + +#### `text` プロパティ向け `indexFilterable` + +:::info Added in `1.19` +::: + +`1.19` 以降、`text` プロパティ向けの Roaring Bitmap インデックスが利用可能です。この実装では `filterable` と `searchable` の 2 つのインデックスに分割され、従来の単一インデックスを置き換えます。新しい `indexFilterable` と `indexSearchable` パラメーターを設定して、Roaring Set インデックスと BM25 用 Map インデックスを生成するかを決定できます(どちらもデフォルトで有効)。 + +#### `indexFilterable` への移行 {#migration-to-indexFilterable} + +Weaviate `1.18.0` 未満を使用している場合は、`1.18.0` 以降へアップグレードし、新しいインデックスを作成する 1 回限りのプロセスを実行することで Roaring Bitmap を利用できます。Weaviate が Roaring Bitmap インデックスを作成すると、その後はバックグラウンドで動作し、作業を高速化します。 + +この挙動は REINDEX_SET_TO_ROARINGSET_AT_STARTUP [環境変数](/deploy/configuration/env-vars/index.md) で制御できます。再インデックスを行いたくない場合は、アップグレード前に `false` に設定してください。 + +:::info Read more +Weaviate の Roaring Bitmap 実装の詳細は、[インラインドキュメント](https://pkg.go.dev/github.com/weaviate/weaviate/adapters/repos/db/lsmkv/roaringset) をご覧ください。 +::: + +## `indexRangeFilters` + +:::info Added in `1.26` +::: + +Weaviate `1.26` では、数値範囲でのフィルタリングに対応した範囲ベースインデックス `indexRangeFilters` を導入しました。このインデックスは `int`、`number`、`date` プロパティに利用できます(これらの配列型には対応していません)。 + +内部的には、範囲インデックスは Roaring Bitmap のスライスとして実装されています。このデータ構造により、64 ビット整数として保存できる値に限定されます。 + +`indexRangeFilters` は新規プロパティでのみ利用可能です。既存プロパティを範囲インデックスへ変換することはできません。 + +## プリフィルタ付き検索のリコール + +Weaviate 独自の HNSW 実装は、HNSW グラフ内のリンクを通常どおり辿りつつ、結果集合を評価する際にのみフィルター条件を適用するため、グラフの整合性が保たれます。そのため、フィルター付き検索のリコールは通常、フィルターなし検索と同等です。 + +次の図は、制限度合いの異なるフィルターを示しています。左(データセットの 100% に一致)から右(1% に一致)に進むにつれてフィルターが厳しくなりますが、`k=10`、`k=15`、`k=20` のフィルター付き ベクトル検索でもリコールは低下していません。 + + + +![Recall for filtered vector search](./img/recall-of-filtered-vector-search.png "Recall of filtered vector search in Weaviate") + +## フラット検索への切り替え (Cutoff) + + + +`v1.8.0` では、フィルターが極端に厳しくなった場合に自動でフラット(ブルートフォース) ベクトル検索へ切り替える機能が導入されました。このシナリオはベクトル検索とスカラー検索を組み合わせた場合にのみ適用されます。HNSW が特定のフィルターでフラット検索へ切り替える必要がある理由の詳細は、[medium](https://medium.com/data-science/effects-of-filtered-hnsw-searches-on-recall-and-latency-434becf8041c) の記事をご参照ください。要するに、フィルターが非常に制限的な場合(データセットのごく一部しか一致しない場合)、HNSW のトラバーサルは実質的に網羅的になります。つまり、フィルターが厳しくなるほど、HNSW の性能は全データセットに対するブルートフォース検索に近づきます。ただし、このようにフィルターでデータセットを小さな集合に絞り込んでいる場合は、同じブルートフォースに近い性能でも、対象を一致集合のみに限定して検索する方が効率的です。 + +次の図は制限度合いの異なるフィルターを示しています。左(0%)から右(100%)へ進むほどフィルターが厳しくなります。**点線より右側** はデータセットの約 15% をカットオフ値としてブルートフォース検索に切り替えています。 + +![Prefiltering with flat search cutoff](./img/prefiltering-response-times-with-filter-cutoff.png "Prefiltering with flat search cutoff") + +比較として、同じフィルターを純粋な HNSW(カットオフなし)で実行した場合は以下のようになります。 + +![Prefiltering with pure HNSW](./img/prefiltering-pure-hnsw-without-cutoff.png "Prefiltering without cutoff, i.e. pure HNSW") + +カットオフ値は、各コレクションの [スキーマ内 `vectorIndexConfig` 設定](/weaviate/config-refs/indexing/vector-index.mdx#hnsw-index) で個別に設定できます。 + + + +:::note Roaring Bitmap による性能向上 +`v1.18.0` 以降、転置インデックスに Roaring Bitmap を実装したことにより、特に大きな許可リストを扱う場合のフィルタリング時間が短縮されました。上記グラフの *青色* 領域は、特に図の左側で最も大きく削減されます。 +::: + + + + + + + + + + +## 追加リソース +:::info 関連ページ +- [リファレンス: GraphQL API](../api/graphql/index.md) +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/binary-passage-retrieval-vector-vs-binary-hash@3x.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/binary-passage-retrieval-vector-vs-binary-hash@3x.png new file mode 100644 index 000000000..cde19773d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/binary-passage-retrieval-vector-vs-binary-hash@3x.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bm25_operators_dark.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bm25_operators_dark.png new file mode 100644 index 000000000..a36308750 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bm25_operators_dark.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bm25_operators_light.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bm25_operators_light.png new file mode 100644 index 000000000..44c369c4f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bm25_operators_light.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bpr-two-step-query-binary-rerank-vector@3x.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bpr-two-step-query-binary-rerank-vector@3x.png new file mode 100644 index 000000000..7bc57738c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/bpr-two-step-query-binary-rerank-vector@3x.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/console-capture.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/console-capture.png new file mode 100644 index 000000000..9dfa7d635 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/console-capture.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/filtered-vector-search-with-caches-performance.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/filtered-vector-search-with-caches-performance.png new file mode 100644 index 000000000..a258f2a92 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/filtered-vector-search-with-caches-performance.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw-layers.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw-layers.svg new file mode 100644 index 000000000..535e10de2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw-layers.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_1_explained.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_1_explained.png new file mode 100644 index 000000000..7b3e82720 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_1_explained.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_2_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_2_search.png new file mode 100644 index 000000000..22e420585 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_2_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_3_insertion.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_3_insertion.png new file mode 100644 index 000000000..73dce045e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_3_insertion.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_4_parameters.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_4_parameters.png new file mode 100644 index 000000000..e9eab9df8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/hnsw_4_parameters.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/pq-illustrated.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/pq-illustrated.png new file mode 100644 index 000000000..0b480ef4e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/pq-illustrated.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/prefiltering-pure-hnsw-without-cutoff.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/prefiltering-pure-hnsw-without-cutoff.png new file mode 100644 index 000000000..d048f9fdd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/prefiltering-pure-hnsw-without-cutoff.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/prefiltering-response-times-with-filter-cutoff.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/prefiltering-response-times-with-filter-cutoff.png new file mode 100644 index 000000000..80183051e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/prefiltering-response-times-with-filter-cutoff.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/recall-of-filtered-vector-search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/recall-of-filtered-vector-search.png new file mode 100644 index 000000000..9550f8bc5 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/recall-of-filtered-vector-search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/shards_explained.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/shards_explained.png new file mode 100644 index 000000000..58c0a216d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/shards_explained.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/shards_in_collections.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/shards_in_collections.png new file mode 100644 index 000000000..d71b8b46e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/shards_in_collections.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/supermarket.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/supermarket.svg new file mode 100644 index 000000000..d503c452b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/supermarket.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/vectors-2d.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/vectors-2d.png new file mode 100644 index 000000000..5d8805721 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/vectors-2d.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/vectors-2d.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/vectors-2d.svg new file mode 100644 index 000000000..dddc48896 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/vectors-2d.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-architecture-overview.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-architecture-overview.svg new file mode 100644 index 000000000..1d435fa8e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-architecture-overview.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-module-diagram.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-module-diagram.svg new file mode 100644 index 000000000..562b786d7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-module-diagram.svg @@ -0,0 +1 @@ +Created with Fabric.js 3.6.6 \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-modules.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-modules.png new file mode 100644 index 000000000..e9cab03eb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/img/weaviate-modules.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/index.md new file mode 100644 index 000000000..489f4d71d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/index.md @@ -0,0 +1,90 @@ +--- +title: コンセプト +sidebar_position: 0 +description: "Weaviate の ベクトル 検索 と AI ネイティブ データベース機能 を支える 基本 コンセプト と アーキテクチャ 原則" +image: og/docs/concepts.jpg +# tags: ['getting started'] +--- + + + + +**コンセプト** セクションでは、Weaviate とそのアーキテクチャに関するさまざまな側面を解説し、最大限に活用するための理解を助けます。これらのセクションはどの順番でもお読みいただけます。 + +:::info +実践的なガイドをお求めの場合は、[クイックスタート チュートリアル](/weaviate/quickstart/index.md) をご覧ください。 +::: + +## Core concepts + +**[データ構造](./data.md)** + +- Weaviate がデータ オブジェクトをどのように保存・表現し、相互にリンクするかを解説します。 + +**[モジュール](./modules.md)** + +- Weaviate のモジュール システムの概要、モジュールでできること、既存のモジュール タイプ、およびカスタム モジュールについて説明します。 + +**[インデックス作成](./indexing/index.md)** + +- 転置 インデックス と ANN インデックスを用いたデータのインデックス方法と、設定可能なオプションについて読めます。 + +**[ベクトル インデックス作成](./indexing/vector-index.md)** + +- HNSW アルゴリズム、距離計測法、設定可能なオプションなど、Weaviate の ベクトル インデックス作成のアーキテクチャについて詳しく解説します。 + +**[ベクトル 量子化](./vector-quantization.md)** + +- Weaviate の ベクトル 量子化オプションについて詳しく読めます。 + +## Weaviate アーキテクチャ + +以下の図は、Weaviate のアーキテクチャを 30,000 フィートの視点で示しています。 + +[![Weaviate module APIs overview](./img/weaviate-architecture-overview.svg "Weaviate System and Architecture Overview")](./img/weaviate-architecture-overview.svg) + +この図の各コンポーネントについては、以下のガイドで学べます。 + +**[シャード内ストレージの詳細](./storage.md)** + * Weaviate がデータを保存する方法 + * Weaviate が書き込みを永続化する方法 + * 転置 インデックス、 ベクトル インデックス、オブジェクト ストアがどのように相互作用するか + +**[Weaviate を水平スケールする方法](./cluster.md)** + * スケールするさまざまな動機 + * シャーディング vs. レプリケーション + * クラスターの設定 + * 一貫性 + +**[リソース計画方法](./resources.md)** + * CPU 、メモリ、 GPU の役割 + * クラスターを適切にサイズ設定する方法 + * 特定のプロセスを高速化する方法 + * ボトルネックを防ぐ方法 + +**[フィルター付き ベクトル 検索](./filtering.md)** + * ベクトル 検索とフィルターを組み合わせる + * HNSW と 転置 インデックスを組み合わせることで、高リコールかつ高速なフィルター付きクエリを実現する方法を学ぶ + +**[ユーザー向けインターフェイス](./interface.md)** + * ユーザー向け API の設計哲学 + * REST と GraphQL API の役割 + +**[レプリケーション アーキテクチャ](./replication-architecture/index.md)** + * レプリケーションについて + * Weaviate の実装 + * ユースケース + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/index.md new file mode 100644 index 000000000..6ea94c497 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/index.md @@ -0,0 +1,23 @@ +--- +title: インデックス作成 +sidebar_position: 0 +description: "最適化された検索性能とデータ取得効率を実現する Weaviate のインデックス システムの概要。" +image: og/docs/concepts.jpg +# tags: ['basics'] +--- + +Weaviate は複数種類のインデックスをサポートしています。 + +1. **[ベクトル インデックス](./vector-index.md)** - ベクトル インデックス(例: HNSW または flat)は、すべてのベクトル検索クエリを処理します。 + - **HNSW** - 近似最近傍検索 (ANN) ベースのベクトル インデックスです。HNSW インデックスは大規模データセットでもスケールします。 + - **Flat** - 小規模データセット向けのブルートフォース検索を行うベクトル インデックスです。 + - **Dynamic** - 小規模データセットでは flat、大規模データセットでは HNSW に切り替わるベクトル インデックスです。 +1. **[転置インデックス](./inverted-index.md)** - 転置インデックスは BM25 クエリを可能にし、フィルタリングを高速化します。 + +インデックスはコレクション単位で設定できます。 + +:::tip インデックス作成のヒント + +特に大規模データセットでは、インデックスをどのように設定するかが重要です。多くをインデックス化するほどストレージが多く必要になるため、ルール オブ サムとして、特定のフィールドやベクトル空間をクエリしない場合はインデックス化しないようにしましょう。 + +::: \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/inverted-index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/inverted-index.md new file mode 100644 index 000000000..77f62cb4a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/inverted-index.md @@ -0,0 +1,183 @@ +--- +title: 転置インデックス +sidebar_position: 2 +description: "キーワード検索とフィルタリングを効率化する転置インデックス アーキテクチャとその性能向上" +image: og/docs/concepts.jpg +# tags: ['basics'] +--- + +Weaviate の転置インデックスは、単語や数値などの値をそれを含むオブジェクトへマッピングし、高速なキーワード検索とフィルタリングを実現します。 + +## Weaviate における転置インデックスの作成 + +Weaviate のインデックス アーキテクチャを理解することは、パフォーマンスとリソース使用量の最適化に欠かせません。Weaviate は **各プロパティと各インデックスタイプごとに個別の転置インデックス** を作成します。つまり: + +- コレクション内の各プロパティごとに専用の転置インデックスが作成されます +- 作成日時などのメタプロパティにも、それぞれ独立した転置インデックスが作成されます +- 1 つのプロパティが複数のインデックスタイプをサポートしている場合、その数だけ転置インデックスが作成されます +- プロパティをまたぐ集約や組み合わせはインデックス作成時ではなくクエリ実行時に行われます + +**例**: `title` プロパティで `indexFilterable: true` と `indexSearchable: true` の両方を設定すると、検索用に最適化されたインデックスとフィルタリング用に最適化されたインデックスの 2 つが生成されます。 + +このアーキテクチャは柔軟性とパフォーマンスを提供する一方で、複数のインデックスタイプを有効にするとストレージ消費とインデックス作成コストが増加する点に注意してください。 + +`text` プロパティの場合、インデックス作成は次の手順で行われます: + +1. **トークン化**: まず、プロパティに設定された [tokenization method](../../config-refs/collections.mdx#tokenization) に従ってテキストをトークン化します。 +3. **インデックス エントリーの作成**: 処理された各トークンに対し、そのトークンを含むオブジェクトを指すインデックス エントリーを作成します。 + +このプロセスにより、テキスト検索やフィルタリングで対象トークンを含むオブジェクトを素早く特定できます。 + +
+ 2024 年 10 月に追加されたパフォーマンス向上 + +Weaviate バージョン `v1.24.26`、`v1.25.20`、`v1.26.6`、`v1.27.0` では、 BM25F スコアリング アルゴリズムに関して以下のパフォーマンス向上とバグ修正を行いました。 + +- BM25 セグメント マージ アルゴリズムを高速化 +- WAND アルゴリズムを改良し、スコア計算から尽きたタームを除外、必要な場合のみ完全ソートを実施 +- マルチプロパティ検索で、すべてのセグメントのクエリターム スコアを合算しない場合があるバグを修正 +- BM25 スコアを複数セグメントで並列計算するように変更 + +常に最新の Weaviate へのアップグレードを推奨します。これらの改善点を含む最新機能を利用できます。 + +
+ +## BlockMax WAND アルゴリズム + +:::info Added in `v1.30` +::: + +BlockMax WAND アルゴリズムは、 BM25 やハイブリッド検索の高速化に用いられる WAND アルゴリズムの派生版です。転置インデックスをブロック単位に整理し、クエリに無関係なブロックをスキップできるようにします。これによりスコアリングが必要なドキュメント数を大幅に削減し、検索性能を向上させます。 + +BM25(またはハイブリッド)検索が遅い場合で `v1.30` より前の Weaviate を使用している場合は、 BlockMax WAND アルゴリズムを搭載した新しいバージョンへ移行し、パフォーマンスが向上するかお試しください。以前のバージョンからデータを移行する必要がある場合は、[v1.30 移行ガイド](/deploy/migration/weaviate-1-30.md) を参照してください。 + +:::note BlockMax WAND によるスコア変化 + +BlockMax WAND アルゴリズムの特性上、 BM25 やハイブリッド検索のスコアはデフォルトの WAND アルゴリズムと若干異なる場合があります。また、単一プロパティ検索と複数プロパティ検索で IDF やプロパティ長正規化の計算が異なるため、スコアも変わる可能性があります。これは仕様でありバグではありません。 + +::: + +## 転置インデックスの設定 + +Weaviate には 3 種類の転置インデックスがあります。 + +- `indexSearchable` - BM25 またはハイブリッド検索用の検索インデックス +- `indexFilterable` - 一致条件による高速 [フィルタリング](../filtering.md) 用のインデックス +- `indexRangeFilters` - 数値範囲による [フィルタリング](../filtering.md) 用のインデックス + +各転置インデックスはプロパティ単位で `true`(有効)または `false`(無効)を設定できます。`indexSearchable` と `indexFilterable` はデフォルトで有効、`indexRangeFilters` はデフォルトで無効です。 + +フィルタリング用インデックスは [フィルタリング](../filtering.md) 専用ですが、検索用インデックスは検索とフィルタリングの両方に使用できます(ただしフィルタリング速度はフィルタリング用インデックスに劣ります)。 + +そのため、`"indexFilterable": false` で `"indexSearchable": true`(または未設定)とすると、フィルタリング性能は低下しますが、インポートが速くなり(1 つのインデックスのみ更新)、ディスク使用量も減少するというトレードオフがあります。 + +プロパティ単位で転置インデックスを有効・無効にする方法は、[関連 How-to セクション](../../manage-collections/vector-config.mdx#property-level-settings) をご覧ください。 + +インデックスを無効にするかどうかの目安としては、_そのプロパティを基にクエリを実行することがない場合は、無効にして構いません。_ + +#### 転置インデックス タイプの概要 + +import InvertedIndexTypesSummary from '/_includes/inverted-index-types-summary.mdx'; + + + +- `indexFilterable` と `indexRangeFilters` のいずれか、または両方を有効にすると、フィルタリングが高速化されます。 + - 片方のみ有効の場合、そのインデックスがフィルタリングに使用されます。 + - 両方有効の場合、`indexRangeFilters` は比較演算子を伴う操作に、`indexFilterable` は等価・不等価の操作に使用されます。 + +次の表は、適用可能なプロパティで 1 つまたは両方のインデックスタイプが `true` の場合、どちらのフィルターが比較を行うかを示しています。 + +| Operator | `indexRangeFilters` only | `indexFilterable` only | Both enabled | +| :- | :- | :- | :- | +| Equal | `indexRangeFilters` | `indexFilterable` | `indexFilterable` | +| Not equal | `indexRangeFilters` | `indexFilterable` | `indexFilterable` | +| Greater than | `indexRangeFilters` | `indexFilterable` | `indexRangeFilters` | +| Greater than equal | `indexRangeFilters` | `indexFilterable` | `indexRangeFilters` | +| Less than | `indexRangeFilters` | `indexFilterable` | `indexRangeFilters` | +| Less than equal | `indexRangeFilters` | `indexFilterable` | `indexRangeFilters` | + +#### タイムスタンプ用転置インデックス + +[タイムスタンプ検索](/weaviate/config-refs/indexing/inverted-index.mdx#indextimestamps) のためにインデックスを有効にすることもできます。 + +タイムスタンプは現在、`indexFilterable` インデックスでインデックス化されます。 + +## インデックスなしのコレクション + +インデックスを一切設定しないことも可能です。コレクションとプロパティの両方でインデックスをスキップすることで、インデックスなしのコレクションを作成できます。 + +
+ インデックスなしの転置インデックス設定例 - JSON オブジェクト + +転置インデックスを使用しない完全なコレクション オブジェクトの例: + +```js +{ + "class": "Author", + "description": "A description of this collection, in this case, it's about authors", + "vectorIndexConfig": { + "skip": true // <== disable vector index + }, + "properties": [ + { + "indexFilterable": false, // <== disable filterable index for this property + "indexSearchable": false, // <== disable searchable index for this property + "dataType": [ + "text" + ], + "description": "The name of the Author", + "name": "name" + }, + { + "indexFilterable": false, // <== disable filterable index for this property + "dataType": [ + "int" + ], + "description": "The age of the Author", + "name": "age" + }, + { + "indexFilterable": false, // <== disable filterable index for this property + "dataType": [ + "date" + ], + "description": "The date of birth of the Author", + "name": "born" + }, + { + "indexFilterable": false, // <== disable filterable index for this property + "dataType": [ + "boolean" + ], + "description": "A boolean value if the Author won a nobel prize", + "name": "wonNobelPrize" + }, + { + "indexFilterable": false, // <== disable filterable index for this property + "indexSearchable": false, // <== disable searchable index for this property + "dataType": [ + "text" + ], + "description": "A description of the author", + "name": "description" + } + ] +} +``` + +
+ +## 参照資料 + +:::info Related pages + +- [Configuration: Inverted index](../../config-refs/indexing/inverted-index.mdx) +- [How-to: Configure collections](../../manage-collections/vector-config.mdx#property-level-settings) + +::: + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/vector-index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/vector-index.md new file mode 100644 index 000000000..1c06e6662 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/indexing/vector-index.md @@ -0,0 +1,272 @@ +--- +title: ベクトルインデックス +sidebar_position: 1 +description: "HNSW とフラットインデックスによる動的ベクトルインデックスで、類似検索を高速化します。" +image: og/docs/concepts.jpg +slug: /weaviate/concepts/vector-index +# tags: ['vector index plugins'] +--- + +ベクトルインデックスとは何でしょうか? それはベクトルデータベースの主要な構成要素で、[検索精度をわずかに犠牲にするだけで検索速度を **大幅に向上**](https://weaviate.io/blog/vector-search-explained) させる([ HNSW インデックス](#hierarchical-navigable-small-world-hnsw-index))、または多数のデータサブセットを小さなメモリフットプリントで効率的に保存する([ フラットインデックス](#flat-index))ために役立ちます。 [ 動的インデックス](#dynamic-index) はフラットインデックスとして始まり、閾値を超えてスケールした際に動的に HNSW インデックスへ切り替えることも可能です。 + +Weaviate の ベクトルファーストなストレージシステムは、ベクトルインデックスを用いたすべてのストレージ操作を処理します。データをベクトルファーストな方法で保存すると、セマンティックまたはコンテキストベースの検索が可能になるだけでなく、パフォーマンスを低下させることなく *非常に* 大量のデータを保存できます(水平スケールや十分なシャード数が確保されている場合)。 + +Weaviate がサポートするベクトルインデックスの種類は次のとおりです。 +* [ flat インデックス ](#flat-index):小規模なデータセット向けに設計された、シンプルで軽量なインデックス。 +* [ HNSW インデックス ](#hierarchical-navigable-small-world-hnsw-index):ビルドには時間がかかるより複雑なインデックスですが、クエリの時間計算量が対数オーダーのため大規模データセットでも高いスケーラビリティを発揮します。 +* [ 動的インデックス ](#dynamic-index):オブジェクト数が増えるにつれて、フラットインデックスから HNSW インデックスへ自動的に切り替えられます。 + +:::caution Experimental feature +`v1.25` から利用可能です。この機能は実験段階です。ご利用の際はご注意ください。 +::: + +このページでは、ベクトルインデックスとは何か、そして Weaviate の ベクトルデータベースでどのような役割を果たすのかを説明します。 + +:::info ベクトルインデックスとは +ベクトルデータベースにおいて、ベクトルインデックスはベクトル埋め込みを整理し、効率的な類似検索を可能にするデータ構造です。適切なインデックス付けはパフォーマンスに直結し、シンプルなフラットインデックスから HNSW のような高度な方式まで、それぞれ目的に応じた使い分けが必要です。 +::: + +## ベクトルインデックスの必要性 + +[ ベクトル埋め込み](https://weaviate.io/blog/vector-embeddings-explained) は意味を表現する優れた方法です。ベクトルをどのようにインデックス化するかを理解することは、ベクトルデータベースを効果的に扱うために極めて重要です。ベクトル埋め込みは配列であり、テキスト、画像、動画などさまざまなデータタイプから意味を捉えることができます。要素数は「次元」と呼ばれ、高次元ベクトルはより多くの情報を持ちますが、取り扱いは難しくなります。 + +ベクトルデータベースは高次元ベクトルの取り扱いを容易にします。検索を例に取ると、ベクトルデータベースはセマンティック類似度を効率的に測定します。 [ 類似検索](../../search/similarity.md) を実行すると、Weaviate はクエリをベクトル化し、そのベクトルと類似したベクトルを持つオブジェクトをデータベースから探し出します。 + +ベクトルは多次元空間における座標に例えられます。以下のグラフは、*単語* を 2 次元空間で表現したごくシンプルな例です。 + +このグラフでは `Apple` と `Banana` が互いに近く、`Newspaper` と `Magazine` も互いに近い位置にありますが、前者のペアと後者のペアは離れています。同一ペア内の距離が小さいのは、それぞれのベクトル埋め込みが類似しているためです。一方、ペア間の距離が大きいのは、ベクトル間に大きな差異があるためです。直感的にいえば、果物同士は似ていますが、果物と読み物は似ていません。 + +詳しくは [ GloVe](https://github.com/stanfordnlp/GloVe) や [ ベクトル埋め込み](https://weaviate.io/blog/vector-embeddings-explained#what-exactly-are-vector-embeddings) をご覧ください。 + +![2D Vector embedding visualization](../img/vectors-2d.png "2D Vectors visualization") + +別の例えとして、スーパーマーケットの商品配置があります。`Apple` が `Banana` の近くに置かれているのは自然ですが、`Magazine` を探す場合には果物売り場から離れ、例えば `Newspaper` がある通路へ向かうでしょう。Weaviate でも、使用するモジュールによってはこのように概念の意味をベクトルに保存できます。単語やテキストだけでなく、画像、動画、DNA 配列などもベクトル化してインデックス化できます。どのモデルを使うかについては [こちら](/weaviate/modules/index.md) をご覧ください。 + +![Supermarket map visualization as analogy for vector indexing](../img/supermarket.svg "Supermarket map visualization") + +:::tip +ブログ記事 [Vector search explained](https://weaviate.io/blog/vector-search-explained) もぜひご覧ください。 +::: + +それでは、Weaviate がサポートするさまざまなアプローチでベクトルをインデックス化する方法を見ていきましょう。最初に紹介するのは HNSW インデックスです。 + +## Hierarchical Navigable Small World (HNSW) インデックス + +**Hierarchical Navigable Small World (HNSW)** は多層グラフ上で動作するアルゴリズムであり、このアルゴリズムで作成されたベクトルインデックスも HNSW インデックスと呼ばれます。HNSW インデックスはクエリが非常に高速ですが、新しいベクトルを追加する際の再構築はリソースを多く消費する場合があります。 + +Weaviate の `hnsw` インデックスは、Hierarchical Navigable Small World([ HNSW](https://arxiv.org/abs/1603.09320))アルゴリズムの [カスタム実装](../../more-resources/faq.md#q-does-weaviate-use-hnswlib) であり、完全な [ CRUD サポート](https://db-engines.com/en/blog_post/87) を提供します。 + +ビルド時には HNSW アルゴリズムが複数のレイヤーを作成します。クエリ時には、これらのレイヤーを活用して近似最近傍 (ANN) を高速かつ効率的に生成します。 + +以下は HNSW を利用したベクトルインデックスのイメージです。 + +![HNSW explained](../img/hnsw_1_explained.png "HNSW explained") + +各オブジェクトは複数のレイヤーに存在する場合がありますが、すべてのオブジェクトは最下層(図中のレイヤー 0)に必ず存在します。レイヤー 0 のデータオブジェクトは互いに非常に密接に接続されています。上位レイヤーに行くほどデータオブジェクトと接続は少なくなります。上位レイヤーのデータオブジェクトは下位レイヤーのオブジェクトに対応しており、各レイヤーはその下のレイヤーより指数関数的にオブジェクト数が少なくなります。HNSW アルゴリズムはこの階層構造を活用し、大量データを効率的に処理します。 + +![HNSW search](../img/hnsw_2_search.png "HNSW search") + +検索クエリが来ると、HNSW アルゴリズムはまず最上位レイヤーで最も近いデータポイントを探します。次に 1 つ下のレイヤーに降り、そのレイヤーで上位レイヤーのポイントに最も近いデータポイントを探します。これが最近傍です。このプロセスを繰り返し、最下層に到達すると検索クエリに最も近いデータオブジェクトを返します。 + +上位レイヤーにはオブジェクトが少ないため、HNSW は検索対象を大幅に絞り込めます。単一レイヤーのみのデータストアでは、無関係なオブジェクトも多数探索しなければならず、効率が落ちます。 + +HNSW は高速かつメモリ効率に優れた類似検索手法です。キャッシュには最上位レイヤーのみを保持し、下位レイヤーはクエリに近いオブジェクトだけを追加するため、他の手法と比べてメモリ使用量が少なくて済みます。 + +図をもう一度見ると、検索ベクトルが最上位レイヤーの部分結果に接続し、それがレイヤー 1、そしてレイヤー 0 の結果集合へと導く様子がわかります。これにより、検索クエリと無関係なオブジェクトをスキップできます。 + +ベクトルを HNSW インデックスに挿入する手順も同様です。HNSW アルゴリズムは最上位レイヤーで最も近いオブジェクトを探し、下位レイヤーへ移動していき、最適な場所に新しいベクトルを挿入します。その後、新しいベクトルをそのレイヤーの既存ベクトルに接続します。 + +![HNSW insertion](../img/hnsw_3_insertion.png "HNSW insertion") + +### 検索品質と速度のトレードオフ管理 + +HNSW のパラメーターを調整することで、検索品質と速度のバランスを取ることができます。 + +![HNSW parameters](../img/hnsw_4_parameters.png "HNSW parameters") + +`ef` パラメーターは検索速度と品質のバランスを決定づける重要な設定です。 + +`ef` は検索時に HNSW アルゴリズムが使用する動的リストのサイズを指定します。`ef` を大きくすると探索範囲が広がり精度が向上しますが、クエリは遅くなる可能性があります。逆に `ef` を小さくすると高速になりますが、精度が下がる場合があります。 + +たとえばリアルタイム性が最重要なアプリケーションでは、多少精度を犠牲にしても `ef` を小さくする方が適しています。一方、分析や研究など精度が最優先の場面では、クエリ時間が長くなっても `ef` を大きく設定するのが望ましいでしょう。 + +`ef` は固定値として設定することも、動的に設定することもできます。動的 `ef` を使用すると、Weaviate が実行時のクエリ要件に基づき速度とリコールのバランスを最適化します。 + +動的 `ef` を有効にするには `ef`: -1 を指定します。Weaviate はクエリのレスポンス制限に基づき ANN リストのサイズを調整します。この計算は `dynamicEfMin`、`dynamicEfMax`、`dynamicEfFactor` の値も考慮します。 + +### Dynamic ef + +`ef` パラメーターはクエリ時の ANN リストのサイズを制御します。固定サイズを指定する代わりに、Weaviate に動的に設定させることも可能です。動的 `ef` を選択した場合、Weaviate は複数のオプションを用意してリストサイズを制御します。 + +ANN リストの長さはクエリで設定したレスポンスの limit によって決まります。Weaviate は limit を基準にし、`dynamicEf` パラメーターで指定した値を用いてリストサイズを調整します。 + +- `dynamicEfMin` はリスト長の下限を設定します。 +- `dynamicEfMax` はリスト長の上限を設定します。 +- `dynamicEfFactor` はリストのレンジを設定します。 + +リコールを高く保つため、limit が小さくても実際の動的 `ef` 値は `dynamicEfMin` を下回りません。 + +大きな結果セットを取得する際でも検索速度を確保するため、動的 `ef` 値は `dynamicEfMax` を超えません。limit が `dynamicEfMax` より大きい場合は、`dynamicEfMax` は影響せず、動的 `ef` 値は limit と同じになります。 + +ANN リストの長さは、Weaviate が limit に `dynamicEfFactor` を掛けた値を基準に計算し、`dynamicEfMin` と `dynamicEfMax` で補正します。 + +次の GraphQL クエリは limit を 4 に設定しています。 + +```graphql +{ + Get { + JeopardyQuestion(limit: 4) { + answer + question + } + } +} +``` + +コレクション側で動的 `ef` が設定されているとします。 + +```json + "vectorIndexConfig": { + "ef": -1, + "dynamicEfMin": 5 + "dynamicEfMax": 25 + "dynamicEfFactor": 10 + } +``` + +結果として得られる検索リストは次の特徴を持ちます。 + +- 最大 40 オブジェクト (「dynamicEfFactor": 10 × limit: 4) +- 最小 5 オブジェクト ("dynamicEfMin": 5) +- 最大 25 オブジェクト ("dynamicEfMax": 25) +- 実際のサイズは 5 〜 25 オブジェクト + +ローカル環境で [Weaviate の `docker-compose.yml` ファイル](/deploy/installation-guides/docker-installation.md) を使ってインスタンスを起動する場合、`QUERY_DEFAULTS_LIMIT` 環境変数が適切なデフォルトのクエリ limit を設定します。メモリエラーを防ぐため、`QUERY_DEFAULTS_LIMIT` は `QUERY_MAXIMUM_RESULTS` よりかなり低く設定されています。 + +デフォルト limit を変更するには、Weaviate インスタンスを構成する際に `QUERY_DEFAULTS_LIMIT` の値を編集してください。 +### 削除処理 + +クリーンアップは非同期プロセスで、削除や更新後に HNSW グラフを再構築します。クリーンアップ前はオブジェクトが削除済みとしてマークされますが、依然として HNSW グラフに接続されたままです。クリーンアップ中にエッジが再割り当てされ、オブジェクトは完全に削除されます。 + +### 非同期インデクシング + +:::caution Experimental +`v1.22` から利用可能です。これは実験的機能のため、慎重にご利用ください。 +::: + +この機能はベクトル インデックス、特に HNSW インデックスにのみ関連します。 + +非同期インデクシングは、以下の方法で有効化できます。 +- オープンソース版をご利用の場合、環境変数 `ASYNC_INDEXING` を `true` に設定してください。 +- Weaviate Cloud の場合、Weaviate Cloud Console で「Enable async indexing」スイッチをオンにしてください。 + +同期インデクシングでは、ベクトル インデックスはオブジェクト ストアとロックステップで更新されます。 HNSW インデックスの更新は特にインデックス サイズが大きくなるにつれて高コストになり、その結果インデクシング処理がボトルネックとなってユーザー リクエスト完了までの時間を遅くする可能性があります。 + +非同期インデクシングを有効化すると、すべてのベクトル インデクシング操作がキューを経由します。これはバッチインポートだけでなく、単一オブジェクトのインポート、削除、更新にも適用されます。 + +そのため、オブジェクト ストアは迅速に更新されてユーザー リクエストを完了し、ベクトル インデックスはバックグラウンドで更新されます。非同期インデクシングは大量データのインポートで特に有用です。 + +この機能により、オブジェクト作成から HNSW インデックスでのベクトル検索が可能になるまでの間に短い遅延が発生します。ノードごとのキュー内オブジェクト数は[こちら](/deploy/configuration/nodes.md)で監視できます。 + +:::info Changes in `v1.28` +Weaviate `v1.22` から `v1.27` までは、非同期インデクシング機能はバッチインポート操作のみに影響し、インメモリキューを使用していました。 +
+ +`v1.28` 以降、この機能は単一オブジェクトのインポート、削除、更新にも拡張されました。加えて、インメモリキューは永続的なオンディスクキューに置き換えられました。この変更により、インデクシング操作の堅牢性が向上し、ロック競合とメモリ使用量の削減によってパフォーマンスも改善されます。 +
+ +オンディスクキューの使用によりディスク使用量がわずかに増加する場合がありますが、総ディスク使用量に対してはごく小さな割合であると想定されます。 +::: + +## フラット インデックス + +:::info Added in `v1.23` +::: + +**フラット インデックス**は、データベースにおけるベクトル インデックス実装の基本的な方法の一つです。その名のとおりシンプルで軽量、構築が高速でメモリ使用量もごく小さく済みます。このインデックスは、たとえば SaaS 製品や分離されたレコードセットのデータベースなど、各エンドユーザー(テナント)が独自の隔離されたデータセットを持つユースケースに適しています。 + +フラット インデックスはディスク上に 1 層でデータオブジェクトを保持するため、メモリフットプリントが非常に小さいのが特徴です。マルチテナンシー ユースケースのような小規模コレクションに適した選択肢です。 + +一方でフラット インデックスは、`hnsw` インデックスの対数時間計算量とは異なり、データオブジェクト数に対して線形時間計算量を持つため、大規模コレクションへのスケールには向きません。 + +## 動的インデックス + +:::caution Experimental feature +`v1.25` から利用可能です。これは実験的機能のため、慎重にご利用ください。 +::: + +import DynamicAsyncRequirements from '/_includes/dynamic-index-async-req.mdx'; + + + +フラット インデックスはオブジェクト数が少ないユースケースに最適で、メモリオーバーヘッドが低くレイテンシも良好です。オブジェクト数が増えるにつれて HNSW インデックスの方が検索性能面で有利になります。動的インデックスの目的は、スケール時にメモリフットプリントが大きくなる代わりにクエリ時間のレイテンシを短縮することです。 + +動的インデックスを設定すると、オブジェクト数が事前に設定した閾値(デフォルトでは 10,000 )を超えたときにフラットから HNSW インデックスへ自動的に切り替わります。この機能は非同期インデクシングが有効な場合のみ動作します。インポート中に閾値に達すると、すべてのデータが非同期キューに溜まり、バックグラウンドで HNSW インデックスが構築され、準備が整い次第フラットから HNSW へスワップされます。 + +現在のところ、これはフラットから HNSW への一方向のアップグレードのみをサポートしており、削除によってオブジェクト数が閾値を下回ってもフラットに戻すことはできません。 + +これはマルチテナント環境で特に有用です。テナントごとに HNSW インデックスを構築するとオーバーヘッドが大きくなりますが、動的インデックスを利用することで、個々のテナントが成長するとそのインデックスだけがフラットから HNSW に切り替わり、小規模テナントのインデックスはフラットのまま維持されます。 + +## ベクトル キャッシュに関する考慮事項 + +検索やインポートのパフォーマンスを最適化するには、すでにインポートされたベクトルがメモリにある必要があります。ディスクからベクトルを読み込むのはメモリ参照に比べ桁違いに遅いため、ディスク キャッシュの使用は最小限にすべきです。ただし、Weaviate ではメモリ上のベクトル数を制限できます。新しいコレクション作成時、この制限はデフォルトで 1e12 ( 1 兆)オブジェクトに設定されています。 + +インポート時には、`vectorCacheMaxObjects` を十分に大きく設定してすべてのベクトルをメモリに保持できるようにしてください。インポートでは複数回の検索が必要になるため、キャッシュに十分なメモリがない場合、インポート性能は大幅に低下します。 + +インポート後、ワークロードが主にクエリ処理になる場合は、データセット全体より小さいベクトル キャッシュ制限を試してみてください。 + +現在キャッシュにないベクトルは、空きがあればキャッシュに追加されます。キャッシュが満杯になると Weaviate はキャッシュを丸ごと破棄します。その後のすべてのベクトルは初回のみディスクから読み込まれ、以降はキャッシュがいっぱいになるまでキャッシュ経由で検索されます。この挙動は、大規模データセットで多くのユーザーが特定のサブセットのみを検索する場合に有用です。このケースでは、最大のユーザーグループに対してはキャッシュから応答し、「イレギュラー」なクエリではディスク参照を行うという運用が可能です。 + +## ベクトル インデクシング FAQ + +### ベクトル 量子化とベクトル インデクシングを併用できますか? + +はい。[ベクトル 量子化(圧縮)](../vector-quantization.md) に詳細があります。 + +### どのベクトル インデックスを選択すべきですか? + +簡単なヒューリスティックとして、各エンドユーザー(テナント)が独立したデータセットを持つ SaaS 製品のようなユースケースでは `flat` インデックスが適しています。大規模コレクションの場合は `hnsw` インデックスの方が適しているかもしれません。 + +ベクトル インデックスタイプのパラメーターは、データオブジェクトのベクトルを*どのようにインデックス化するか*を指定するだけであり、インデックスはデータ検索と類似度検索に使用されます。 + +`vectorizer` パラメーターはデータ ベクトルをどのように生成するか(ベクトルにどの数値を含めるか)を決定します。`vectorizer` には `text2vec-contextionary` などの[モジュール](/weaviate/modules/index.md)を指定します。(独自のベクトルをインポートしたい場合は `vectorizer` を `none` に設定できます)。 + +コレクションの設定方法については[こちらのハウツーページ](../../manage-collections/vector-config.mdx)をご覧ください。 + +### ベクトル インデクシングで使用できる距離メトリクスは? + +コサイン類似度など、[すべての距離メトリクス](/weaviate/config-refs/distances.md)をどのベクトル インデックスタイプでも使用できます。 + +### Weaviate でベクトル インデックスタイプをどう設定しますか? + +インデックスタイプは、[コレクション定義](../../manage-collections/vector-config.mdx#set-vector-index-type)の設定を通じてデータ コレクションごとに指定でき、利用可能な[ベクトル インデックス設定](../../config-refs/indexing/vector-index.mdx)に従います。 + +### インデックス化をスキップすべきとき + +コレクションをベクトライズする意味がない場合があります。たとえば、そのコレクションが 2 つの別コレクション間のリファレンスのみで構成されている場合や、ほとんどが重複要素である場合などです。 + +重複ベクトルを HNSW にインポートするのは非常に高コストです。インポートアルゴリズムは、候補ベクトルの距離が最悪候補の距離より大きいかを早い段階でチェックしますが、重複ベクトルが多いとこの早期終了条件が満たされず、各インポートやクエリで全探索が発生します。 + +コレクションのインデックス化を避けるには `"skip"` を `"true"` に設定します。デフォルトではコレクションはインデックス化されます。 + +### どんな ANN アルゴリズムが存在しますか? + +さまざまな ANN アルゴリズムがあり、このウェブサイトで概要をご覧いただけます。 + +### Weaviate の ANN パフォーマンスに関する参考ベンチマークはありますか? + +[ANN ベンチマークページ](/weaviate/benchmarks/ann.md)には、さまざまなベクトル検索ユースケースと相対的なベンチマークが掲載されています。類似したデータセットを探し、最適な設定を学ぶのに最適なページです。 + +## 参考リソース + +:::info Related pages +- [概念: ベクトル 量子化(圧縮)](../vector-quantization.md) +- [設定: ベクトル インデックス](../../config-refs/indexing/vector-index.mdx) +- [設定: スキーマ(セマンティック インデックスの設定)](../../config-refs/indexing/vector-index.mdx#configure-semantic-indexing) +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/interface.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/interface.md new file mode 100644 index 000000000..03027c63e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/interface.md @@ -0,0 +1,160 @@ +--- +title: インターフェース +sidebar_position: 85 +description: "Weaviate と統合するための RESTful、GraphQL、gRPC API インターフェースおよびクライアントライブラリのサポート。" +image: og/docs/concepts.jpg +# tags: ['architecture', 'interface', 'API design'] +--- + +Weaviate は、その API を通じて管理および利用できます。Weaviate には RESTful API と GraphQL API が あり、すべての言語向けクライアントライブラリは全 API 機能をサポートしています。Python クライアントなど一部のクライアントでは、完全なスキーマ管理やバッチ処理などの追加機能も提供されています。これにより、Weaviate はカスタムプロジェクトで簡単に利用でき、API も直感的で既存のデータ環境への統合が容易です。 + +このページでは、Weaviate の API 設計と、GraphQL を使用して Weaviate Console からインスタンスを検索する方法について説明します。 + +## API 設計 + +### 設計: UX と Weaviate の機能 + +ユーザーエクスペリエンス (UX) は、私たちの最も重要な原則の 1 つです。Weaviate は理解しやすく、直感的に使え、コミュニティにとって価値があり、望まれ、使いやすいものでなければなりません。その UX において Weaviate とのインタラクションは非常に重要です。Weaviate の API はユーザーニーズの観点から設計されており、ソフトウェアの機能を考慮しています。私たちはユーザーリサーチ、ユーザーテスト、プロトタイピングを行い、すべての機能がユーザーに共感されるよう努めています。共同ディスカッションを通じてユーザー要件を継続的に収集し、ユーザーニーズと Weaviate の機能を照合します。ユーザーまたはアプリケーションの観点から強い要望がある場合、Weaviate の機能や API を拡張することがあります。新しい Weaviate の機能が追加された場合、それは新しい API 機能として自然に利用可能になります。 + +Weaviate の API UX は、Peter Morville によって定義された UX ハニカムの使いやすさのルールに従って設計されています。 + +### RESTful API と GraphQL API + +Weaviate には RESTful API と GraphQL API の両方が あります。現時点では両 API 間で機能の完全なパリティはありません (後に実装予定で、GitHub 上に [issue](https://github.com/weaviate/weaviate/issues/1540) があります)。RESTful API は主に DB 管理と CRUD 操作に使用されます。GraphQL API は主に Weaviate 内のデータオブジェクトへアクセスするために使用され、単純なルックアップからスカラー検索と ベクトル 検索の組み合わせまで対応します。大まかに言えば、API は以下のユーザーニーズをサポートします: + +* **データの追加、取得、更新、削除 (CRUD)** -> RESTful API +* **Weaviate の管理操作** -> RESTful API +* **データ検索** -> GraphQL API +* **探索的データ検索** -> GraphQL API +* **データ解析 (メタデータ)** -> GraphQL API +* **本番環境での非常に大きなデータセットに対するほぼリアルタイム処理** -> クライアントライブラリ (Python、Go、Java、JavaScript) が内部で両 API を使用 +* **アプリケーションへの容易な統合** -> クライアントライブラリ (Python、Go、Java、JavaScript) が内部で両 API を使用 + +## GraphQL + +### GraphQL を採用した理由 + +GraphQL API を採用した理由は複数あります: + +* **データ構造** + * Weaviate のデータは クラス-プロパティ 構造に従います。GraphQL を使うことで、クラスとプロパティを指定してデータオブジェクトをクエリできます。 + * Weaviate ではクロスリファレンスでデータをリンクできます。この点で GraphQL のようなグラフクエリ言語が非常に有用です。 + +* **パフォーマンス** + * GraphQL ではオーバーフェッチ/アンダーフェッチがありません。クエリした分だけ正確に情報を取得でき、パフォーマンス面で有利です。 + * リクエスト数の削減。GraphQL では非常に効率的かつ精密なクエリが可能で、同じ結果を得るために従来の RESTful API で必要となる多数のクエリを減らせます。 + +* **ユーザーエクスペリエンス** + * 複雑さの軽減 + * 型付きスキーマによりエラーが起こりにくい + * カスタムデザインが可能 + * データ探索やファジー検索が可能 + +### GraphQL の設計原則 + +GraphQL クエリは直感的で Weaviate の機能に合うよう設計されています。[Hackernoon のこの記事](https://hackernoon.com/how-weaviates-graphql-api-was-designed-t93932tl) では GraphQL API がどのように設計されたかを詳しく説明しています (例は古い Weaviate と GraphQL API バージョンを示しています)。設計の鍵となる 3 点は次のとおりです: + +* **自然言語** + GraphQL クエリは可能な限り自然言語パターンに従っています。クエリの機能が理解しやすく、書きやすく覚えやすいです。以下のクエリ例では、人間の言語を認識できます: 「*Get* the *title* of the *Articles* where the *wordcount* is *greater than* *1000*」。このクエリの最も重要な語が GraphQL クエリにも使われています: + +```graphql +{ + Get { + Article(where: { + path: ["wordCount"], # Path to the property that should be used + operator: GreaterThan, # operator + valueInt: 1000 # value (which is always = to the type of the path property) + }) { + title + } + } +} +``` + +現在、GraphQL リクエストには主に `Get{}`、`Explore{}`、`Aggregate{}` の 3 つの関数があります。 + +* **クラスとプロパティ** + Weaviate のデータは クラス-プロパティ 構造を持ち、データオブジェクト間にクロスリファレンスが存在する場合があります。返すデータのクラス名は「メイン関数」の 1 階層下に書かれます。次の階層には、クラスごとに返すプロパティとクロスリファレンスプロパティを記述します: + +```graphql +{ + { + { + + + { + ... on { + + } + } + + _ { + + } + } + } +} +``` + +* **データベース設定に依存するクエリフィルター (検索引数)** + オブジェクトをフィルターするためにクラスレベルでフィルターを追加できます。スカラー (`where` フィルター) と ベクトル (`near<...>`) フィルターを組み合わせることが可能です。Weaviate のセットアップ (接続しているモジュール) に応じて、追加のフィルターが使用できます。以下は [`qna-transformers` モジュール](/weaviate/modules/qna-transformers.md) を使用したフィルターの例です: + +```graphql +{ + Get { + Article( + ask: { + question: "Who is the king of the Netherlands?", + properties: ["summary"] + }, + limit: 1 + ) { + title + _additional { + answer { + result + } + } + } + } +} +``` + +### GraphQL メイン関数の設計 + +1. **データ検索: `Get {}`** + データオブジェクトのクラス名が分かっている場合に検索します。 +2. **探索的 & ファジー検索: `Explore {}`** + データスキーマやクラス名が分からない場合にファジー検索を行います。 +3. **データ解析 (メタデータ): `Aggregate {}`** + メタデータを検索し、データ集計の解析を行います。 + +## gRPC API サポート + +バージョン `1.19` から、Weaviate は gRPC (gRPC Remote Procedure Calls) API のサポートを導入し、時間とともにさらに高速化を図っています。 + +これによりユーザー向け API の変更は発生しません。2023 年 5 月時点で、gRPC はごく小規模に追加されており、今後コアライブラリおよびクライアントへの展開が予定されています。 + +## Weaviate Console + +[Weaviate Console](https://console.weaviate.cloud) は、WCD から Weaviate クラスターを管理し、他の場所で稼働する Weaviate インスタンスへアクセスするためのダッシュボードです。GraphQL クエリを実行するために Query Module を使用できます。 + +![GraphQL Query Module in Weaviate Console](./img/console-capture.png) + +## Weaviate クライアント + +Weaviate には [Go](/weaviate/client-libraries/go.md)、[Java](/weaviate/client-libraries/java.md)、[Python](/weaviate/client-libraries/python/index.mdx)、[TypeScript/JavaScript](/weaviate/client-libraries/typescript/index.mdx) のクライアントライブラリがあります。すべての言語向けクライアントライブラリは全 API 機能をサポートしています。一部のクライアント (例: Python クライアント) では、完全なスキーマ管理やバッチ処理などの追加機能も提供されています。これにより、Weaviate はカスタムプロジェクトで簡単に利用でき、API も直感的なため既存のデータ環境への統合が容易です。 + +## さらなるリソース +:::info 関連ページ +- [リファレンス: GraphQL API](../api/graphql/index.md) +- [リファレンス: RESTful API](/weaviate/api/rest) +- [リファレンス: クライアントライブラリ](../client-libraries/index.mdx) +::: + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/modules.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/modules.md new file mode 100644 index 000000000..2650abd73 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/modules.md @@ -0,0 +1,71 @@ +--- +title: モジュール +sidebar_position: 15 +description: "特化したアドオンコンポーネントで Weaviate の機能を拡張するためのモジュラーアーキテクチャの概要。" +image: og/docs/concepts.jpg +# tags: ['modules'] +--- + + + Weaviate にはモジュール化された構造があります。ベクトル化やバックアップなどの機能は、*オプション* のモジュールによって処理されます。 + +モジュールを一切付与しない Weaviate のコアは、純粋なベクトルネイティブデータベースです。 +[![Weaviate モジュールの紹介](./img/weaviate-module-diagram.svg "Weaviate モジュール図")](./img/weaviate-module-diagram.svg) + +データはオブジェクトとそのベクトルの組み合わせとして Weaviate に保存され、これらのベクトルは提供された [ベクトルインデックスアルゴリズム](../concepts/indexing/vector-index.md) によって検索可能です。ベクトライザーモジュールが付与されていない場合、 Weaviate はオブジェクトを *vectorize* する、すなわちオブジェクトからベクトルを計算する方法を知りません。 + +保存・検索したいデータの種類(テキスト、画像など)やユースケース(検索、質問応答など)、言語、分類、ML モデル、学習データセットなどに応じて、最適なベクトライザーモジュールを選択して付与できます。または、自前のベクトルを Weaviate に持ち込むことも可能です。 + +このページでは、モジュールとは何か、そして Weaviate でどのような役割を果たすのかを説明します。 + + +## 利用可能なモジュールタイプ + +次の図は、最新の Weaviate バージョン (||site.weaviate_version||) で利用できるモジュールを示しています。モジュールは以下のカテゴリに分かれます。 + +- ベクトル化モジュール +- ベクトル化と追加機能を備えたモジュール +- その他のモジュール + +![Weaviate module ecosystem](./img/weaviate-modules.png "Weaviate module ecosystem") + +### ベクトライザー & ランカーモジュール + +`text2vec-*`、`multi2vec-*`、`img2vec-*` などのベクトライザーモジュールはデータをベクトルへ変換します。`rerank-*` などのランカーモジュールは、検索結果をランク付けします。 + +### リーダー & ジェネレーターモジュール + +リーダーまたはジェネレーターモジュールは、ベクトライザーモジュールの上に重ねて使用できます。これらのモジュールは取得した関連ドキュメント集合に対してさらなる処理を行い、質問応答や生成タスクなどを実行します。例としては、ドキュメントから直接回答を抽出する [`qna-transformers`](../modules/qna-transformers.md) モジュールがあります。ジェネレーターモジュールは、言語生成を用いて与えられたドキュメントから回答を生成します。 + +### その他のモジュール + +`gcs-backup` や `text-spellcheck` などが該当します。 + +## 依存関係 + +モジュールは他のモジュールへの依存関係を持つ場合があります。たとえば、[`qna-transformers`](../modules/qna-transformers.md) モジュールを使用するには、*正確に 1 つ* のテキストベクトル化モジュールが必要です。 + +## モジュールを使用しない Weaviate + + Weaviate は、モジュールなしでも純粋なベクトルネイティブデータベース兼検索エンジンとして利用できます。モジュールを含めない場合は、各データエントリーに対してベクトルを入力する必要があります。その後、ベクトル検索によってオブジェクトを検索できます。 + +## カスタムモジュール + +誰でも Weaviate で使用できるカスタムモジュールを作成可能です。作成方法と利用方法は [こちら](../modules/custom-modules.md) をご覧ください。 + +## さらなるリソース + +:::info Related pages +- [設定: モジュール](../configuration/modules.md) +- [リファレンス: モジュール](../modules/index.md) +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/_category_.json new file mode 100644 index 000000000..4cf28198b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Replication Architecture", + "position": 35 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/cluster-architecture.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/cluster-architecture.md new file mode 100644 index 000000000..e26a24115 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/cluster-architecture.md @@ -0,0 +1,129 @@ +--- +title: クラスターアーキテクチャ +sidebar_position: 3 +description: "Weaviate の分散レプリケーションシステムにおけるノードの挙動とクラスター調整メカニズム。" +image: og/docs/concepts.jpg +# tags: ['architecture'] +--- + +このページでは、 Weaviate のレプリケーション設計においてノードやクラスターがどのように動作するかを説明します。 + +Weaviate では、メタデータのレプリケーションとデータのレプリケーションが分離されています。メタデータには Raft コンセンサスアルゴリズムを使用し、データのレプリケーションにはリーダーレス設計と最終的整合性を採用しています。 + +## ノードディスカバリー + +デフォルトでは、クラスター内の Weaviate ノードは [Hashicorp の Memberlist](https://github.com/hashicorp/memberlist) を介したゴシップ風プロトコルを使用し、ノード状態や障害シナリオを共有します。 + +Weaviate はクラスターとして動作する際、特に Kubernetes 上での運用に最適化されています。 [Weaviate Helm chart](/deploy/installation-guides/k8s-installation.md#weaviate-helm-chart) は `StatefulSet` とヘッドレス `Service` を利用し、ノードディスカバリーを自動的に構成します。 + +
+ ノードディスカバリーにおける FQDN + +:::caution `v1.25.15` で追加、`v1.30` で削除 + +これは実験的機能です。ご利用の際はご注意ください。 + +::: + +IP アドレスベースのノードディスカバリーが最適でない状況が発生することがあります。そのような場合、 `RAFT_ENABLE_FQDN_RESOLVER` と `RAFT_FQDN_RESOLVER_TLD` [環境変数](/deploy/configuration/env-vars/index.md#multi-node-instances) を設定することで、[完全修飾ドメイン名 (FQDN)](https://en.wikipedia.org/wiki/Fully_qualified_domain_name) ベースのノードディスカバリーを有効化できます。 + +この機能を有効にすると、 Weaviate は FQDN リゾルバーを使用してノード名を IP アドレスへ解決し、メタデータ (例: Raft 通信) に利用します。 + +:::info FQDN: メタデータ変更のみ対象 +この機能は、 Raft をコンセンサスメカニズムとして用いるメタデータ変更時にのみ使用されます。データの読み書き操作には影響しません。 +::: + +#### FQDN を使用すべき例 + +IP アドレスが異なるクラスター間で再利用される場合、あるクラスターのノードが別クラスターのノードを誤って検出してしまう恐れがあります。 FQDN を用いることでこれを回避できます。 + +また、サービス (例: Kubernetes) を利用しており、サービスの IP と実際のノード IP が異なるが、サービスがノードへの接続をプロキシしている場合にも便利です。 + +#### FQDN ノードディスカバリー用環境変数 + +`RAFT_ENABLE_FQDN_RESOLVER` は Boolean フラグで、 FQDN リゾルバーの有効/無効を切り替えます。 `true` に設定すると、 Weaviate は FQDN リゾルバーでノード名を IP アドレスへ解決します。 `false` の場合、 Memberlist ルックアップを使用します。デフォルトは `false` です。 + +`RAFT_FQDN_RESOLVER_TLD` は文字列で、ノード ID を IP アドレスに解決する際 `[node-id].[tld]` の形式で `[tld]` (トップレベルドメイン) を付加します。 + +この機能を利用するには、 `RAFT_ENABLE_FQDN_RESOLVER` を `true` に設定してください。 + +
+ +## メタデータレプリケーション: Raft + +:::info `v1.25` で追加 +::: + +Weaviate はメタデータのレプリケーションに [Raft コンセンサスアルゴリズム](https://raft.github.io/) を使用し、 Hashicorp の [raft ライブラリ](https://pkg.go.dev/github.com/hashicorp/raft) で実装しています。ここでのメタデータは、コレクション定義やシャード/テナントの状態を指します。 + +Raft はクラスター全体でメタデータ変更の整合性を保証します。メタデータの変更はリーダーノードに転送され、リーダーが自ノードのログに適用した後、フォロワーノードへ複製します。過半数のノードが変更を承認すると、リーダーはログへコミットし、フォロワーへ通知します。フォロワーは通知を受け取り、自身のログへ変更を適用します。 + +この仕組みにより、少数のノード障害が発生してもクラスター全体でメタデータの一貫性が保たれます。 + +その結果、 Weaviate クラスターにはメタデータ変更を担当するリーダーノードが存在します。リーダーは Raft アルゴリズムによって選出され、メタデータ変更の調整を担います。 + +## データレプリケーション: リーダーレス + +Weaviate はデータレプリケーションにリーダーレスアーキテクチャを採用しています。つまり、フォロワーノードへ複製を行う中央のリーダーやプライマリノードは存在しません。すべてのノードがクライアントからの書き込み・読み取りを受け付けられるため、高い可用性を実現します。単一障害点がないのが特徴です。リーダーレスレプリケーションは、[Dynamo 方式](https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf) のデータレプリケーションとしても知られ、 [Apache Cassandra](https://cassandra.apache.org) などの OSS プロジェクトでも採用されています。 + +Weaviate では、クライアントの読み書き要求を適切なノードへ中継するコーディネーションパターンを使用しています。リーダーベースのデータベースとは異なり、コーディネーターノードは操作順序を強制しません。 + +以下の図は、 Weaviate におけるリーダーレスレプリケーション設計を示しています。 1 つのコーディネーターノードがクライアントからのトラフィックを正しいレプリカへ導きます。このノードには特別な役割はなく、単にロードバランサーからリクエストを受け取ったためにコーディネーターとなっただけです。同じデータに対する次のリクエストは、別のノードがコーディネートする可能性があります。 + +

レプリケーションアーキテクチャ

+ +リーダーレスレプリケーションの主な利点は、耐障害性の向上です。すべてのリクエストを処理するリーダーが存在しないため、可用性が高まります。シングルリーダー設計では、書き込みは必ずリーダーで処理されるため、そのノードがダウンすると書き込みができなくなります。リーダーレス設計ではすべてのノードが書き込みを受け付けるため、マスターノード障害のリスクがありません。 + +高い可用性の反面、リーダーレスデータベースは整合性が低下しがちです。リーダーノードが存在しないため、ノード間で一時的にデータが古くなる可能性があります。リーダーレスデータベースは最終的整合性に向かう傾向があります。 Weaviate では整合性を [調整可能](./consistency.md) ですが、その分可用性を犠牲にします。 + +## レプリケーションファクター + +import RaftRFChangeWarning from '/_includes/1-25-replication-factor.mdx'; + + + +Weaviate では、データのレプリケーションはコレクション単位で有効化および制御されます。そのため、コレクションごとに異なるレプリケーションファクターを設定できます。 + +レプリケーションファクター (RF または n) は、分散環境でデータが何個複製されるかを決定します。レプリケーションファクターが 1 の場合、各データエントリは 1 つしか存在せず、レプリケーションは行われません。レプリケーションファクターが 2 の場合、各データエントリは 2 つの異なるノード (レプリカ) に複製されます。当然ながら、レプリケーションファクターはノード数を超えることはできません。クラスター内のどのノードもコーディネーターノードとして機能し、クエリを適切なターゲットノードへ導けます。 + +レプリケーションファクター 3 は、パフォーマンスと耐障害性のバランスが取れているため一般的に使用されます。奇数ノード数が推奨されるのは、競合解決が容易になるためです。 3 ノード構成では、 2 ノードでクォーラムを達成でき、耐障害性は 1 ノードとなります。一方 2 ノード構成では、コンセンサス達成中にノード障害を許容できません。 4 ノード構成では、 3 ノードが必要になります。したがって、 3 ノード構成は 2 ノードや 4 ノードよりコスト対耐障害性の比率が優れています。 + +

レプリケーションファクター

+ +## 書き込み操作 + +書き込み操作では、クライアントのリクエストがクラスター内の任意のノードに送信されます。最初にリクエストを受け取ったノードがコーディネーターノードとして割り当てられます。コーディネーターノードはリクエストをあらかじめ定義された複数のレプリカノードへ送信し、結果をクライアントへ返します。そのため、クラスター内のどのノードもコーディネーターノードになり得ます。クライアントはこのコーディネーターノードとだけ直接通信します。結果を返す前に、コーディネーターノードは設定に応じた数の書き込み ACK を待ちます。 Weaviate がいくつの ACK を待つかは [整合性設定](./consistency.md) に依存します。 + +**手順** +1. クライアントがデータを任意のノードに送信し、そのノードがコーディネーターノードとなる +2. コーディネーターノードがデータを複数のレプリカノードへ送信する +3. コーディネーターノードは、クラスターノードの指定割合 (ここでは `x`) から ACK を待機する。 v1.18 以降、 `x` は [設定可能](./consistency.md) で、デフォルトは `ALL` +4. `x` 件の ACK を受け取ると、書き込みは成功する + +例として、クラスターサイズ 3・レプリケーションファクター 3 の場合を考えます。この場合、すべてのノードがデータのコピーを保持します。クライアントが新しいデータを送信すると、 3 ノードすべてに複製されます。 + +

クラスターサイズ 3 におけるレプリケーションファクター 3

+ +クラスターサイズ 8・レプリケーションファクター 3 の場合、書き込みは 8 ノードすべてではなく、該当レプリカを保持する 3 ノードのみに送信されます。コーディネーターノードがどのノードに書き込むかを決定します。どのノードがどのコレクション (およびシャード) を保持するかは Weaviate のセットアップで決定され、各ノード (すなわち各コーディネーターノード) が把握しています。どこに複製されるかは決定論的であり、すべてのノードがどのシャードにどのデータが入るかを認識しています。 + +

クラスターサイズ 8 におけるレプリケーションファクター 3

+ +## 読み取り操作 + +読み取り操作もコーディネーターノードによって調整され、クエリはデータを保持している適切なノードへ送信されます。一部のノードが古い (スタイル) データを保持している可能性があるため、読み取りクライアントは受け取ったデータのうち最新のものを選択してユーザーへ返します。 + +**手順** +1. クライアントが Weaviate にクエリを送信し、最初に受信したノードがコーディネーターノードとなる +2. コーディネーターノードがクエリを複数のレプリカノードへ送信する +3. コーディネーターノードは x ノードからのレスポンスを待つ。 *x は [設定可能](./consistency.md) (`ALL`, `QUORUM`, `ONE`、 v1.18 以降。 Get-Object-By-ID 形式のリクエストは v1.17 から調整可能)* +4. コーディネーターノードがメタデータ (例: タイムスタンプ、ID、バージョン番号) を用いて競合データを解決する +5. コーディネーターノードが最新のデータをクライアントへ返す + +クラスターサイズ 3、レプリケーションファクター 3 の場合、すべてのノードがクエリを処理できます。整合性レベルが、何ノードへクエリを送信するかを決定します。 + +クラスターサイズ 10、レプリケーションファクター 3 の場合、該当データ (コレクション) を保持する 3 ノードがクエリを処理し、コーディネーターノードがそれを調整します。クライアントは x (整合性レベル) ノードから応答を受け取るまで待機します。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/consistency.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/consistency.md new file mode 100644 index 000000000..5ad2464dc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/consistency.md @@ -0,0 +1,377 @@ +--- +title: 一貫性 +sidebar_position: 4 +description: " Weaviate クラスター内のレプリカ間でのレプリケーションファクター設定とデータ整合性モデル。" +image: og/docs/concepts.jpg +# tags: ['architecture'] +--- + +import SkipLink from '/src/components/SkipValidationLink' + + Weaviate におけるレプリケーションファクターは、シャード(レプリカとも呼ばれます)のコピーをクラスター全体にいくつ保持するかを決定します。 + +

Replication factor

+ +レプリケーションファクターが > 1 になると、整合性モデルはシステムの信頼性、スケーラビリティ、パフォーマンス要件のバランスを取ります。 + + Weaviate は複数の整合性モデルを使用します。クラスター メタデータ用とデータオブジェクト用で、それぞれ異なるモデルです。 + +### Weaviate における整合性モデル + + Weaviate は [Raft](https://raft.github.io/) コンセンサスアルゴリズムを使用して [クラスター メタデータのレプリケーション](./cluster-architecture.md#metadata-replication-raft) を行います。ここでのクラスター メタデータには、コレクション定義やテナントのアクティビティ ステータスが含まれます。これにより、一部ノードがダウンしていてもメタデータを更新できます。 + +データオブジェクトは、[リーダーレス設計](./cluster-architecture.md#data-replication-leaderless) と調整可能な整合性レベルを用いてレプリケートされます。そのため、データ操作をより一貫性重視にも可用性重視にも調整でき、望ましいトレードオフを実現できます。 + +これらの設計は、[CAP 定理](./index.md#cap-theorem) で説明される整合性と可用性のトレードオフを反映しています。 + +:::tip 整合性に関する経験則 +整合性の強さは、次の条件で判断できます。 +* r + w > n の場合、システムは強い整合性を持ちます。 + * r は読み取り操作の整合性レベル + * w は書き込み操作の整合性レベル + * n はレプリケーションファクター(レプリカ数) +* r + w <= n の場合、このシナリオで到達できるのは最終的な整合性です。 +::: + +## クラスター メタデータ + +クラスター メタデータは Raft アルゴリズムを使用します。 + + `v1.25` 以降、 Weaviate はクラスター メタデータのレプリケーションに [Raft](https://raft.github.io/) コンセンサスアルゴリズムを採用しています。Raft はリーダー選出型のコンセンサス アルゴリズムで、ログベースの方式によりクラスター全体へレプリケーションを調整します。 + +その結果、クラスター メタデータを変更するリクエストはすべてリーダーノードへ送信されます。リーダーノードは自分のログに変更を適用した後、フォロワーノードへ変更を伝播します。ノードの過半数が変更を承認すると、リーダーノードが変更をコミットし、クライアントへ確定を返します。 + +このアーキテクチャにより、少数のノード障害が発生してもクラスター全体でメタデータの整合性が保たれます。 + +
+ v1.25 以前のクラスター メタデータ コンセンサス アルゴリズム + +Raft を導入する前は、クラスター メタデータの更新は [分散トランザクション](https://en.wikipedia.org/wiki/Distributed_transaction) アルゴリズムで実施していました。これは分散ネットワーク上の複数ノードのデータベースを横断して一連の操作を行う手法です。 Weaviate では [2 フェーズコミット (2PC)](https://en.wikipedia.org/wiki/Two-phase_commit_protocol) プロトコルを使用し、ミリ秒単位でクラスター メタデータをレプリケートしていました。 + +フェイルがない正常実行では 2 つのフェーズがあります。 +1. コミット要求フェーズ(投票フェーズ): コーディネーターノードが各ノードへ更新を受け取り処理できるかを確認します。 +2. コミットフェーズ: コーディネーターノードが各ノードへ変更をコミットします。 + +
+ +### クエリにおけるコレクション定義の取得 + +:::info `v1.27.10`, `v1.28.4` で追加 +::: + +一部のクエリではコレクション定義が必要です。この機能導入前は、そのようなクエリのたびにローカルノードがリーダーノードから定義を取得していました。これにより整合性は強く保たれますが、トラフィックと負荷が増加する可能性がありました。 + +対応している場合、`COLLECTION_RETRIEVAL_STRATEGY` [環境変数](/deploy/configuration/env-vars/index.md#multi-node-instances) に `LeaderOnly`、`LocalOnly`、`LeaderOnMismatch` を設定できます。 + +- `LeaderOnly` (デフォルト): 常にリーダーノードから定義を取得します。最も整合性が高い一方、クラスター内部トラフィックが増える可能性があります。 +- `LocalOnly`: 常にローカルの定義を使用します。最終的な整合性となりますが、クラスター内部トラフィックを削減できます。 +- `LeaderOnMismatch`: ローカル定義が古いかをチェックし、必要に応じてリーダーから取得します。整合性とトラフィックのバランスを取ります。 + +デフォルトは強い整合性を得るため `LeaderOnly` です。ただし、`LocalOnly` や `LeaderOnMismatch` を用いることで、望ましい整合性レベルに応じてトラフィックを削減できます。 + +## データオブジェクト + + Weaviate はデータオブジェクトに対して、整合性レベルに応じて調整された 2 フェーズコミットを使用します。たとえば `QUORUM` 書き込み(後述)の場合、5 ノードが存在すると 3 件のリクエストが送信され、それぞれが内部で 2 フェーズコミットを実行します。 + +その結果、 Weaviate のデータオブジェクトは最終的に整合性が取られます。最終的な整合性は BASE セマンティクスを提供します。 + +* **Basically available**: 読み取りおよび書き込み操作は可能な限り利用可能 +* **Soft-state**: 更新がまだ収束していないため整合性保証はありません +* **Eventually consistent**: システムが十分に長く稼働し書き込みが行われた後、すべてのノードが整合性を持つようになります + + Weaviate は可用性向上のため最終的な整合性を採用しています。読み取りと書き込みの整合性は調整可能で、アプリケーション要件に合わせて可用性と整合性のトレードオフを選択できます。 + +*下のアニメーションは、レプリケーションファクター 3、ノード数 8 の環境で `QUORUM` 整合性を設定した書き込みまたは読み取りの例です。青色のノードがコーディネーターノードとして動作します。`QUORUM` が設定されているため、コーディネーターノードは 3 件中 2 件のレスポンスを受け取った時点でクライアントへ結果を返します。* + +

Write consistency QUORUM

+ +### 書き込み整合性の調整 + +データオブジェクトの追加または変更は **書き込み** 操作です。 + +:::note +書き込み操作の整合性は、 Weaviate v1.18 から `ONE`、`QUORUM`(デフォルト)、`ALL` に調整できます。 v1.17 では書き込み整合性は常に `ALL`(最高整合性)です。 +::: + +書き込み整合性を設定可能にした主な理由は、 v1.18 で自動修復が導入されたためです。書き込みは選択した整合性レベルにかかわらず n(レプリケーションファクター) ノードに対して必ず行われます。ただしコーディネーターノードが待機する ACK 数が `ONE`、`QUORUM`、`ALL` で異なります。読み取りリクエストでの修復機能がない状況で、すべてのノードに確実に書き込みを適用するため、 v1.17 までは書き込み整合性が `ALL` に固定されていました。 v1.18 以降の設定は以下のとおりです: +* **ONE** - 少なくとも 1 つのレプリカから ACK を受け取れば書き込み完了とみなします。最も高速(高可用性)ですが、整合性は最低です。 +* **QUORUM** - 少なくとも `QUORUM` レプリカから ACK を受け取る必要があります。`QUORUM` は _n / 2 + 1_ で計算されます(_n_ はレプリカ数)。例: レプリケーションファクター 6 ではクォーラムは 4 で、2 レプリカのダウンに耐えられます。 +* **ALL** - すべてのレプリカから ACK を受け取る必要があります。最も整合性が高いですが、最も遅く(低可用性)な選択肢です。 + +*下図: レプリケーションファクター 3、ノード数 8、書き込み整合性 `ONE` の Weaviate レプリケート構成。* + +

Write consistency ONE

+ +*下図: レプリケーションファクター 3、ノード数 8、書き込み整合性 `QUORUM`(n/2+1)の構成。* + +

Write consistency QUORUM

+ +*下図: レプリケーションファクター 3、ノード数 8、書き込み整合性 `ALL` の構成。* + +

Write consistency ALL

+ +### 読み取り整合性の調整 + +読み取り操作は Weaviate のデータオブジェクトに対する GET リクエストです。書き込みと同様、読み取り整合性も `ONE`、`QUORUM`(デフォルト)、`ALL` に調整可能です。 + +:::note +`v1.18` 以前は、[ID でオブジェクトを取得するリクエスト](../../manage-objects/read.mdx#get-an-object-by-id) にのみ整合性レベルを設定でき、それ以外の読み取りリクエストはすべて `ALL` でした。 +::: + +以下の整合性レベルはほとんどの読み取り操作に適用されます。 + +- `v1.18` 以降、REST エンドポイントで整合性レベルを指定できます。 +- `v1.19` 以降、GraphQL `Get` リクエストでも整合性レベルを指定できます。 +- すべての gRPC ベースの読み書き操作は調整可能な整合性レベルをサポートします。 + +* **ONE** - 少なくとも 1 つのレプリカからレスポンスが得られれば読み取り完了とみなします。最も高速(高可用性)ですが、整合性は最低です。 +* **QUORUM** - `QUORUM` 数のレプリカからレスポンスが必要です。`QUORUM` は _n / 2 + 1_ で計算されます。例: レプリケーションファクター 6 ではクォーラムは 4 で、2 レプリカのダウンに耐えられます。 +* **ALL** - すべてのレプリカからレスポンスを受け取る必要があります。少なくとも 1 つのレプリカが応答しないと読み取りは失敗します。最も整合性が高いですが、最も遅い(低可用性)選択肢です。 + +例: +* **ONE** + 単一データセンターでレプリケーションファクター 3、読み取り整合性 `ONE` の場合、コーディネーターノードは 1 つのレプリカからのレスポンスを待ちます。 + +

Write consistency ONE

+ +* **QUORUM** + 単一データセンターでレプリケーションファクター 3、読み取り整合性 `QUORUM` の場合、コーディネーターノードは n / 2 + 1 = 3 / 2 + 1 = 2 つのレプリカからレスポンスを待ちます。 + +

Write consistency QUORUM

+ +* **ALL** + 単一データセンターでレプリケーションファクター 3、読み取り整合性 `ALL` の場合、コーディネーターノードは 3 つすべてのレプリカからレスポンスを待ちます。 + +

Write consistency ALL

+### 調整可能な一貫性戦略 + +一貫性と速度のトレードオフに応じて、以下に書き込み / 読み取り操作の一般的な一貫性レベルの組み合わせを示します。これらは最終的な一貫性を保証するための _最小_ 要件です: +* `QUORUM` / `QUORUM` => 書き込みと読み取りのレイテンシがバランス +* `ONE` / `ALL` => 書き込みが高速、読み取りが低速 (書き込み最適化) +* `ALL` / `ONE` => 書き込みが低速、読み取りが高速 (読み取り最適化) + +### 調整可能な一貫性とクエリ + +読み取り操作における調整可能な一貫性レベルは、クエリで返されるオブジェクト一覧の一貫性には影響しません。言い換えると、クエリで返されるオブジェクトの UUID 一覧は、コーディネーターノード (および必要に応じたその他のシャード) のローカルインデックスのみに依存し、読み取り一貫性レベルとは無関係です。 + +これは、各クエリがコーディネーターノードと、クエリを解決するために必要な他のシャードによって実行されるためです。読み取り一貫性レベルを `ALL` に設定しても、複数のレプリカにクエリを発行して結果をマージするわけではありません。 + +読み取り一貫性レベルが適用されるのは、特定されたオブジェクトをレプリカから取得する際です。たとえば、読み取り一貫性レベルを `ALL` に設定すると、コーディネーターノードはすべてのレプリカからオブジェクトが返されるのを待ちます。`ONE` に設定した場合、コーディネーターノードは自身だけからオブジェクトを返すことがあります。 + +つまり、読み取り一貫性レベルは取得されるオブジェクトのバージョンには影響しますが、クエリ結果をより (あるいはより少なく) 一貫性のあるものにするわけではありません。 + +:::note いつ発生する可能性がありますか? +デフォルトでは、Weaviate は挿入 / 更新 / 削除時にすべてのノードへ書き込みを行います。そのため、ほとんどの場合すべてのシャードは同一のローカルインデックスを持ち、この問題は発生しません。これはノードがダウンしている、ネットワークに問題があるなどの稀なケースでのみ発生します。 +::: + +### テナント状態とデータオブジェクト + +[マルチテナントコレクション](../data.md#multi-tenancy) では、各テナントに設定可能な [テナント状態](../../starter-guides/managing-resources/tenant-states.mdx) があり、データの可用性と配置を決定します。テナント状態は `active`, `inactive`, `offloaded` に設定できます。 + +`active` テナントのデータはクエリと更新が可能であるはずですが、`inactive` や `offloaded` テナントはそうではありません。 + +しかし、テナント状態が変更されてから、データがその (宣言的な) テナント状態を反映するまでに遅延が発生する場合があります。 + +その結果、テナント状態が `inactive` や `offloaded` に設定されていても、一定期間データがクエリ可能である場合があります。逆に、`active` に設定されていても、一定期間データがクエリや更新に利用できない場合があります。 + +:::info なぜ repair-on-read で解決されないのですか? +速度を優先するため、テナントに対するデータ操作はテナントのアクティビティ状態操作とは独立して行われます。そのため、テナント状態は repair-on-read 操作では更新されません。 +::: + +## 修復 + +Weaviate のような分散システムでは、ネットワーク問題、ノード障害、タイミング競合などによりオブジェクトレプリカが不整合になることがあります。Weaviate はレプリカ間で不整合を検出すると、同期していないデータを修復しようとします。 + +Weaviate は [非同期レプリケーション](#async-replication)、[削除解決](#deletion-resolution-strategies)、[repair-on-read](#repair-on-read) の各戦略を用いてレプリカ間の一貫性を維持します。 + +### 非同期レプリケーション + +:::info `v1.26` で追加 +::: + +非同期レプリケーションは、同じデータを保持するノード間で最終的な一貫性を確保する Weaviate のバックグラウンド同期プロセスです。各シャードが複数ノードにレプリケートされる場合、非同期レプリケーションは定期的にデータを比較・伝播し、すべてのノードが同期を保つよう保証します。 + +このプロセスでは Merkle ツリー (ハッシュツリー) アルゴリズムを使用してクラスタ内ノードの状態を監視・比較します。不整合が検出されると、対象ノードのデータを再同期します。 + +repair-on-read は 1 つまたは 2 つの孤立した修復には効果的ですが、非同期レプリケーションは多数の不整合が存在する状況で効果を発揮します。たとえばオフラインノードが複数の更新を逃した場合、ノードが復旧すると非同期レプリケーションが迅速に一貫性を回復します。 + +非同期レプリケーションは repair-on-read を補完します。同期チェックの合間にノードが不整合になった場合、repair-on-read が読み取り時に問題を検知します。 + +非同期レプリケーションを有効化するには、コレクション定義の [`replicationConfig` セクション](../../manage-collections/multi-node-setup.mdx#replication-settings) で `asyncEnabled` を true に設定します。利用可能な設定の詳細は [How-to: Replication](/deploy/configuration/replication.md#async-replication-settings) を参照してください。 + +#### 非同期レプリケーションのメモリおよびパフォーマンスの考慮事項 + +:::info `v1.29` で追加 +::: + +非同期レプリケーションは、オブジェクトの最新更新時間に基づき、ハッシュツリーを用いてクラスタノード間でデータを比較・同期します。この処理に必要な追加メモリは、ハッシュツリーの高さ `H` によって決まります。ツリーが高いほどメモリ消費は増えますが、ハッシュが高速化され、不整合の検出・修復時間が短縮されます。 + +トレードオフは次のとおりです: + - **高い** `H`: メモリ使用量が多いが、レプリケーションが速い + - **低い** `H`: メモリ使用量が少ないが、レプリケーションが遅い + +:::tip マルチテナンシーにおけるメモリ管理 +各テナントはシャードによってバックアップされています。そのため、テナント数が多い場合、非同期レプリケーションのメモリ消費は大きくなります。(例: 1,000 テナントでハッシュツリーの高さが 16 の場合、ノードあたり約 2 GB の追加メモリが必要ですが、高さ 20 ではノードあたり約 34 GB が必要になります) +
+ +メモリ消費を抑えるにはハッシュツリーの高さを下げてください。ただし、その分ハッシュ処理が遅くなり、レプリケーションも遅くなる可能性があります。 +::: + +クイックリファレンスとして、以下の計算式と例を利用してください。 + +##### メモリ計算 + +- **ハッシュツリー内の総ノード数:** + 高さ `H` のハッシュツリーにおける総ノード数は次のとおりです: + ``` + Number of hash tree nodes = 2^(H+1) - 1 ≈ 2^(H+1) + ``` + +- **必要な総メモリ (各ノードの各シャード / テナント):** + 各ハッシュツリーノードは約 **16 バイト** のメモリを使用します。 + ``` + Memory Required ≈ 2^(H+1) * 16 bytes + ``` + +##### 例 + +- 高さ `16` のハッシュツリー: + - `総ノード数 ≈ 2^(16+1) = 131,072` + - `必要メモリ ≈ 131072 * 16 bytes ≈ 2,097,152 bytes (~2 MB)` + +- 高さ `20` のハッシュツリー: + - `総ノード数 ≈ 2^(20+1) = 2,097,152` + - `必要メモリ ≈ 2,097,152 * 16 bytes ≈ 33,554,432 bytes (~33 MB)` + +##### パフォーマンスの考慮: 葉ノードの数 + +シャード (例: テナント) 内のオブジェクトはハッシュツリーの葉ノードに分散されます。ツリーが大きいほど、各葉ノードがハッシュするデータ量が減り、比較とレプリケーションが高速化されます。 + +- **ハッシュツリーの葉ノード数:** + ``` + Number of leaves = 2^H + ``` + +##### 例 + +- 高さ `16` のハッシュツリー: + - `葉ノード数 = 2^16 = 65,536` + +- 高さ `20` のハッシュツリー: + - `葉ノード数 = 2^20 = 1,048,576` + +:::note デフォルト設定 +デフォルトのハッシュツリー高さ `16` は、メモリ消費とレプリケーション性能のバランスを取るために選定されています。クラスタノードの利用可能リソースと性能要件に応じて調整してください。 +::: + +### 削除解決戦略 + +:::info `v1.28` で追加 +::: + +オブジェクトが一部のレプリカに存在し、別のレプリカには存在しない場合、それは作成がまだ全レプリカに伝播されていないか、削除がまだ全レプリカに伝播されていないかのいずれかです。この 2 つを区別することが重要です。 + +削除解決は、非同期レプリケーションおよび repair-on-read と連携し、クラスタ全体で削除されたオブジェクトを一貫して扱います。各コレクションに対して、以下の削除解決戦略のいずれかを [設定できます](../../manage-collections/multi-node-setup.mdx#replication-settings): + +- `NoAutomatedResolution` +- `DeleteOnConflict` +- `TimeBasedResolution` + +削除解決戦略は可変です。[コレクション定義の更新方法](../../manage-collections/collection-operations.mdx#update-a-collection-definition) を参照してください。 +#### `NoAutomatedResolution` + +これはデフォルト設定であり、 `v1.28` より前の Weaviate バージョンで利用できる唯一の設定です。このモードでは、削除の競合を特別扱いしません。あるオブジェクトが一部のレプリカに存在し、他のレプリカに存在しない場合、Weaviate は欠落しているレプリカに対してオブジェクトを復元する可能性があります。 + +#### `DeleteOnConflict` + +`deleteOnConflict` での削除競合は、常にすべてのレプリカからオブジェクトを削除することで解決されます。 + +そのために、Weaviate は削除リクエストを受け取った際にオブジェクトを完全に消去するのではなく、削除済みオブジェクトとしてマークします。 + +#### `TimeBasedResolution` + +`timeBasedResolution` では、削除リクエストのタイムスタンプと、その後に行われた作成や更新などのオブジェクト操作のタイムスタンプを比較して競合を解決します。 + +削除リクエストのタイムスタンプが後であれば、すべてのレプリカでオブジェクトが削除されます。削除リクエストのタイムスタンプが前であれば、その後の更新がすべてのレプリカに適用されます。 + +例: +- オブジェクトがタイムスタンプ 100 で削除され、その後タイムスタンプ 90 で再作成された場合、再作成が優先されます +- オブジェクトがタイムスタンプ 100 で削除され、その後タイムスタンプ 110 で再作成された場合、削除が優先されます + +#### 選択の指針 + +- 競合を手動で管理し、最大限のコントロールを得たい場合は `NoAutomatedResolution` を使用します +- 削除を必ず反映させたい場合は `DeleteOnConflict` を使用します +- 最新の操作を優先させたい場合は `TimeBasedResolution` を使用します + +### Repair-on-read + +:::info v1.18 で追加 +::: + +読み取り整合性を `All` もしくは `Quorum` に設定している場合、リードコーディネーターは複数のレプリカから応答を受け取ります。応答が異なる場合、コーディネーターは不整合を修復しようとします。これを「repair-on-read」または「read repair」と呼びます。 + +| 問題 | 対応 | +| :- | :- | +| オブジェクトが一部のレプリカに存在しない | 欠落しているレプリカへオブジェクトを伝搬します | +| オブジェクトが古い | ステールなレプリカを更新します | +| オブジェクトが一部のレプリカで削除されている | エラーを返します。削除が失敗したか、オブジェクトが部分的に再作成された可能性があります | + +リードリペアは、使用する読み取りおよび書き込み整合性レベルにも依存します。 + +| 書き込み整合性レベル | 読み取り整合性レベル | 対応 | +| :- | :- | +| `ONE` | `ALL` | すべてのノードを検証して修復を保証します | +| `QUORUM` | `QUORUM` または `ALL` | 同期の問題を修正しようとします | +| `ALL` | - | この状況は発生しないはずです。書き込みが失敗しているはずです | + +修復は読み取り時にのみ発生するため、バックグラウンドの負荷は大きくありません。ただしノードが不整合状態の間、整合性レベル `ONE` の読み取りは古いデータを返す可能性があります。 + +## Replica movement + +:::info v1.32 で追加 +::: + +シャードは、単一テナントコレクションではコレクションの一部、多テナントコレクションでは 1 テナント全体を表します。Weaviate では、クラスター内のソースノードからデスティネーションノードへ個々のシャードレプリカを手動で移動またはコピーできます。これにより、スケール後のクラスター再バランス、ノードの廃止、データローカリティの最適化によるパフォーマンス向上、データ可用性の向上などの運用シナリオに対応できます。 + +レプリカ移動はステートマシンとして動作し、プロセス全体でデータ整合性を確保します。この機能は単一テナントコレクションと多テナントコレクションの両方で利用可能です。 + +コレクション作成時に設定する静的なレプリケーションファクターとは異なり、レプリカ移動ではクラスター内でレプリカを移動またはコピーすることで特定のシャードに対して複製数を調整できます。コピー操作を行うと新しいレプリカが作成され、そのシャードのレプリケーションファクターが増加します。コレクションにはデフォルトのレプリケーションファクターが設定されていますが、個々のシャードはそれより高い値を持つことができます。ただし、コレクションレベルより低いレプリケーションファクターにはできません。 + +:::info + +[`REPLICATION_ENGINE_MAX_WORKERS`](/docs/deploy/configuration/env-vars/index.md#REPLICATION_ENGINE_MAX_WORKERS) 環境変数を使用すると、レプリカ移動を並列に処理するワーカー数を調整できます。 + +::: + +### Movement states + +各レプリカ移動操作は、データ整合性と可用性を保つためのワークフローを次のステートで進行します。 + +- **REGISTERED**: 移動操作が開始され、Raft リーダーに記録されました。リクエストが受信され、処理待ちキューに登録されています。 +- **HYDRATING**: デスティネーションノードで新しいレプリカを作成中です。データセグメントが既存のレプリカ(通常はソースレプリカ、または他の利用可能なピア)から転送されます。 +- **FINALIZING**: 大量データの転送が完了し、転送中に発生した書き込みをキャッチアップしています。これにより、レプリカは最新データと完全に同期されます。進行中の書き込みが完了しターゲットノードへ複製されるまでの待機時間は、 [`REPLICA_MOVEMENT_MINIMUM_ASYNC_WAIT`](/docs/deploy/configuration/env-vars/index.md#REPLICA_MOVEMENT_MINIMUM_ASYNC_WAIT) で調整できます。 +- **DEHYDRATING**: 移動 (Move) 操作の場合、新しいレプリカが準備完了した後、ソースノード上の元のレプリカを削除しています。 +- **READY**: 操作が正常に完了しました。新しいレプリカは完全に同期され、トラフィックを処理できます。Move 操作の場合、ソースレプリカは削除されています。 +- **CANCELLED**: 操作が完了する前にキャンセルされました。手動で中断された場合や、回復不能なエラーが発生した場合に起こります。 + +レプリカ移動は 2 つのモードをサポートします。 + +- **Move**: レプリカをあるノードから別のノードへ移動し、レプリケーションファクターは維持します +- **Copy**: レプリカをコピーして別のノードへ追加し、そのシャードのレプリケーションファクターを 1 増やします + +:::note Replication factor and quorum + +シャードレプリカをコピーすると、レプリケーションファクターが偶数になる場合があります。これにより、クォーラム達成には `n/2 + 1` ノードが必要となり、以前の `n/2 + 0.5` より難しくなることがあります。たとえば `RF=3` から `RF=4` に増やすと、クォーラムに必要なノード数は 2 から 3 へ( 67% から 75% のレプリカ)増加します。 + +::: + +## 関連ページ +- [API リファレンス | GraphQL | Get | 整合性レベル](../../api/graphql/get.md#consistency-levels) +- API リファレンス | REST | オブジェクト + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-factor.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-factor.png new file mode 100644 index 000000000..b47d2cc15 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-factor.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-high-availability.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-high-availability.png new file mode 100644 index 000000000..ecdb03f5b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-high-availability.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-increased-throughput.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-increased-throughput.png new file mode 100644 index 000000000..98268e2d0 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-increased-throughput.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-main-quorum.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-main-quorum.png new file mode 100644 index 000000000..d86c3c805 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-main-quorum.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-quorum-animation.gif b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-quorum-animation.gif new file mode 100644 index 000000000..42d20fbd1 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-quorum-animation.gif differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-regional-proximity-1.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-regional-proximity-1.png new file mode 100644 index 000000000..0d266fc1b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-regional-proximity-1.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-regional-proximity-3.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-regional-proximity-3.png new file mode 100644 index 000000000..253a00ae5 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-regional-proximity-3.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-replication-vs-sharding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-replication-vs-sharding.png new file mode 100644 index 000000000..5aef59d31 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-replication-vs-sharding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-ALL.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-ALL.png new file mode 100644 index 000000000..8728c6c8a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-ALL.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-ONE.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-ONE.png new file mode 100644 index 000000000..91409228c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-ONE.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-QUORUM.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-QUORUM.png new file mode 100644 index 000000000..d38c5244c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-c-QUORUM.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-size3.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-size3.png new file mode 100644 index 000000000..4c70b094b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-size3.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-size8.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-size8.png new file mode 100644 index 000000000..0c041342d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-rf3-size8.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-zero-downtime.gif b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-zero-downtime.gif new file mode 100644 index 000000000..b63603faf Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/replication-zero-downtime.gif differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/repliction-cap.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/repliction-cap.png new file mode 100644 index 000000000..40a35c2ae Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/img/repliction-cap.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/index.md new file mode 100644 index 000000000..54f9f110d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/index.md @@ -0,0 +1,179 @@ +--- +title: レプリケーション アーキテクチャ +sidebar_position: 0 +description: "高可用性・信頼性・データベース性能向上を実現する、マルチノードのデータレプリケーション設計。" +image: og/docs/concepts.jpg +# tags: ['architecture'] +--- + +:::info Added in `v1.17` +::: + +Weaviate は、[replication factor](../../manage-collections/multi-node-setup.mdx#replication-settings) を 1 より大きく設定することで、マルチノード クラスター間のデータレプリケーションを実現します。これにより、[高可用性](./motivation.md#high-availability-redundancy) など、さまざまな[利点](./motivation.md)が得られます。データベースのレプリケーションは、信頼性・スケーラビリティ・パフォーマンスを向上させます。 + +Weaviate では複数のレプリケーション方式を採用しています。 + +- [クラスター メタデータのレプリケーション](./consistency.md#cluster-metadata) は [Raft](https://raft.github.io/) コンセンサス アルゴリズムによって管理されます。 +- [データレプリケーション](./consistency.md#data-objects) は [チューナブル](./consistency.md) かつリーダーレスです。 + +
+ クラスター metadata とは? + +Weaviate クラスターの `metadata` には、コレクション定義やテナントのアクティビティ ステータスが含まれます。 +
+ +すべてのクラスター メタデータは、replication factor に関係なく常に全ノードにレプリケートされます。 +
+ +これは、オブジェクトの作成時刻などのオブジェクト メタデータとは異なります。オブジェクト メタデータは、指定された replication factor に従いオブジェクト データと一緒に保存されます。 + +
+ +この「レプリケーション アーキテクチャ」セクションでは、次の情報を提供します。 + +* **General Concepts**(本ページ) + * レプリケーションとは? + * CAP 定理 + * Weaviate にレプリケーションが必要な理由 + * レプリケーションとシャーディングの違い + * Weaviate におけるレプリケーションの仕組み + * ロードマップ + + +* **[Use Cases](./motivation.md)** + * モチベーション + * 高可用性 + * 読み取りスループット向上 + * ゼロダウンタイム アップグレード + * リージョナル近接性 + + +* **[Philosophy](./philosophy.md)** + * 典型的な Weaviate のユースケース + * リーダーレス アーキテクチャを選んだ理由 + * 段階的ロールアウト + * 大規模テスト + + +* **[Cluster Architecture](./cluster-architecture.md)** + * リーダーレス設計 + * Replication Factor + * 書き込み・読み取り操作 + + +* **[Consistency](./consistency.md)** + * クラスター メタデータ + * データオブジェクト + * 修復 + + +* **[Multi-DataCenter](./multi-dc.md)** + * リージョナル近接性 + +## レプリケーションとは? + +

Example setup with replication

+ +データベース レプリケーションとは、同じデータポイントのコピーをクラスター内の複数ノードに保持することを指します。 + +その結果として得られるシステムは分散データベースです。分散データベースは複数ノードで構成され、それぞれがデータのコピーを保持できます。そのため、あるノード(サーバー)がダウンしても、ユーザーは別のノードからデータにアクセスできます。さらに、レプリケーションによりクエリ スループットも向上します。 + +## CAP 定理 + +レプリケーション導入の主目的は信頼性の向上です。[Eric Brewer](https://en.wikipedia.org/wiki/Eric_Brewer_(scientist)) は、分散データベースの信頼性には制限があることを [CAP 定理](https://en.wikipedia.org/wiki/CAP_theorem) で示しました。CAP 定理によれば、分散データベースは次の 3 つの保証のうち 2 つしか同時に提供できません。 +* **Consistency (C)** - すべての読み取りが最新の書き込み、またはエラーを返し、全ノードが同一のデータを同時に参照できることを保証します。 +* **Availability (A)** - すべてのリクエストに対し常にエラーのない応答を返しますが、最新の書き込みを含む保証はありません。 +* **Partition tolerance (P)** - ノード間でネットワークにより任意のメッセージが失われたり遅延したりしても、システムが動作を継続できることを意味します。 + +

CAP Theorem

+ +理想的には、Weaviate のようなデータベースが最高の信頼性を持つことが望まれますが、これは一貫性・可用性・パーティション耐性間のトレードオフによって制限されます。 + +### 一貫性と可用性のトレードオフ + +:::tip +Consistency (C)、Availability (A)、Partition tolerance (P) のうち、同時に保証できるのは 2 つだけです。 + +Partition tolerance が必須であるとすると、残りの 2 つのうちシステムにとって重要な方を選択する必要があります。 +::: + +一貫性・可用性・パーティション耐性のうち、同時に保証できるのは 2 つだけです。クラスターは分散システムであり、ネットワーク パーティションが発生する前提のため、設計の際には **一貫性 (C)** か **可用性 (A)** のいずれかを選択することになります。 + +**一貫性** を可用性より優先すると、ネットワーク パーティションによりデータが最新であることを保証できない場合、データベースはエラーやタイムアウトを返します。**可用性** を一貫性より優先すると、データベースは常にクエリを処理し、最新である保証がなくても可能な限り最新のデータを返そうとします。 + +C を A より優先すべき典型例は、トランザクションを扱う銀行口座データなどのクリティカル データベースです。取引データでは、常に一貫性がなければ残高が正しくなくなる可能性があります。 + +一方、重要度が低いデータベースでは、A を C より優先できます。例としてメッセージング サービスが挙げられます。多少古いデータが表示されても許容されますが、高可用性と低レイテンシーで大量の書き込みを処理する必要があります。 + +Weaviate は一般的に後者の設計に従います。多くの場合、Weaviate はクリティカル データよりも比較的重要度の低いデータを扱い、近似検索のセカンダリ データベースとして利用されるためです。詳細は [Philosophy](./philosophy.md) を参照してください。ただし、必要に応じて Weaviate の [チューナブル コンシステンシー](./consistency.md#tunable-consistency-strategies) を利用できます。 + +## Weaviate にレプリケーションが必要な理由 + +Weaviate はデータベースとして、ユーザーのリクエストに対し信頼できる応答を提供しなければなりません。前述のとおり、データベースの信頼性にはさまざまな要素があります。以下は、Weaviate でレプリケーションが望ましいユースケースです。詳細は [Replication Use Cases (Motivation)](./motivation.md) をご覧ください。 + +1. **高可用性(冗長性)**
+ 分散(レプリケートされた)データベース構成では、1 台のサーバーノードがダウンしてもサービスは中断されません。データベースは引き続き利用可能で、読み取りクエリは利用可能なノードに(ほぼ気付かれずに)リダイレクトされます。 +2. **読み取りスループットの向上**
+ データベース構成にサーバーノードを追加すると、スループットも比例して増加します。ノードが多いほど、システムが処理できるユーザー(読み取り操作)数が増えます。コンシステンシー レベル `ONE` で読み取りを行う場合、replication factor(すなわちノード数)を増やすとスループットは線形に向上します。 +3. **ゼロダウンタイム アップグレード**
+ レプリケーションがない場合、Weaviate インスタンスをアップグレードする際にダウンタイムが発生します。単一ノードを停止・更新・再起動して再び利用可能になるまでサービスは停止します。レプリケーションがあればローリング アップデートが可能になり、常に最大でも 1 ノードのみが停止し、他のノードがトラフィックを継続的に処理します。 +4. **リージョナル近接性**
+ ユーザーが異なる地域(例:アイスランドとオーストラリア)にいる場合、データベース サーバーとの物理的距離によりすべてのユーザーに低レイテンシーを保証できません。分散データベースを使用すると、異なるローカル地域にノードを配置してレイテンシーを削減できます。これはレプリケーションの Multi-Datacenter 機能に依存します。 +## レプリケーションとシャーディング + +レプリケーションは [シャーディング](../cluster.md) とは異なります。シャーディングは水平スケーリングを指し、Weaviate には v1.8 で導入されました。 + +* **レプリケーション** はデータを別々のサーバーノードにコピーします。Weaviate では、これによりデータの可用性が向上し、単一ノードが障害を起こした場合の冗長性が確保されます。クエリスループットもレプリケーションによって改善できます。 +* **シャーディング** はデータを分割し、その断片(シャード)を複数のレプリカセットに送ることで、サーバー間の水平スケーリングを行います。データは分割され、すべてのシャードを合わせると完全なデータセットになります。Weaviate でシャーディングを使用すると、大規模データセットの運用やインポート速度の向上が可能です。 + +

レプリケーションとシャーディング

+ +レプリケーションとシャーディングは組み合わせて使用でき、スループットと可用性を高めるとともに、インポート速度の向上や大規模データセットへの対応が可能になります。たとえば、データベースのレプリカ数を 3、シャード数を 3 に設定すると、合計 9 個のシャードが生成され、各サーバーノードが 3 つの異なるシャードを保持します。 + +## Weaviate でのレプリケーションの仕組み + +### クラスタメタデータのレプリケーション + +Weaviate のクラスタメタデータ変更は Raft によって管理され、クラスタ全体で一貫性を確保しています。(これにはコレクション定義やテナントのアクティブステータスが含まれます。) + +Weaviate `v1.25` から、クラスタメタデータの変更は Raft コンセンサスアルゴリズムを使用してコミットされます。Raft はリーダーベースのコンセンサスアルゴリズムで、リーダーノードがクラスタメタデータの変更を担当します。Raft により、少数ノードの障害が発生しても変更内容はクラスタ全体で一貫性を保ちます。 + +
+ メタデータレプリケーション(v1.25 以前) + +Weaviate `v1.25` 以前では、各クラスタメタデータの変更は 2 フェーズコミットを用いた分散トランザクションで記録されていました。 +
+ +これは同期プロセスであり、すべてのノードが変更を認証して初めてコミットされます。このアーキテクチャでは、ノードがダウンするとメタデータ操作が一時的に停止します。さらに、一度に処理できる操作は 1 件のみでした。 + +Weaviate `v1.24` 以前をお使いの場合は、クラスタメタデータ変更に Raft コンセンサスアルゴリズムを利用するために [ `v1.25` へのアップグレード](/deploy/migration/weaviate-1-25.md) をご検討ください。 + +
+ +### データレプリケーション + +Weaviate では、一般的に一貫性よりも可用性を優先します。データレプリケーションにはリーダーレス設計を採用しており、プライマリやセカンダリの概念はありません。データの読み書き時、クライアントは 1 つ以上のノードに接続します。ユーザーとノードの間にはロードバランサーがあり、ユーザーはどのノードと通信しているかを意識する必要がありません(ユーザーが誤ったノードにリクエストしても Weaviate が内部で転送します)。 + +読み書き(v1.18 以降)で確認応答が必要なノード数は `ONE`、`QUORUM`(n/2+1)、`ALL` に設定できます。書き込み操作で整合性レベルを `ALL` にすると、データベースは同期的に動作します。`ALL` 以外に設定した場合(v1.18 以降)、ユーザー視点では非同期で書き込みが行われます。 + +レプリカ数はノード数(クラスタサイズ)と一致している必要はありません。Weaviate ではコレクション単位でデータを分割することが可能です。これは [シャーディングとは異なります](#replication-vs-sharding)。 + +レプリケーションの詳細は [Philosophy](./philosophy.md)、[Cluster Architecture](./cluster-architecture.md)、[Consistency](./consistency.md) をご覧ください。 + +## Weaviate でレプリケーションを利用するには + +[レプリケーションの設定方法](/deploy/configuration/replication.md) を参照してください。コレクション定義でレプリケーションを有効化できます。クエリでは、[希望する整合性レベルを指定](../../search/basics.md#replication) できます。 + +## ロードマップ + +* 未定 + * マルチデータセンターレプリケーション(この機能への投票は [こちら](https://github.com/weaviate/weaviate/issues/2436)) + +## 関連ページ +- [Configuration: Replication](/deploy/configuration/replication.md) + +## ご質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/motivation.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/motivation.md new file mode 100644 index 000000000..e721dabcb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/motivation.md @@ -0,0 +1,94 @@ +--- +title: ユースケース(動機) +sidebar_position: 1 +description: "Weaviate のレプリケーションの利点と設定要件を示す 4 つの主要なユースケース。" +image: og/docs/concepts.jpg +# tags: ['architecture'] +--- + +このページでは、 Weaviate のレプリケーションを導入する動機となる 4 つのユースケースを紹介します。目的が異なるため、それぞれに必要な設定も変わる場合があります。 + +## 高可用性(冗長化) + +データベースの高可用性とは、サービスを中断することなく継続的に稼働できるよう設計されていることを意味します。つまり、障害やエラーが発生しても自動的に処理できる耐障害性が求められます。 + +これはレプリケーションによって解決できます。冗長ノードが存在すれば、ほかのノードが停止してもリクエストを処理できます。 + +Weaviate はクラスターメタデータ操作を重要視しており、データ操作とは異なる方法で扱います。 + +Weaviate `v1.25` からは、クラスターメタデータのレプリケーションに Raft コンセンサスアルゴリズムを採用しています。 Raft はリーダーベースのアルゴリズムで、リーダーノードがクラスターメタデータの変更を担当します。これにより、一部のノードが障害を起こしてもクラスターメタデータの整合性が保たれます。 + +Weaviate `v1.25` 以前は、クラスターメタデータ操作にリーダーレス設計と 2 フェーズコミットを使用していました。そのため、コレクション定義の更新やテナント状態の更新といったクラスターメタデータ操作にはすべてのノードが必要でした。ノードが一時的にダウンするとクラスターメタデータ操作が行えず、また同時に実行できるクラスターメタデータ操作は 1 件のみという制限もありました。 + +データ操作に関しては、分散データベース構成ではノードがダウンしても読み書きクエリが利用可能な場合があり、単一障害点は排除されます。ユーザーのクエリは利用可能なレプリカノードに自動的(かつ透過的に)ルーティングされます。 + +高可用性が求められるアプリケーションの例としては、救急サービス、企業向け IT システム、ソーシャルメディア、ウェブサイト検索などが挙げられます。現代のユーザーは高い可用性を当たり前と考えており、ほとんどダウンタイムを許容しません。たとえばウェブサイト検索では、ノードがダウンしてもサービス(読み取りクエリ)が停止してはいけません。書き込みが一時的に利用できなくなっても許容範囲であり、最悪の場合でも検索結果が古くなるだけで読み取りは可能です。 + +

高可用性

+ +高可用性は次の設定例で示せます。 +1. Write `ALL`, Read `ONE` + 書き込み時は `ALL` ノードの応答が必要なため高可用性はありません。読み取り時は `ONE` であるため、すべてのノードがダウンしても 1 つ残っていれば読み取り操作が可能です。 +2. Write `QUORUM`, Read `QUORUM` (n/2+1) + 少数のノードがダウンしても過半数が稼働していれば読み取りと書き込みの両方が可能です。 +3. Write `ONE`, Read `ONE` + もっとも可用性が高い構成です。 1 ノードを除いてすべてがダウンしても読み取り・書き込みが可能です。ただし、この非常に高い可用性は低い整合性保証と表裏一体です。結果整合性のため、アプリケーション側で一時的なデータの古さに対応できる必要があります。 + +## スループット(読み取り)の向上 + +多数のユーザー向けアプリケーションを構築しており、 Weaviate インスタンスに多くの読み取りリクエストが発生する場合、データベースは高いスループットをサポートする必要があります。スループットは QPS(Queries Per Second)で測定します。データベースにサーバーノードを追加するとスループットも比例して増加します。ノード数が増えるほど、システムが処理できるユーザー(読み取り操作)数も増えます。つまり、 Weaviate をレプリケートするとスループットが向上します。 + +読み取りの整合性レベルを低く(例: `ONE`)設定すると、レプリケーションファクター(サーバーノード数)を増やすことでスループットは線形に向上します。たとえば読み取り整合性が `ONE` で、 1 ノードあたり 10,000 QPS を達成できる場合、 3 レプリカノードの構成では 30,000 QPS が見込めます。 + +

スループットの向上

+ +## ゼロダウンタイムアップグレード + +レプリケーションがない場合、 Weaviate インスタンスを更新するとダウンタイムが発生します。単一ノードは停止・アップデート・再起動を経て再びサービス可能になるまで待つ必要があります。レプリケーションを行うと、ローリングアップデートでアップグレードが実施され、同時に停止するのは最大 1 ノードとなり、ほかのノードは引き続きトラフィックを処理できます。 + +例として、 Weaviate のバージョンを v1.19 から v1.20 へ更新する場合を考えます。レプリケーションがないと次のようなダウンタイムが発生します。 +1. ノードがトラフィックを処理中 +2. ノードを停止、リクエスト不可 +3. ノードイメージを新しいバージョンへ差し替え +4. ノードを再起動 +5. ノードが準備完了まで待機 +6. ノードが再びトラフィックを処理 + +ステップ 2 から 6 までは Weaviate サーバーがリクエストを受け付けられず、ユーザー体験が損なわれます。 + +レプリケーション(例:レプリケーションファクター 3)があれば、 Weaviate のバージョンアップグレードはローリングアップデートで行われ、同時に停止するのは最大 1 ノードです。 +1. 3 ノードすべてがトラフィックを処理中 +2. ノード 1 を置き換え、ノード 2 と 3 がトラフィックを処理 +3. ノード 2 を置き換え、ノード 1 と 3 がトラフィックを処理 +4. ノード 3 を置き換え、ノード 1 と 2 がトラフィックを処理 + +

ゼロダウンタイムアップグレード

+ +## 地域的近接性 + +ユーザーが異なる地域(例:アイスランドとオーストラリアのような遠距離)にいる場合、データベースサーバーとユーザー間の物理距離のため、すべてのユーザーに低レイテンシを保証するのは困難です。データベースサーバーは 1 か所にしか配置できないため、どこに設置するかという課題が生じます。 +1. オプション 1 - クラスターを中間地点に配置(例:インド)
+ アイスランドとインド、オーストラリアとインド間でデータが往復するため、すべてのユーザーが比較的高いレイテンシを被ります。 + +

地理的中間地点にクラスターを配置

+ +2. オプション 2 - クラスターを一方のユーザーグループに近づける(例:アイスランド)
+ アイスランドのユーザーは非常に低レイテンシになりますが、オーストラリアのユーザーはデータ伝送距離が長くなるため高レイテンシを経験します。 + + データクラスタを 2 つの地理的ロケーションにレプリケートできる場合、別の選択肢が生まれます。これを Multi-Datacenter(Multi-DC)レプリケーションと呼びます。 +3. オプション 3 - アイスランドとオーストラリアの双方にサーバークラスターを持つ Multi-DC レプリケーション
+ アイスランドとオーストラリアのユーザーはそれぞれローカルクラスターからサービスを受けるため、双方が低レイテンシを享受できます。 + +

Multi-DC レプリケーション

+ +Multi-DC レプリケーションには、データが複数の物理ロケーションに冗長化されるという追加メリットもあります。非常にまれですがデータセンター全体がダウンしても、別のロケーションからデータを提供できます。 + +:::note +Regional Proximity はレプリケーションの Multi-Datacenter 機能に依存します。関心のある方は[こちら](https://github.com/weaviate/weaviate/issues/2436)で投票できます。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/multi-dc.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/multi-dc.md new file mode 100644 index 000000000..4a8980cb2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/multi-dc.md @@ -0,0 +1,24 @@ +--- +title: マルチデータセンター +sidebar_position: 5 +description: "将来の地理的リージョンをまたぐ分散デプロイメント向けマルチデータセンター レプリケーション機能。" +image: og/docs/concepts.jpg +# tags: ['architecture'] +--- + + +マルチデータセンター (Multi-DC) レプリケーションにより、複数のデータセンターにわたる複数のサーバー上にデータのコピーを保持できます。この形式のレプリケーションは v1.17 および v1.18 ではまだサポートされていません。現行のレプリケーション機能は、後日 Multi-DC をサポートできるよう設計されています。この機能に興味がある場合は、[この GitHub issue](https://github.com/weaviate/weaviate/issues/2436) に賛成票をお願いします。 + +ユーザーグループが地理的に離れた複数の場所(例: アイスランドやオーストラリア)に分散している場合、Multi-DC レプリケーションは有益です。ユーザーグループの近くのローカルリージョンにノードを配置することで、レイテンシーを低減できます。さらに Multi-DC レプリケーションではデータが複数の物理的な場所に冗長化されるため、まれにデータセンター全体が停止した場合でも他リージョンからデータを提供できます。 + +現時点では、すべてのレプリカノードが同一データセンター内にあるという前提で運用してください。この構成の利点は、ノード間のネットワーク通信が安価で高速な点です。欠点はデータセンター全体が障害を起こした場合に冗長性がなくなることです。これは Multi-DC が[実装されれば](https://github.com/weaviate/weaviate/issues/2436) 解決します! + +

Replication multi-dc

+ + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/philosophy.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/philosophy.md new file mode 100644 index 000000000..ad20d9c20 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/replication-architecture/philosophy.md @@ -0,0 +1,33 @@ +--- +title: 設計哲学 +sidebar_position: 2 +description: "Weaviate のレプリケーションアーキテクチャの決定の背後にある設計原則とユーザー中心アプローチ。" +image: og/docs/concepts.jpg +# tags: ['architecture'] +--- + +## ユーザーの利用方法をモデルにした設計 + +Weaviate が採用するレプリケーションシステムのアーキテクチャは、ユーザーが Weaviate をどのように利用しているかをモデルにしています。Weaviate はサイト検索、レコメンデーション、ナレッジ抽出などの情報検索ユースケースを支えています。これらのユースケースには共通点があります。 +* 多くの場合、 **非常に大規模** (数 10 億件のオブジェクトと ベクトル を含むデータセット) です +* 厳しいレイテンシ要件を伴う **大規模な並列利用** が発生します (高スループットかつ低い p99 レイテンシ) +* バージョンアップグレードなどの計画停止や予期しない障害に対しても、サービスが **高可用** であることが不可欠です +* 一時的にデータが同期していなくても、最終的に **整合性が確保される** のであれば許容されることが多いです +* トランザクション性が必要な場合、Weaviate は強整合性のあるトランザクションデータベースと併用されることがあります。Weaviate が主要なデータベースとして使われる場合、データは通常トランザクション性を持ちません +* Weaviate のユーザーはクラウドネイティブ技術、とりわけ NoSQL データベースの利用経験が豊富で、結果整合性システムを正しく扱うアプリケーション設計を理解しています + +上記の利用パターンと [CAP 定理](./index.md#cap-theorem) のトレードオフを踏まえ、Weaviate ではクラスターメタデータとデータのレプリケーションに対して 2 種類のアーキテクチャを実装しています。 + +1. **クラスターメタデータのレプリケーション** は [Raft 合意アルゴリズム](https://raft.github.io/) を基にしており、選出されたリーダーがログベースで整合性を維持します。これにより、(少数の) ノード障害が発生してもメタデータの変更が可能です。 + +2. **データレプリケーション** はリーダーレス設計で調整可能な整合性を採用しています。中央リーダーやプライマリノードがフォロワーノードへレプリケーションを行う仕組みは存在しません。Weaviate のデータレプリケーションアーキテクチャは **可用性を整合性より優先** します。ただし、リクエストによってはより厳格な整合性が要求される場合があります。そのようなケースでは、Weaviate は [読み取り・書き込み整合性のチューニング](./consistency.md) を提供します。 + +## リーダーレスアーキテクチャを選択した理由 + +Weaviate のレプリケーションアーキテクチャは、同様の目的で設計されたモダンな Internet スケールデータベース、特に [Apache Cassandra](https://cassandra.apache.org/_/index.html) から着想を得ています。Weaviate の [レプリケーションアーキテクチャ](./cluster-architecture.md) は Cassandra と多くの共通点があります。可用性とスループットを両立するために、当然ながらリーダーレスパターンが選択されました。リーダーフル構成では、主に 2 つの欠点があります。第一に、すべての書き込み要求がリーダーを経由するため、リーダーが性能上のボトルネックになります。第二に、リーダーが障害を起こすと新しいリーダーの選出が必要になり、このプロセスは複雑かつコストが高く、一時的なサービス停止を招く可能性があります。リーダーフルシステムの主な利点は、特定の整合性保証を比較的容易に提供できる点です。しかし先述の動機から、Weaviate は大規模ユースケース、リニアスケーリング、可用性を厳格な整合性より重視しています。 + +## 質問やフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/reranking.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/reranking.md new file mode 100644 index 000000000..58a717fac --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/reranking.md @@ -0,0 +1,74 @@ +--- +title: リランキング +sidebar_position: 28 +description: "検索結果の関連性と精度を向上させるために、別モデルを用いて結果を並べ替える手法。" +image: og/docs/concepts.jpg +# tags: ['basics'] +--- + +リランキングは、検索で返された結果セットを別のモデルで並べ替えることにより、検索の関連性を改善します。 + +リランキングはクエリと各データオブジェクトとの関連度スコアを計算し、最も関連性の高いものから低いものへ並べ替えたリストを返します。すべての `(query, data_object)` ペアでこのスコアを計算することは通常非常に時間がかかるため、リランキングはまず関連オブジェクトを取得した後の第 2 段階として使用されます。 + +リランキングは取得後の小さなデータサブセットに対して動作するため、計算コストが高いアプローチを用いても検索関連性を改善できます。 + +:::info + +コレクションに対して [リランキングモデルを設定](../manage-collections/generative-reranker-models.mdx#specify-a-reranker-model-integration) し、[検索結果にリランキングを適用](../search/rerank.md) する方法をご覧ください。 + +::: + +## Weaviate におけるリランキング + +当社のリランキングモジュールを使用すると、Weaviate 内で簡単に [マルチステージ検索](https://weaviate.io/blog/cross-encoders-as-reranker) を実行できます。 + +言い換えると、例えばベクトル検索を実行し、その結果をリランキングで再度並べ替えることができます。リランキングモジュールはベクトル検索、bm25 検索、ハイブリッド検索のすべてと互換性があります。 + +### リランキングを含む GraphQL クエリ例 + +以下のように GraphQL クエリでリランキングを利用できます。 + +```graphql +{ + Get { + JeopardyQuestion( + nearText: { + concepts: "flying" + } + limit: 10 + ) { + answer + question + _additional { + distance + rerank( + property: "answer" + query: "floating" + ) { + score + } + } + } + } +} +``` + +このクエリは `JeopardyQuestion` クラスから 10 件の結果を取得し、クエリ “flying” を用いたハイブリッド検索を実行します。その後、`answer` プロパティとクエリ “floating” を使って結果を再ランク付けします。 + +リランキングに渡す `JeopardyQuestion` クラスの `property` を指定できます。ここで返される `score` にはリランキングによるスコアが含まれる点に注意してください。 + +## さらなるリソース + +:::info Related pages +- [API 参照: GraphQL - 追加プロパティ](../api/graphql/additional-properties.md#rerank) +- [検索の方法: リランキング](../search/rerank.md) +- [Cohere リランキング統合](../model-providers/cohere/reranker.md) +- [Transformers リランキング統合](../model-providers/transformers/reranker.md) +- [VoyageAI リランキング統合](../model-providers/voyageai/reranker.md) +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/resources.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/resources.md new file mode 100644 index 000000000..89cd3ba9c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/resources.md @@ -0,0 +1,165 @@ +--- +title: リソース計画 +sidebar_position: 90 +description: "大規模環境で Weaviate のパフォーマンスを最適化するための CPU・メモリ・GPU リソース計画ガイドライン。" +image: og/docs/concepts.jpg +# tags: ['architecture', 'resource', 'cpu', 'memory', 'gpu'] +--- + +Weaviate は大規模プロジェクトでも高いスケーラビリティを発揮します。100 万件未満の小規模プロジェクトであれば特別なリソース計画は不要です。中規模・大規模プロジェクトでは、リソースから最大のパフォーマンスを引き出す計画が必要です。システム設計時には、 CPU とメモリの管理を意識してください。 CPU とメモリが Weaviate インスタンスの主要リソースです。使用するモジュールによっては GPU も重要になります。 + + +## 利用可能リソースの制限 + +Weaviate のリソース使用量を制御してシステム全体のリソースを使い切らないようにするには、[環境変数](/deploy/configuration/env-vars/index.md)を設定します。利用できる環境変数は次のとおりです。 + +- `LIMIT_RESOURCES`: `true` に設定すると、Weaviate は自動的にリソース使用量を制限します。メモリ使用量を総メモリの 80% に設定し、 CPU コアは 1 つを除いてすべて使用します。`GOMEMLIMIT` の設定を上書きしますが、`GOMAXPROCS` の設定は尊重します。 + +- `GOMEMLIMIT`: Go ランタイムのメモリ上限を設定します。Weaviate に割り当てるメモリの総量の 10〜20% 程度に設定してください。メモリ使用量がこの上限に近づくとガベージコレクタの動作が積極的になります。 + +- `GOMAXPROCS`: 同時実行のために使用する最大スレッド数を設定します。指定すると `LIMIT_RESOURCES` もこの設定を尊重し、Weaviate が使用する CPU コア数を明示的に指定できます。 + +これらの設定により、システムリソースとバランスを取りながら Weaviate のパフォーマンスを最適化できます。 + + +## CPU の役割 + +:::tip Rule of thumb +CPU はクエリ速度およびインポート速度に直接影響しますが、データセットサイズには影響しません。 +::: + +ベクトル検索は Weaviate の操作の中で最も CPU 集約的な処理です。クエリは CPU ボトルネックになりやすく、インポートもインデックス作成時にベクトル検索を行うため CPU ボトルネックになります。Weaviate はベクトルをインデックスするために HNSW (Hierarchical Navigable Small World) アルゴリズムを使用します。主用途に合わせて [HNSW インデックスを調整](../config-refs/indexing/vector-index.mdx) できます。 + +複数の CPU を効率的に利用するには、コレクションに複数シャードを作成してください。単一ノードでも最速のインポートを実現するには複数シャードを作成します。 + +各挿入および検索はシングルスレッドで実行されます。ただし、複数の検索や挿入を同時に行う場合、Weaviate はマルチスレッドを利用できます。[バッチ挿入](/weaviate/manage-objects/import)は複数スレッドで並列処理を行います。 + +### CPU を追加すべきタイミング + +インポート時に CPU 使用率が高い場合は CPU を追加してインポート速度を向上させます。 + +検索スループットが制限されている場合は CPU を追加して 1 秒当たりのクエリ数を増やします。 + +## メモリの役割 + +:::tip Rule of thumb +メモリはサポートできる最大データセットサイズを決定します。メモリは直接的にはクエリ速度に影響しません。 +::: + +HNSW インデックスはメモリ上に保持される必要があります。必要なメモリ量はデータセットサイズに直接比例します。データセットサイズと現在のクエリ負荷には相関がありません。ベクトルを圧縮する [`product quantization (PQ)`](/weaviate/concepts/vector-quantization#product-quantization) を利用すると、メモリに保持できるベクトル数を増やせます。 + +Weaviate では、予期しない Out-of-Memory(「 OOM 」)を防ぐためにメモリ上に保持するベクトル数の上限を設定できます。デフォルト値はコレクションごとに 1 兆 (`1e12`) オブジェクトです。この値を変更するには、インデックス設定の [`vectorCacheMaxObjects`](../config-refs/indexing/vector-index.mdx) を更新してください。 + +また、Weaviate はディスク上のデータに対して [メモリマップトファイル](https://en.wikipedia.org/wiki/Memory-mapped_file) を使用します。メモリマップトファイルは効率的ですが、ディスクストレージはメモリより遥かに遅い点に注意してください。 + +### メモリ使用量を左右する要因 + +HNSW ベクトルインデックスがメモリ使用量の主因です。以下の要因が影響します。 + +- **オブジェクトベクトルの総数** + ベクトル数が重要であり、元オブジェクトの生データサイズは重要ではありません。メモリに格納されるのはベクトルのみで、元のテキストやその他データのサイズは制限要因になりません。 + +- **`maxConnections` HNSW インデックス設定** + メモリ上の各オブジェクトはレイヤーごとに最大 [`maxConnections`](../config-refs/indexing/vector-index.mdx) 本の接続を持ちます。各接続は 8〜10B のメモリを使用します。ベースレイヤーは `2 * maxConnections` である点に注意してください。 + +### 計算例 + +:::note +以下の計算はすべてのベクトルをメモリに保持する前提です。メモリとディスクを組み合わせるハイブリッド方式については後述の [Vector Cache](#vector-cache) を参照してください。 +::: + +メモリ必要量を概算する経験則は次のとおりです。 + +`メモリ使用量 = 2 * (全ベクトルのメモリフットプリント)` + +例として、384 次元の `float32` 型ベクトルが 100 万件あるモデルを考えます。 + +- 単一ベクトルのメモリ量は `384 * 4 B = 1536 B` +- 100 万件のメモリ量は `1e6 * 1536 B = 1.5 GB` + +経験則によりメモリ量を 2 倍します。したがって必要メモリは `2 * 1e6 * 1536 B = 3 GB` です。 + +より正確な計算を行うには、単純に 2 倍する代わりに [`maxConnections`](../config-refs/indexing/vector-index.mdx) の影響を考慮します。 + +例として `maxConnections` が 64 の場合、より正確な見積もりは +`1e6 * (1536 B + (64 * 10)) = 2.2 GB` です。 + +`maxConnections` を含めた見積もりは経験則より小さくなります。ただしこの見積もりにはガベージコレクションによるオーバーヘッドが含まれていません。ガベージコレクションについては次章で説明します。 + +## ガベージコレクションの影響 + +Weaviate はガベージコレクションを持つ Go で実装されています。そのため、不要になったメモリが即座に再利用可能になるとは限りません。ガベージコレクタが非同期でメモリを解放する必要があります。これによりメモリ使用に 2 つの影響が出ます。 + +- [ガベージコレクタのメモリオーバーヘッド](#メモリオーバーヘッド-for-ガベージコレクタ) +- [ガベージコレクションによる OOM 問題](#ガベージコレクションによる-oom-問題) + +### メモリオーバーヘッド for ガベージコレクタ +`maxConnections` を含むメモリ計算はシステムが安定した状態を表します。しかし、Weaviate がベクトルをインポートしている間は追加のメモリが割り当てられ、最終的にガベージコレクタが解放します。ガベージコレクションは非同期であるため、この追加メモリも考慮が必要です。前述の「経験則」はこの点を加味しています。 + +### ガベージコレクションによる OOM 問題 +まれに、特に大規模マシンで非常に高速なインポートを行う場合、Weaviate がメモリを割り当てる速度がガベージコレクタが解放する速度を上回ることがあります。この場合、システムカーネルが `out of memory kill (OOM-Kill)` を発動する可能性があります。これは既知の問題であり、Weaviate で改善に取り組んでいます。 + +### データインポート +インポート中の OOM を避けるには、`LIMIT_RESOURCES` を `True` に設定するか、`GOMEMLIMIT` 環境変数を設定してください。詳細は [環境変数](/deploy/configuration/env-vars/index.md) を参照してください。 + +## メモリ使用量を削減する戦略 + +以下の方法で Weaviate のメモリ使用量を削減できます。 + +- **ベクトル圧縮を使用する** + 直積量子化 (PQ) はベクトルサイズを縮小する技術です。ベクトル圧縮はリコール性能に影響を与えるため、本番導入前にデータセットでテストすることを推奨します。 + 詳細は [Product Quantization](/weaviate/concepts/vector-quantization) を参照してください。 + PQ の設定方法は [Compression](../configuration/compression/pq-compression.md) を参照してください。 + +- **ベクトルの次元数を削減する** + メモリサイズを最も効果的に削減する方法は、ベクトルあたりの次元数を減らすことです。高次元ベクトルを使用している場合は、次元の少ないモデルを検討してください。たとえば、384 次元モデルは 1536 次元モデルより遥かにメモリを消費しません。 + +- **HNSW の [`maxConnections`](../config-refs/indexing/vector-index.mdx) を減らす** + メモリ上の各オブジェクトは最大 `maxConnections` 本の接続を持ち、各接続は 8〜10B のメモリを使用します。`maxConnections` を減らすとメモリフットプリントを削減できます。 + + `maxConnections` を減らすと HNSW のリコール性能が低下します。これを緩和するために `efConstruction` と `ef` のいずれか、または両方を増やしてください。 + + - `efConstruction` を増やすとインポート時間が増え、クエリ時間には影響しません。 + - `ef` を増やすとクエリ時間が増え、インポート時間には影響しません。 + +- **全ベクトル数より小さいベクトルキャッシュを使用する(非推奨)** + この戦略は後述の [Vector Cache](#vector-cache) で説明します。パフォーマンスに大きな影響があるため、限定的な状況でのみ推奨されます。 + +## Vector Cache + +検索およびインポートを最適化するには、インポート済みのベクトルをすべてメモリに保持する必要があります。ベクトルキャッシュのサイズは、コレクション定義の [`vectorCacheMaxObjects`](../config-refs/indexing/vector-index.mdx) パラメータで指定します。新規コレクションではデフォルトで 1 兆 (`1e12`) オブジェクトに設定されています。 + +`vectorCacheMaxObjects` を小さく設定することもできますが、ディスクからのベクトル取得はメモリ取得より何桁も遅くなります。`vectorCacheMaxObjects` を減らす場合は十分注意し、最後の手段としてのみ行ってください。 + +一般的な推奨事項は次のとおりです。 +- インポート中は `vectorCacheMaxObjects` をすべてのベクトルをメモリに保持できる値に設定してください。インポートでは複数回の検索が行われ、キャッシュに全ベクトルがないとインポート性能が大幅に低下します。 + +- インポート後にクエリ中心のワークロードになる場合は、データセット総量より小さいキャッシュサイズを試してください。 + + キャッシュに存在しないベクトルは空きがあればキャッシュに追加されます。キャッシュが満杯になると、Weaviate はキャッシュ全体を破棄します。その後、すべてのベクトルが初回はディスクから読み込まれ、再びキャッシュが満杯になるまでキャッシュが使用されます。 + 大規模データセットで多くのユーザーが特定のベクトル集合のみを検索するケースでは、キャッシュが非常に有効です。大多数のユーザーはキャッシュから、高頻度でないクエリはディスク読み込みで対応できます。 +### Weaviate マシンまたはクラスターのメモリ増設タイミング + +メモリを追加するべきケース: +- より大きなデータセットをインポートしたい場合(より一般的)。 +- 正確検索 ( exact lookups ) がディスク依存になっており、メモリを増やすことでページキャッシュ ( page-caching ) を改善できる場合(あまり一般的ではありません)。 + +## Weaviate における GPU の役割 + +Weaviate Database 自体は GPU を使用しません。 しかし、Weaviate がモジュールとして提供するモデルの中には GPU での実行を想定しているものがあります。 例えば `text2vec-transformers`、`qna-transformers`、`ner-transformers` などです。 これらのモジュールは分離されたコンテナ内で動作するため、モジュールのコンテナを GPU アクセラレートされたハードウェア上で実行しつつ、Weaviate Database を低コストの CPU のみのハードウェアで実行できます。 + +## ディスク: SSD と HDD ( Spinning Disk ) の比較 + +Weaviate は Solid-State Disk ( SSD ) での利用に最適化されています。 ただし、回転式ハードディスク ( HDD ) でも、ある程度の性能低下を受け入れれば使用可能です。 + +## ファイルシステム + +最適な性能と信頼性を確保するため、Weaviate の永続ボリューム ( [`PERSISTENCE_DATA_PATH`](/deploy/configuration/env-vars/index.md) ) には NFS などのファイルシステムを使用しないでください。 + +代わりに、Ext4 や XFS といったファイルシステムを SAN ストレージ ( 例: EBS ) と組み合わせて使用することで、最高のパフォーマンスを得られます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/_best-practices.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/_best-practices.md new file mode 100644 index 000000000..600099907 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/_best-practices.md @@ -0,0 +1,228 @@ +--- +title: ベストプラクティス +sidebar_position: 5 +image: og/docs/concepts.jpg +# tags: ['concepts', 'search', 'optimization'] +--- + +# 検索:ベストプラクティス + +このページでは、検索の品質とパフォーマンスを最適化するための推奨ベストプラクティスを示します。 + +## フィルター + +フィルターはプロパティやメタデータに関連する特定の条件に基づいて検索結果を絞り込みます。 + +Weaviate では [事前フィルター](../filtering.md) を適用し、フィルターを実行してその結果をパラメーターとして検索に渡します。これにより、フィルターが非常に厳しい場合でも再現率を高く保つことができます。 + +各プロパティごとに [インデックスを有効化または無効化](#index-types-and-filters) したり、[オプションのメタデータをインデックス化](#optional-metadata-filtering) したりして、フィルタリング性能とディスク使用量のトレードオフを調整します。 + +### インデックスの種類とフィルター + +Weaviate はフィルター処理を高速化するためにインデックスを利用します。 + +`v1.18` で、フィルター性能を向上させるために [Roaring ビットマップインデックス (`indexFilterable`)](../filtering.md#indexfilterable) が追加されました。さらに、`int`、`number`、`date` プロパティの範囲ベースの数値フィルターを高速化するため、`v1.26` で [範囲ベースインデックス (`indexRangeFilters`)](../filtering.md#indexrangefilters) が追加されました。 + +これらのインデックスはプロパティごとに [有効化または無効化](../../manage-collections/collection-operations.mdx#set-inverted-index-parameters) できます。 + +インデックスを有効化すると検索は高速化しますが、ディスクおよびメモリの使用量がわずかに増加します。 + +一般的な目安として、そのプロパティでフィルタリングが不要であると確信している場合を除き、`indexFilterable` と `indexRangeFilters` の両方を有効にすることを推奨します。 + +### オプションのメタデータフィルター + +プロパティ作成時に設定しておけば、各プロパティに対して追加のメタデータフィルターをオプションで構成できます。 + +これらのオプションは次のとおりです。 + +- `indexTimestamps`: タイムスタンプベースのフィルター(作成日時または最終更新日時)用 +- `indexNullState`: null 値によるフィルター用 +- `indexPropertyLength`: テキストプロパティの長さによるフィルター用 + +これらのインデックスオプションを有効化すると対応するフィルターが利用可能になりますが、ディスクおよびメモリの使用量がわずかに増加します。 + +## ベクトル検索 + +ベクトル検索は、クエリのベクトルと保存済みのベクトルを比較し、最も近い一致を見つける類似度ベースの検索です。 + +Weaviate は、インポート時およびクエリ時に設定済みの [モデルプロバイダー統合](../../model-providers/index.md) を使用して、テキストや画像などのメディアを統合的にベクトル化します。 + +### ベクトライザーモデルの選択 + +ベクトル化とは、ベクトライザーモデルを用いてデータ(テキスト、画像など)を数値ベクトルに変換するプロセスです。 + +1. **Embedding モデル** : Weaviate は機械学習モデル(例: Transformer)を使用して入力データをベクトル埋め込みに変換します。 +2. **次元数** : ベクトルは通常 768 や 1536 次元など高次元となり、複雑な意味関係を捉えます。 +3. **意味的表現** : 高次元空間におけるベクトルの位置は、他のベクトルとの意味的関係を表します。 + +### 近似最近傍 (ANN) 検索 + +Weaviate のベクトル検索は、ANN アルゴリズムを使用して高次元空間内で類似ベクトルを効率的に検索します。 + +1. **厳密検索 vs. 近似検索** : 厳密な最近傍検索は最も近いベクトルを保証しますが、計算コストが高くなります。ANN は精度をわずかに犠牲にする代わりに大幅な速度向上を得ます。 +2. **ANN アルゴリズム** : Weaviate は次のような ANN アルゴリズムをサポートします。 + - HNSW (Hierarchical Navigable Small World): 多層グラフ構造を構築し、高速検索を実現します。 + - PQ (直積量子化): ベクトルを圧縮してメモリ使用量を削減し、検索速度を向上させます。 +3. **インデックス構築** : データ取り込み時に ANN インデックスを構築し、検索時の高速取得に最適化します。 + +### 距離計算指標 + +ベクトルの類似度は距離計算指標を用いて測定します。Weaviate は複数の指標をサポートします。 + +1. **コサイン類似度** : ベクトル間の角度のコサインを計算します(多くのユースケースでのデフォルト)。 +2. **ユークリッド距離** : ベクトル間の直線距離を測定します。 +3. **ドット積** : ベクトルのドット積を計算します(正規化された埋め込みの一部で有用)。 + +## キーワード検索 + +### 転置インデックス + +Weaviate のキーワード検索は、語を含むドキュメントへのマッピングを行うデータ構造である 転置インデックス に依存しています。 + +1. **インデックス構築** : データ取り込み時に、Weaviate はテキストをトークンに分割し、それぞれのトークンが含まれるドキュメントをマッピングするインデックスを作成します。 +2. **トークナイズ** : 言語、ステミング、ストップワードなどを考慮しつつテキストを単語またはサブワードに分割します。 +3. **ポスティングリスト** : 各語について、その語を含むドキュメントのリストや語の出現回数などの追加情報を保持します。 + +### BM25 アルゴリズム + +Weaviate はキーワード検索の結果をランク付けするために BM25F アルゴリズムを使用します。 + +1. **Term Frequency (TF)** : ある語がドキュメント内で出現する頻度を測定します。 +2. **Inverse Document Frequency (IDF)** : その語が全ドキュメントの中でどれだけ希少か/一般的かを測定します。 +3. **フィールド重み** : BM25F ではドキュメント内のフィールドごとに異なる重みを設定できます。 +4. **スコアリング** : TF、IDF、およびフィールド重みを組み合わせてドキュメントの関連度スコアを算出します。 + +## ハイブリッド検索 + +ハイブリッド検索はベクトル検索とキーワード検索を組み合わせ、両者の長所を活用します。 + +### 融合手法 + +Weaviate では、ベクトル検索結果とキーワード検索結果を統合する 2 つの融合手法を提供します。 + +1. **相対スコア融合** : + - ベクトル類似度と BM25 スコアを共通のスケールに正規化します。 + - 正規化されたスコアを重み付き合計で結合します。 +2. **ランク融合** : + - ベクトル検索結果とキーワード検索結果でのオブジェクトの順位に基づいてスコアを付与します。 + - 順位ベースのスコアを統合し、最終的な並び順を決定します。 + +### Alpha パラメーター + +Alpha パラメーターはハイブリッド検索におけるベクトル検索とキーワード検索のバランスを制御します。 + +- Alpha = 0: キーワード検索のみ +- Alpha = 1: ベクトル検索のみ +- 0 < Alpha < 1: 両者の重み付き組み合わせ + +## パフォーマンスの考慮事項 + +1. **インデックス作成** : 高速な検索性能には ANN と 転置インデックス の両方で効率的なインデックスを構築することが重要です。 +2. **シャーディング** : Weaviate は複数のシャードにデータを分散してスケーラビリティを向上できます。 +3. **キャッシュ** : 適切なキャッシュ戦略により、繰り返しまたは類似したクエリの応答時間を大幅に短縮できます。 +4. **ハードウェア** : 特にベクトル演算では GPU アクセラレーションが性能を向上させる場合があります。 +## リランキング + +リランキングは、検索結果の関連性を向上させるために、最初に取得した検索結果をより高度なモデルや異なる基準で再順位付けする手法です。 + +### Cross-Encoder モデル + +1. **Bi-Encoder vs. Cross-Encoder** : 初期取得では効率性のために Bi-Encoder モデルがよく使用されますが、リランキングでは通常、より高い精度のために Cross-Encoder モデルが用いられます。 +2. **Attention Mechanism** : Cross-Encoder はクエリとドキュメントのペアを同時に処理し、関連性をより細かく理解できます。 +3. **Computational Trade-off** : Cross-Encoder は計算コストが高いため、最初に取得した結果のうち少量のサブセットに対してのみ使用されます。 + + +## 関連性の最適化 + +検索の関連性は次の要素によって影響を受けます。 + +### ベクトル検索品質 + +#### ベクトライザー・モデルの選定 + +ベクトライザー・モデルは、オブジェクトをどのように ベクトル に変換するかを決定します。 +モデルは、テキスト・画像・音声など、データのモダリティに適している必要があります。ドメイン特化モデルの採用や、モデルの複雑さとパフォーマンス要件のバランスを検討してください。 + + Weaviate は ::model provider integrations:: と統合できます。 + +#### ベクトル化するフィールド + +意味理解に最も寄与するフィールドを特定してください。複数のフィールドを 1 つのベクトル埋め込みにまとめることも検討します。構造化データと非構造化データをベクトル化した場合の影響を評価しましょう。 + +#### ANN インデックス設定 + + +### キーワード検索 + +- インデックスプロパティの長さ、null プロパティなど +- これらの設定が検索動作や利用可能なクエリに与える影響 +- k1 と b の値 + +### ハイブリッド検索 + +- ハイブリッド融合方法 +- Alpha 値 + + +## 検索パフォーマンスとスケーラビリティ + +- ベクトルインデックス設定とクエリパフォーマンス +- 量子化とクエリ +- 大規模データセットで検索を最適化するためのベストプラクティス + + +## 検索拡張生成 ( RAG ) + +検索拡張生成 ( RAG ) は 生成検索 とも呼ばれ、従来の検索メカニズムと生成系 AI モデルを組み合わせ、取得した情報に基づいて新しいコンテンツを生成します。 + +### RAG アーキテクチャ + +1. **Retriever** : Weaviate の検索機能(ベクトル、キーワード、またはハイブリッド)を使用して関連情報を取得します。 +2. **Generator** : 取得した情報とユーザーのクエリを基に、大規模言語モデル ( LLM ) を用いて応答を生成します。 +3. **Prompt Engineering** : ユーザーのクエリと取得情報を組み合わせた効果的なプロンプトを設計し、 LLM の出力を誘導します。 + +### 言語モデルとの統合 + +1. **API Connections** : Weaviate は OpenAI、Cohere、Google など、さまざまな LLM プロバイダーと統合できます。 +2. **Model Selection** : ユーザーは、パフォーマンス、コスト、ユースケースの要件などを考慮して適切なモデルを選択できます。 +3. **Token Management** : トークン上限や切り捨て処理を管理し、 LLM API を効果的に利用します。 + +### RAG ワークフロー + +1. **Query Processing** : ユーザーのクエリを解析し、検索パラメータを決定します。 +2. **Information Retrieval** : Weaviate の検索機能を使用して、関連するドキュメントやデータポイントを取得します。 +3. **Context Preparation** : 取得した情報を生成モデルのコンテキストとして準備します。 +4. **Response Generation** : クエリと準備したコンテキストを LLM に送信して応答を生成します。 +5. **Post-processing** : 必要に応じて生成された応答を整形またはフォーマットし、ユーザーへ返します。 + + +## AI モデルと検索 + +### 概要 + +- 検索における AI モデルの役割(ベクトル検索、リランキング、生成検索など) + +### モデル選定ガイド + +- 適切なモデルを選択するための基準 +- 異なるモデルタイプ間のトレードオフ + + +## 検索関連性とランキング + +- Weaviate が結果の順序を決定する方法 +- 検索関連性を向上させる手法 + + +## 一般的なユースケース + +- EC 商品検索 +- コンテンツ推薦システム +- セマンティックドキュメント検索 +- 画像・マルチメディア検索 + + +## トラブルシューティングとよくある落とし穴 + +- 検索実装でよくある問題への対処 +- 検索に関する問題の診断と解決のヒント \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/_category_.json new file mode 100644 index 000000000..47a611799 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Search", + "position": 5 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/hybrid-search.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/hybrid-search.md new file mode 100644 index 000000000..431e7c51b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/hybrid-search.md @@ -0,0 +1,197 @@ +--- +title: ハイブリッド検索 +sidebar_position: 60 +description: "ベクトル(セマンティック)検索とキーワード検索を組み合わせ、セマンティック類似度と正確なキーワード一致の強みを活用します。" +image: og/docs/concepts.jpg +# tags: ['concepts', 'search', 'hybrid search', 'vector search', 'keyword search', 'bm25'] +--- + +ハイブリッド検索は [ ベクトル検索 ](./vector-search.md) と [ キーワード検索(BM25)](./keyword-search.md) を組み合わせ、それぞれの強みを活かします。これにより、セマンティック類似度(ベクトル検索)と正確なキーワード関連度(BM25)を考慮し、より包括的な検索結果を提供します。 + +ハイブリッド検索では両方の検索を並列で実行し、それぞれのスコアを組み合わせて最終的なランキングを生成します。これにより多様で堅牢な検索が可能となり、幅広いユースケースに適しています。 + +## ハイブリッド検索の仕組み + +Weaviate でハイブリッド検索を行う際の手順は次のとおりです。 + +1. 両方の検索を並列で実行 + - ベクトル検索でセマンティックに類似したコンテンツを取得 + - BM25 検索でキーワード一致を取得 +1. 正規化したスコアを [ 融合戦略 ](#fusion-strategies) で結合 +1. 結合スコアでランク付けした結果を返却 + +```mermaid +%%{init: { + 'theme': 'base', + 'themeVariables': { + 'primaryColor': '#4a5568', + 'primaryTextColor': '#2d3748', + 'primaryBorderColor': '#718096', + 'lineColor': '#718096', + 'secondaryColor': '#f7fafc', + 'tertiaryColor': '#edf2f7', + 'fontFamily': 'Inter, system-ui, sans-serif', + 'fontSize': '14px', + 'lineHeight': '1.4', + 'nodeBorder': '1px', + 'mainBkg': '#ffffff', + 'clusterBkg': '#f8fafc' + } +}}%% + +flowchart LR + %% Style definitions + classDef systemBox fill:#f8fafc,stroke:#3182ce,stroke-width:1.5px,color:#2d3748,font-weight:bold + classDef processBox fill:#f8fafc,stroke:gray,stroke-width:0.5px,color:#2d3748,font-weight:bold + classDef component fill:white,stroke:#a0aec0,stroke-width:1px,color:#2d3748 + + %% Main flow + query["🔍 Query"] --> split["Query Processing"] + + %% Parallel processes + split --> vector["Vector Search"] + split --> bm25["BM25 Search"] + + %% Results combination + vector --> fusion["Score Fusion"] + bm25 --> fusion + fusion --> results["📑 Ranked Results"] + + %% Parameters box + subgraph params["Search Parameters"] + alpha["Alpha: Balance between
vector and keyword scores"] + fusion_type["Fusion Strategy:
rankedFusion or relativeScoreFusion"] + end + + params --> fusion + + %% Apply styles + class query,split,vector,bm25,fusion,results component + class params processBox + class alpha,fusion_type component + + %% Linkstyle for curved edges + linkStyle default stroke:#718096,stroke-width:3px,fill:none,background-color:white +``` + +### 融合戦略 + +Weaviate では、ベクトル検索とキーワード検索のスコアを組み合わせる方法として `relativeScoreFusion` と `rankedFusion` の 2 つをサポートしています。 + +`relativeScoreFusion`(`v1.24` 以降のデフォルト)では、各オブジェクトのスコアをベクトル検索とキーワード検索それぞれで *正規化* します。最大値は 1、最小値は 0 とし、その間をスケールします。最終スコアは、正規化されたベクトル距離と正規化された BM25 スコアのスケール済み合計として計算されます。 + +`rankedFusion`(`v1.23` 以前のデフォルト)では、各オブジェクトは検索結果内の順位に基づいてスコアリングされます。最上位のオブジェクトが最も高いスコアを受け取り、順位が下がるにつれてスコアが減少します。最終スコアは、ベクトル検索とキーワード検索の順位ベーススコアを合算して算出します。 + +一般的には `relativeScoreFusion` が良い選択肢であることが多いため、デフォルトになっています。 + +主な理由は、`relativeScoreFusion` が元の検索スコアからより多くの情報を保持するのに対し、`rankedFusion` は順位のみを保持する点です。ベクトル検索とキーワード検索で得られる微妙な違いは、`relativeScoreFusion` の方がランキングに反映されやすいと考えられます。 + +以下に 2 つの融合戦略の具体例を示します。 + +### 融合例 + +検索により **5 件**のオブジェクトが返され、それぞれ **ドキュメント ID**(0 ~ 4)と **キーワード検索スコア**、**ベクトル検索スコア**が **スコア順** に並んでいるとします。 + + + + + + + + + + + + + + +
検索タイプ(id): score(id): score(id): score(id): score(id): score
キーワード(1): 5(0): 2.6(2): 2.3(4): 0.2(3): 0.09
ベクトル(2): 0.6(4): 0.598(0): 0.596(1): 0.594(3): 0.009
+ +#### ランクベース融合 + +スコアは各結果の順位に依存し、`1/(RANK + 60)` で計算されます。 + + + + + + + + + + + + + + +
検索タイプ(id): score(id): score(id): score(id): score(id): score
キーワード(1): 0.0154(0): 0.0160(2): 0.0161(4): 0.0167(3): 0.0166
ベクトル(2): 0.016502(4): 0.016502(0): 0.016503(1): 0.016503(3): 0.016666
+ +ご覧のとおり、スコアがどれだけ異なっていても、同じ順位であれば結果は同一になります。 + +#### 相対スコア融合 + +相対スコア融合では、最大スコアを 1、最小スコアを 0 とし、**最大値**と**最小値**までの**相対距離**に応じてスコールします。 + + + + + + + + + + + + + + +
検索タイプ(id): score(id): score(id): score(id): score(id): score
キーワード(1): 1.0(0): 0.511(2): 0.450(4): 0.022(3): 0.0
ベクトル(2): 1.0(4): 0.996(0): 0.993(1): 0.986(3): 0.0
+ +この方法では、元のスコア分布が反映されます。たとえば、ベクトル検索の上位 4 件のスコアはほぼ同一であり、正規化後もその関係は維持されています。 + +#### 比較 + +ベクトル検索では上位 4 件(ID 2, 4, 0, 1)のスコアがほぼ同じで、いずれも良好な結果でした。一方、キーワード検索では 1 件(ID 1)が他より大きな差をつけて優れていました。 + +`relativeScoreFusion` の最終結果では、ID 1 がトップになりました。これは、キーワード検索で大きく抜きん出ており、ベクトル検索でも上位グループに入っていたため妥当です。 + +対して `rankedFusion` では、ID 2 がトップで、ID 1 と ID 0 が僅差で続きます。 + +### Alpha パラメーター + +alpha 値は、最終的なハイブリッド検索結果におけるベクトル検索の重みを決定します。alpha は 0 から 1 の範囲で指定します。 + +- `alpha = 0.5`(デフォルト): 両検索に同等の重み +- `alpha > 0.5`: ベクトル検索により重み付け +- `alpha < 0.5`: キーワード検索により重み付け + +## 検索しきい値 + +ハイブリッド検索では `max vector distance` パラメーターで最大ベクトル距離のしきい値を設定できます。 + +このしきい値はハイブリッド検索のベクトル検索部分のみに適用され、たとえキーワード検索スコアが高くても、ベクトル空間で類似度が低すぎる結果を除外できます。 + +たとえば `0.3` を指定すると、ベクトル距離が `0.3` を超えるオブジェクトはハイブリッド検索結果から除外されます。 + +これにより、セマンティック類似度が一定基準以上であることを保証しつつ、キーワード一致の利点も享受できます。 + +キーワード(BM25)部分や最終結合スコアには同等のしきい値パラメーターはありません。 + +これは、BM25 スコアがベクトル距離のように正規化・制約されておらず、一般的なしきい値を設定しても意味が薄いためです。 +## キーワード (BM25) 検索パラメーター + +Weaviate のハイブリッド検索では、キーワード (BM25) 検索で利用できるすべてのパラメーターを使用できます。これには、たとえばトークン化方式、ストップワード、BM25 パラメーター (k1、b)、検索演算子 ( `and` または `or` )、検索対象とする特定のプロパティや、特定のプロパティをブーストする機能などが含まれます。 + +これらのパラメーターの詳細については、[キーワード検索のページ](./keyword-search.md) をご覧ください。 + +## さらなるリソース + +- [How-to: Search](../../search/index.mdx) +- [How-to: Hybrid search](../../search/hybrid.md) +- [Blog: A deep dive into Weaviate's fusion algorithms](https://weaviate.io/blog/hybrid-search-fusion-algorithms) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/index.md new file mode 100644 index 000000000..c24b65c7f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/index.md @@ -0,0 +1,422 @@ +--- +title: 検索 +sidebar_position: 5 +description: " 10 億規模のデータセットとリアルタイム クエリ向けに設計された検索機能の概要。" +image: og/docs/concepts.jpg +# tags: ['concepts', 'search'] +--- + +Weaviate は柔軟で高速かつスケーラブルな検索を実行し、 10 億規模のデータセットでもユーザーが迅速に適切なデータを見つけられるよう支援します。 + +Weaviate では、ニーズに合わせてさまざまな検索タイプを実行でき、パフォーマンスと精度を最適化するための設定も行えます。 + +以下のセクションでは、Weaviate における検索の概念的な概要として、[検索プロセスと種類の概要](#search-process) を紹介します。 + +## 検索プロセス + +次の表と図は、Weaviate における検索プロセスを示しています。コアの検索プロセスを中心に、結果を改善・操作するためのステップがいくつか存在します。 + +| Step | Description | Optional | +|------|-------------|----------| +| 1. [Retrieval](#retrieval-filter) | [Filter](#retrieval-filter): 条件に基づいて結果セットを絞り込む
[Search](#retrieval-search): [キーワード](#keyword-search)・[ベクトル](#vector-search)・[ハイブリッド](#hybrid-search) のいずれかの検索タイプで最も関連性の高いエントリーを見つける | 必須 | +| 2. [Rerank](#rerank) | 別の (より複雑な) モデルで結果を再順位付けする | 任意 | +| 3. [Retrieval augmented generation](#retrieval-augmented-generation-rag) | 取得したデータとプロンプトを生成系 AI モデルへ送信する。検索拡張生成 (RAG) とも呼ばれる | 任意 | + +
+ +```mermaid +flowchart LR + %% Node definitions + Query[/"🔍 Query"/] + Filter["Filter"] + Key["Keyword Search
(BM25F)"] + Vec["Vector Search
(Embeddings)"] + Hyb["Hybrid Search
(Combined)"] + Rerank["Rerank
(Optional)"] + RAG["RAG
(Optional)"] + Results[/"📊 Results"/] + + %% Main flow grouping + subgraph retrieval ["Retrieval"] + direction LR + Filter + search + end + + subgraph search ["Search"] + direction LR + Key + Vec + Hyb + end + + %% Connections + Query --> retrieval + Filter --> search + retrieval --> Results + retrieval --> Rerank + Rerank --> RAG + RAG --> Results + + %% Node styles + style Query fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Filter fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Key fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Vec fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Hyb fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Rerank fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style RAG fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Results fill:#ffffff,stroke:#B9C8DF,color:#130C49 + + %% Subgraph styles + style retrieval fill:#ffffff,stroke:#130C49,stroke-width:2px,color:#130C49 + style search fill:#ffffff,stroke:#7AD6EB,stroke-width:2px,color:#130C49 +``` + +
+ +各ステップの概要は次のとおりです。 + +### リトリーバル: フィルター + +:::info In one sentence + フィルターは、特定の条件に基づいてオブジェクト数を減らします。 +::: + +フィルターは以下のような条件でオブジェクトを絞り込みます。 + +- テキスト一致 +- 数値しきい値 +- 日付範囲 +- カテゴリ値 +- 地理的位置 + +フィルタリングを適切に行うことで検索結果の関連性を大幅に高められます。これは、フィルターが厳密な条件で結果セットを正確に絞り込めるためです。 + +:::info How do filters interact with searches? +Weaviate では [プリフィルタリング](../filtering.md) を採用しており、検索より前にフィルターが実行されます。 +
+ +これにより、検索結果がフィルター条件と重なり合い、適切なオブジェクトが取得されます。 +::: + +
+ フィルター: 例 + +次の `animal_objs` のようなデータセットでは、特定の色でフィルターして条件に合うオブジェクトのみを取得できます。 +
+ +```json +[ + {"description": "brown dog"}, + {"description": "small domestic black cat"}, + {"description": "orange cheetah"}, + {"description": "black bear"}, + {"description": "large white seagull"}, + {"description": "yellow canary"}, +] +``` + +`"description"` に `"black"` をフィルターすると、黒色のオブジェクトのみが返されます。 + +- `{'description': 'black bear'}` +- `{'description': 'small domestic black cat'}` +
+ +Weaviate では、他に順位付けを行わない場合、結果の並びはオブジェクトの UUID に基づきます。そのため、この場合の順序は実質ランダムになり、フィルターは条件に合うかどうかだけを判断します。 +
+ +### リトリーバル: 検索 + +:::info In one sentence + 検索は、クエリとの関連度に基づいてオブジェクトを順序付けしたリストを生成します。 +::: + +検索は、最も近い・最も関連性の高いデータオブジェクトを見つけるプロセスです。Weaviate では、[キーワード検索](#keyword-search)、[ベクトル検索](#vector-search)、[ハイブリッド検索](#hybrid-search) の 3 種類をサポートしています。 + +| 検索タイプ | 説明 | +|-------------|-------------| +| キーワード検索 | トークン頻度を用いた従来のテキスト検索。 | +| ベクトル検索 | ベクトル埋め込みによる類似度検索。 | +| ハイブリッド検索 | ベクトル検索とキーワード検索の結果を組み合わせる。 | + +:::tip Search vs Filter +フィルターは条件に合うかどうかだけを判定するため、結果の順位付けは行いません。 +
+ +検索ではクエリとの関連度に基づいて結果が **順位付け** されます。 +::: + +それでは各検索タイプを詳しく見ていきましょう。 + +#### キーワード検索 + +キーワード検索では、キーワード一致の「スコア」に基づいて結果を順位付けします。このスコアは、クエリ内のトークンが各データオブジェクトにどの程度含まれているかによって算出され、これらの指標を BM25 アルゴリズムで組み合わせて最終スコアを生成します。 + +
+ キーワード検索: 例 + +次の `animal_objs` のようなデータセットでは、特定の色に対してキーワード検索を行い、その重要度を確認できます。 +
+ +```json +[ + {"description": "brown dog"}, + {"description": "small domestic black cat"}, + {"description": "orange cheetah"}, + {"description": "black bear"}, + {"description": "large white seagull"}, + {"description": "yellow canary"}, +] +``` + +`"black"` でキーワード検索を行うと、黒色のオブジェクトのみが返されますが、ここでは BM25 アルゴリズムに基づいて順位付けされます。 +1. `{'description': 'black bear'}` +1. `{'description': 'small domestic black cat'}` +
+ +`{"description": "black bear"}` のほうが `{"description": "small domestic black cat"}` よりスコアが高いのは、テキスト中で「black」が占める割合が大きいためです。 +
+ +
+ キーワード検索を使う場面 + +キーワード検索は、特定の単語の出現がテキストの関連性を強く示す場合に最適です。 + +例えば: +- 医療や法律文献で特定の用語を含むものを探す +- 正確な用語が重要となる技術文書や API リファレンスを検索する +- EC データベースで製品名や SKU を特定する +- プログラミング環境でコードスニペットやエラーメッセージを探す +
+ +:::info Read more +Weaviate におけるキーワード検索の詳細は [keyword search](./keyword-search.md) を参照してください。 +::: + +#### ベクトル検索 + +ベクトル埋め込みを用いた類似検索です。この方法では、あらかじめ設定された [距離メトリック](../../config-refs/distances.md) に基づき、クエリのベクトル埋め込みと保存済みオブジェクトのベクトル埋め込みを比較し、最も近いものを探します。 + + Weaviate では、複数の方法でベクトル検索を実行できます。 [テキスト入力](../../search/similarity.md#search-with-text)、 [ベクトル入力](../../search/similarity.md#search-with-a-vector)、あるいは [既存オブジェクト](../../search/similarity.md#search-with-an-existing-object) を基に類似オブジェクトを検索できます。さらに、 [画像](../../search/image.md) など他のモダリティでの検索も可能です。 + +
+ ベクトル検索: 例 + +`animal_objs` のようなデータセットでは、意味的に近い単語で検索し、それらがどの程度重要かを取得できます。 +
+ +```json +[ + {"description": "brown dog"}, + {"description": "small domestic black cat"}, + {"description": "orange cheetah"}, + {"description": "black bear"}, + {"description": "large white seagull"}, + {"description": "yellow canary"}, +] +``` + +ここで `"black"` を検索すると、キーワード検索と同様に動作します。しかし、ベクトル検索では `"very dark"`、`"noir"`、`"ebony"` などのクエリでも類似結果が得られます。 +
+ +これは、ベクトル検索がテキストの持つ意味に基づいており、使用された単語の一致には依存しないためです。ベクトル埋め込みはテキストの意味を捉えるため、より柔軟な検索が可能になります。 +
+ +その結果、上位 3 件は次のとおりです: +1. `{'description': 'black bear'}` +1. `{'description': 'small domestic black cat'}` +1. `{'description': 'orange cheetah'}` + +
+ +
+ ベクトル検索を使う場面 + +ベクトル検索は、人間の「類似性」の感覚が結果品質の良い指標になる場合に最適です。 + +例: +- セマンティックテキスト検索: 異なる単語を使っていても意味が近い文書を探す。 +- 多言語検索: 異なる言語間で関連コンテンツを見つける。 +- 画像類似検索: 大規模データベースから視覚的に似た画像を探す。 + +
+ +:::info Read more + Weaviate におけるベクトル検索のしくみについては [ベクトル検索](./vector-search.md) ページをご覧ください。 +::: + +#### ハイブリッド検索 + +ベクトル検索とキーワード検索を組み合わせ、それぞれの利点を活かします。両方の検索を実行し、ハイブリッド融合方法や alpha 値などのパラメータを用いて結果を結合します。 + +
+ ハイブリッド検索: 例 + +`animal_objs` のようなデータセットでは、ハイブリッド検索により、より堅牢に関連オブジェクトを見つけることができます。 +
+ +```json +[ + {"description": "brown dog"}, + {"description": "small domestic black cat"}, + {"description": "orange cheetah"}, + {"description": "black bear"}, + {"description": "large white seagull"}, + {"description": "yellow canary"}, +] +``` + +`"black canine"` でハイブリッド検索を行うと、キーワード検索との一致により、説明に `"black"` を含むオブジェクトが高く評価されます。そのため `{"description": "small domestic black cat"}` や `{"description": "black bear"}` が上位に表示されます。 +
+ +一方で、ベクトル検索によりクエリと `"dog"` の高い類似度が検出されるため、`{"description": "brown dog"}` のように `"dog"` を含むオブジェクトもブーストされます。 +
+ +その結果、上位 3 件は次のとおりです: +1. `{"description": "black bear"}` +1. `{"description": "small domestic black cat"}` +1. `{"description": "brown dog"}` + +
+ +
+ ハイブリッド検索を使う場面 + +ハイブリッド検索は堅牢な検索タイプであり、出発点として最適です。どちらか一方の検索で良い結果が得られたアイテムをブーストする傾向があります。 + +例: +- 学術論文検索: キーワードの関連性とセマンティック類似性の両方に基づき論文を探す。 +- 求人マッチング: スキルのキーワード一致と職務記述の意味理解を組み合わせ候補者を特定する。 +- レシピ検索: 特定の材料 (キーワード) と料理全体の類似性 (ベクトル) の両方を考慮してレシピを探す。 +- カスタマーサポート: 正確な用語一致と概念的類似性を併用し、関連チケットやドキュメントを発見する。 + +
+ +:::info Read more + Weaviate におけるハイブリッド検索のしくみについては [ハイブリッド検索](./hybrid-search.md) ページをご覧ください。 +::: + +### 取得: 順序なし + +ランク付けを伴わないクエリを組み立てることもできます。 + +たとえば、単にフィルターだけのクエリや、 [カーソル API](../../manage-objects/read-all-objects.mdx) を使ってデータセット全体を順に処理したい場合があります。 + +このような順序なし取得リクエストでは、 Weaviate はオブジェクトを UUID の順で取得します。したがって、結果リストは実質的にランダムな順序になります。 + +### リランク + +:::info In one sentence + リランカーは、より複雑なモデルや異なる基準で初期検索結果を再順位付けします。 +::: + +リランクは、初期検索結果を再順位付けして検索関連性を向上させます。 + +コレクションが [リランカー統合を設定済み](../../model-providers/index.md) の場合、 Weaviate は設定されたリランカーモデルを用いて初期検索結果を並べ替えます。 + +これにより、計算コストの高いモデルを小さな結果サブセットに適用し、検索品質を向上させることができます。通常、 [Cohere Rerank](../../model-providers/cohere/reranker.md) や [Hugging Face Reranker](../../model-providers/transformers/reranker.md) などのリランカーモデルはクロスエンコーダーモデルであり、テキストをより細かく理解できます。 + +また、リランカーを使用して取得時とは異なる入力クエリを提供し、より高度な検索戦略を採用することもできます。 + +
+ リランクを使う場面 + +リランクは、より複雑なモデルを小さな結果サブセットに適用して検索結果の質を高めたい場合に有用です。対象オブジェクトが非常に微妙または専門的な業界・ユースケースの場合に必要となることがあります。 + +例として、法律、医療、科学文献の検索では、テキストをより精緻に理解する必要があります。リランクにより、最も関連性の高い結果を表面化できます。 +
+ +### 検索拡張生成 (RAG) + +:::info In one sentence + Retrieval Augmented Generation は、検索と生成 AI モデルを組み合わせ、検索結果に基づき新しいコンテンツを生成します。 +::: + +検索拡張生成 (RAG) は、生成検索とも呼ばれ、検索と生成 AI モデルを組み合わせ、検索結果を基に新しいコンテンツを生成する強力な手法です。これにより、 AI モデルの生成能力と Weaviate の検索能力の両方を活用できます。 + + Weaviate は [AWS](../../model-providers/aws/generative.md)、 [Cohere](../../model-providers/cohere/generative.md)、 [Google](../../model-providers/google/generative.md)、 [OpenAI](../../model-providers/openai/generative.md)、 [Ollama](../../model-providers/ollama/generative.md) など、多くの人気ある [生成モデルプロバイダー](../../model-providers/index.md) と統合しています。 + +その結果、 Weaviate では RAG を [簡単に設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration) でき、 [統合された単一クエリ](../../search/generative.md#grouped-task-search) として容易に実行できます。 + +
+ RAG: 例 + +`animal_objs` のようなデータセットでは、任意の検索方法と組み合わせて検索拡張生成を行い、関連オブジェクトを取得したあと変換できます。 +
+ +```json +[ + {"description": "brown dog"}, + {"description": "small domestic black cat"}, + {"description": "orange cheetah"}, + {"description": "black bear"}, + {"description": "large white seagull"}, + {"description": "yellow canary"}, +] +``` + +例として、キーワード検索 `"black"` と RAG リクエスト `"What do these animal descriptions have in common?"` を考えます。 +
+ +検索結果は `{"description": "black bear"}` と `{"description": "small domestic black cat"}` です。その後、生成モデルがクエリに基づき出力を生成します。一例として次のような生成結果が得られました。 +
+ +```text +"What these descriptions have in common are: + +* **Color:** Both describe animals with a **black** color. +* **Species:** One is an **animal**, the other describes a **breed** of animal (domesticated)." +``` +
+## 検索スコアと指標 + +Weaviate では、クエリに対する検索結果をランク付けするために、さまざまな指標を使用します。主な指標は以下のとおりです。 + +- ベクトル距離: クエリとオブジェクト間のベクトル距離。 +- BM25F スコア: BM25F アルゴリズムを用いて計算されるキーワード検索スコア。 +- ハイブリッド スコア: ベクトル検索とキーワード検索のスコアを組み合わせたもの。 + +## 名前付きベクトル + +### 特定の名前付きベクトルの検索 + +名前付きベクトルを持つコレクションでベクトル検索を行う場合は、検索するベクトル空間を指定します。 + +[ベクトル類似度検索](/weaviate/search/similarity#named-vectors)( `near_text` 、 `near_object` 、 `near_vector` 、 `near_image` )および [ハイブリッド検索](/weaviate/search/hybrid#named-vectors) で名前付きベクトルを使用できます。 + +名前付きベクトルのコレクションはハイブリッド検索をサポートしますが、一度に 1 つのベクトルのみ検索できます。 + +コレクションに名前付きベクトルがあっても、[キーワード検索](/weaviate/search/bm25) の構文は変わりません。 + +### 複数の名前付きベクトルの検索 + +:::info Added in `v1.26` +::: + +コレクションに複数の名前付きベクトルが定義されている場合、それらを 1 回の検索で指定できます。これは、オブジェクトと複数の名前付きベクトルとの類似度を比較する際に便利です。 + +この機能は「マルチターゲット ベクトル検索 (multi-target vector search)」と呼ばれます。 + +マルチターゲット ベクトル検索では、以下を指定できます。 + +- 検索対象とするベクトル +- 対象ベクトルと比較するクエリ +- 各対象ベクトルに対して適用する距離の重み(生値または正規化後) + +詳細は [How-to: Multi-target vector search](../../search/multi-vector.md) を参照してください。 + +## 参考リソース + +詳細は次のページを参照してください。 +- [概念: ベクトル検索](./vector-search.md) +- [概念: キーワード検索](./keyword-search.md) +- [概念: ハイブリッド検索](./hybrid-search.md) + +これらの検索タイプのコードスニペットについては、[How-to: search](../../search/index.mdx) ページを参照してください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/keyword-search.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/keyword-search.md new file mode 100644 index 000000000..7099a8afb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/keyword-search.md @@ -0,0 +1,210 @@ +--- +title: キーワード検索 (BM25) +sidebar_position: 40 +description: "BM25 アルゴリズムを用いた正確なキーワードおよびフレーズ検索のための厳密なトークンベース一致。" +image: og/docs/concepts.jpg +# tags: ['concepts', 'search', 'keyword search', 'bm25', 'keyword'] +--- + +import ThemedImage from '@theme/ThemedImage'; + +キーワード検索は、文字列(トークン)を用いた厳密一致ベースの検索です。 + +これは検索クエリに対する関連度に基づいてドキュメントをランク付けする BM25 アルゴリズムを使用します。高レベルでは、 BM25 アルゴリズムは、ドキュメント内のクエリ語の出現回数(term frequency)とデータセット全体での語の出現頻度(inverse document frequency)を用いて関連度スコアを計算します。 + +より具体的には、 Weaviate では複数フィールド対応版である BM25F アルゴリズムを使用します。 + +キーワード検索は、クエリに含まれる厳密なトークンと格納されたオブジェクトのトークンとの一致を基に最適な一致結果を決定します。そのため、キーワード検索は厳密一致(例: ドメイン固有の言語、正確なカテゴリやタグ)が重要な場面に適しています。例: + +- 特定の技術用語を含むドキュメントの検索 +- 正確なキーワードやタグによる記事の特定 + +これは、正確な語が一致しなくても意味的に類似した内容を見つける ベクトル 検索とは異なります。関連概念よりも精度が重要な場合にキーワード検索を使用できます。 + +## Weaviate におけるキーワード検索 + +Weaviate では、キーワード検索は [BM25F](https://en.wikipedia.org/wiki/Okapi_BM25) 「スコア」によって測定されたクエリとの最適一致オブジェクトを返します。 + +:::info BM25F と BM25 の違い +BM25F の「 F 」は「 field 」を意味し、フィールドごとに異なる重み付けを行える BM25 のフィールド特化版です。これにより、オブジェクトの異なるフィールド(プロパティ)ごとに重みを設定できます。 +
+ +Weaviate ではキーワード検索のスコア計算に BM25F を使用しているため、両者は同義で扱われます。本ドキュメントでは一般に BM25 と呼びます。 +::: + + BM25 スコアは、オブジェクトのプロパティにおけるクエリトークンの出現頻度、およびオブジェクトプロパティとクエリの長さに基づいて計算されます。 + +たとえば `"A red Nike shoe"` のような入力文字列がクエリとして与えられた場合、 Weaviate は以下を行います。 + +1. 入力を [トークン化](#トークン化) する(例: `["a", "red", "nike", "shoe"]`) +2. [ストップワード](#ストップワード) を除去する(例: `a` を除き `["red", "nike", "shoe"]` となる) +3. [BM25 パラメータ](#bm25-パラメータ) と [プロパティブースト](#プロパティ-ブースト) を考慮し、データベースオブジェクトの [選択プロパティ](#選択プロパティ) に対して BM25 スコアを算出する +4. BM25 スコアが最も高いオブジェクトを検索結果として返す + +### トークン化 + +キーワード検索におけるトークン化とは、各ソーステキストを比較・一致させるために個々の「トークン」へ分割する方法を指します。 + +デフォルトのトークン化方法は `word` です。 + +`whitespace`、`lowercase`、`field` などの他のトークン化方法に加え、他言語向けの `GSE` や `kagome_kr` なども利用できます([詳細](../../config-refs/collections.mdx#tokenization))。 + +トークン化オプションはコレクションの [転置インデックス設定](../../search/bm25.md#set-tokenization) で指定します。 + +:::info 異なる文脈でのトークン化 +「トークン化」という用語は、ベクトル化や言語生成などの文脈でも使用されます。これらはそれぞれ異なる要件を満たすため通常異なるトークナイザーを使用するため、同じ入力テキストからでも異なるトークン集合が生成されます。 +::: + +### ストップワード + +ストップワードとは、テキスト処理前に除外される単語です。 + +Weaviate は BM25 スコア計算時に設定可能なストップワードを使用します。ストップワードリストに含まれるトークンは BM25 スコア計算から除外されます。 + +詳細は [リファレンスページ](../../config-refs/indexing/inverted-index.mdx#stopwords) を参照してください。 + +### BM25 パラメータ + + BM25 は、クエリ語が出現するドキュメントをランク付けするためのスコアリング関数で、挙動を制御する 2 つの主要パラメータがあります。 + +- `k1` (デフォルト: 1.2): term frequency の飽和を制御します。値が大きいほど、語が複数回出現した際にスコアがより増加します +- `b` (デフォルト: 0.75): ドキュメント長の正規化を制御します。1 に近いほどドキュメント長の正規化が強くなります + +```mermaid +%%{init: { + 'theme': 'base', + 'themeVariables': { + 'primaryColor': '#4a5568', + 'primaryTextColor': '#2d3748', + 'primaryBorderColor': '#718096', + 'lineColor': '#718096', + 'secondaryColor': '#f7fafc', + 'tertiaryColor': '#edf2f7', + 'fontFamily': 'Inter, system-ui, sans-serif', + 'fontSize': '14px', + 'lineHeight': '1.4', + 'nodeBorder': '1px', + 'mainBkg': '#ffffff', + 'clusterBkg': '#f8fafc' + } +}}%% + +flowchart LR + %% Style definitions + classDef systemBox fill:#f8fafc,stroke:#3182ce,stroke-width:1.5px,color:#2d3748,font-weight:bold + classDef processBox fill:#f8fafc,stroke:gray,stroke-width:0.5px,color:#2d3748,font-weight:bold + classDef component fill:white,stroke:#a0aec0,stroke-width:1px,color:#2d3748 + classDef paramBox fill:white,stroke:#3182ce,stroke-width:1px,color:#2d3748 + + %% Main flow + query["🔍 Query Text"] --> tokenize["⚡ Tokenization"] + tokenize --> stopwords["🚫 Stopword
Removal"] + stopwords --> scoring["📊 BM25
Scoring"] + + %% Parameters section + subgraph params["Parameter Configuration"] + direction TB + k1["k1: Term Frequency
Saturation Control"] + b["b: Document Length
Normalization"] + end + + params --> scoring + scoring --> results["📑 Ranked
Results"] + + %% Apply styles + class query,tokenize,stopwords,scoring,results component + class params processBox + class k1,b paramBox + + %% Linkstyle for curved edges + linkStyle default stroke:#718096,stroke-width:3px,fill:none,background-color:white +``` + +コレクション単位でカスタム `k1` と `b` を設定できます([設定方法](../../manage-collections/collection-operations.mdx#set-inverted-index-parameters))。 + + + +### キーワード検索オペレーター + +:::info `v1.31` で追加 +::: + +検索オペレーターは、オブジェクトが返されるために含まれていなければならないクエリ [トークン](../../search/bm25.md#set-tokenization) の最小数を定義します。 + +概念的には、 BM25 スコア計算結果にフィルターを適用するように動作します。使用可能なオペレーターは次のとおりです。 +- `and` : すべてのトークンがオブジェクトに存在する必要があります +- `or` : 少なくとも 1 つのトークンがオブジェクトに存在する必要があります。最小トークン数は `minimumOrTokensMatch` で設定可能です + +例として、`computer networking guide` という BM25 クエリを `and` オペレーターで実行した場合、`computer`、`networking`、`guide` のすべてのトークンを含むオブジェクトのみが返されます。対して、同じクエリを `or` オペレーターで実行すると、これらのトークンのうち少なくとも 1 つを含むオブジェクトが返されます。`or` オペレーターを `minimumOrTokensMatch` が `2` の設定で使用すると、少なくとも 2 つのトークンがオブジェクトに存在する必要があります。 + +指定がない場合、デフォルトのオペレーターは `or` で `minimumOrTokensMatch` は `1` です。つまり、オブジェクトが返されるには、少なくとも 1 つのトークンが存在する必要があります。 + +import BM25OperatorsLight from '../img/bm25_operators_light.png'; +import BM25OperatorsDark from '../img/bm25_operators_dark.png'; + + + +使用方法の詳細は [ハウツーページ](../../search/bm25.md#search-operators) を参照してください。 + +### 選択プロパティ + + BM25 クエリでは、スコア計算に含めるオブジェクトプロパティをオプションで指定できます。 + +デフォルトでは、すべての `text` プロパティが BM25 計算に含まれます。これを変更する方法は 2 つあります。 + +- コレクション設定でプロパティの [`indexSearchable` を `false` に設定](../../manage-collections/vector-config.mdx#property-level-settings) します。このプロパティはすべての BM25 検索で無視されます。 +- [クエリ時に検索対象プロパティを指定](../../search/bm25.md#search-on-selected-properties-only) します。これはそのクエリにのみ適用されます。 + +### プロパティ ブースト + +プロパティブーストを使用すると、クエリが最終的な BM25 スコアを計算する際にプロパティごとに異なる重みを設定できます。 + +これは、あるプロパティが他よりも検索において重要な場合に便利です。 + +例えば、 e-commerce カタログを検索する際、商品説明よりもタイトルやカテゴリに重みを付けることができます。 + + + +[プロパティの重み](../../search/bm25.md#use-weights-to-boost-properties) はクエリ時に設定します. +## ベクトル検索との組み合わせ + +キーワード検索は、 Weaviate でベクトル検索と組み合わせることでハイブリッド検索を実行できます。これにより、次の両方を活用できます。 +- キーワード検索の厳密一致機能 +- ベクトル検索のセマンティック理解能力 + +詳細は [ハイブリッド検索](./hybrid-search.md) をご覧ください。 + +## 注意点とベストプラクティス + +キーワード検索を使用する際の主な考慮事項は次のとおりです。 + +1. **トークナイザーの選択** + - データと検索要件に基づいて選択してください。たとえば、自然言語テキストには `word` トークナイザーを使用し、 URL やメールアドレスなどを丸ごと厳密一致させる必要がある場合は `field` を検討します。 + - 多言語コンテンツの場合、中国語/日本語向けの `GSE`、韓国語向けの `kagome_kr` などの専用トークナイザーを検討してください。 + - 特殊文字や大文字・小文字の区別の要否も考慮します。 + - 特殊文字や大文字・小文字が期待どおりに処理されるか確認するため、データとクエリのサブセットでトークナイザーをテストしてください。ベクトル化とキーワード検索は独立しているため、実験時にはベクトル化を無効にしてリソース/コストを節約できます。 + +2. **パフォーマンスの最適化** + - 検索に必要なプロパティだけをインデックス化します。 + - ユーザーの行動を事前に予測できない場合は特に、キーワード検索とベクトル検索を組み合わせた [ハイブリッド検索](./hybrid-search.md) を出発点として検討してください。 + +3. **クエリの最適化** + - 検索において重要度の高いプロパティ(例: タイトル、カテゴリ)には重み付けを行い、そうでないプロパティ(例: 説明)より優先させます。 + - ほとんどのユースケースではデフォルト値が適しているため、 `k1` と `b` の値は正当な理由がある場合のみ変更してください。 + +### 参考リソース + +- [How-to: Search](../../search/index.mdx) +- [How-to: Keyword search](../../search/bm25.md) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/vector-search.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/vector-search.md new file mode 100644 index 000000000..5d42ce18f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/search/vector-search.md @@ -0,0 +1,290 @@ +--- +title: ベクトル検索 +sidebar_position: 20 +description: "テキスト、画像、音声、マルチモーダル データ向けのベクトル埋め込みを用いた類似度ベースのセマンティック検索。" +image: og/docs/concepts.jpg +# tags: ['concepts', 'search', 'vector search', 'vector'] +--- + +ベクトル検索は、ベクトル埋め込み( embeddings )を用いた類似度ベースの検索です。ベクトル検索は、そのセマンティック(意味的)な類似性を基にオブジェクトを見つける能力から「セマンティック検索」とも呼ばれます。ただし、ベクトル検索はテキスト データに限定されません。画像、動画、音声など他のデータ タイプにも利用できます。 + +ベクトル埋め込みは、オブジェクトの意味情報をベクトル空間で表現したものです。これはオブジェクトの特徴を示す数値の集合で、ベクトルはこの目的のために学習されたベクトライザー モデルによって生成されます。 + +ベクトル検索では、[保存済みオブジェクトのベクトル](#object-vectors)と[クエリ ベクトル](#query-vectors)を比較し、最も近いものを見つけて上位 `n` 件の結果を返します。 + +:::tip ベクトル検索入門 +ベクトル検索が初めてですか?ブログ「[ベクトル検索の基礎](https://weaviate.io/blog/vector-search-explained)」で、ベクトル検索の概念とユースケースを紹介しています。 +::: + +## オブジェクト ベクトル + +ベクトル検索を行うには、各オブジェクトが代表的なベクトル埋め込みを持っている必要があります。 + +ベクトルを生成するモデルはベクトライザー モデル、またはエンベディング モデルと呼ばれます。 + +ユーザーは次の 2 通りの方法で、オブジェクトとそのベクトルを Weaviate に登録できます。 + +- Weaviate の[ベクトライザー モデルプロバイダー統合](#model-provider-integration)を使用してベクトルを生成する +- [ベクトルを直接提供](#bring-your-own-vector)して Weaviate に登録する + +### モデルプロバイダー統合 + +Weaviate は、[Cohere](../../model-providers/cohere/index.md)、[Ollama](../../model-providers/ollama/index.md)、[OpenAI](../../model-providers/openai/index.md) など、[主要なベクトライザー モデルプロバイダーとのファーストパーティ統合](../../model-providers/index.md)を提供します。 + +このワークフローでは、ユーザーが[コレクションにベクトライザーを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer)すると、オブジェクトの登録や検索時など必要に応じて Weaviate が自動的にベクトルを生成します。 + +```mermaid +%%{init: { + 'theme': 'base', + 'themeVariables': { + 'primaryColor': '#4a5568', + 'primaryTextColor': '#2d3748', + 'primaryBorderColor': '#718096', + 'lineColor': '#718096', + 'secondaryColor': '#f7fafc', + 'tertiaryColor': '#edf2f7', + 'fontFamily': 'Inter, system-ui, sans-serif', + 'fontSize': '14px', + 'lineHeight': '1.4', + 'nodeBorder': '1px', + 'mainBkg': '#ffffff', + 'clusterBkg': '#f8fafc' + } +}}%% + +flowchart LR + %% Style definitions + classDef systemBox fill:#f8fafc,stroke:#3182ce,stroke-width:1.5px,color:#2d3748,font-weight:bold + classDef weaviateBox fill:#f8fafc,stroke:gray,stroke-width:0.5px,color:#2d3748,font-weight:bold + classDef cloudBox fill:white,stroke:#48bb78,stroke-width:2px,color:#553c9a,font-weight:bold + classDef providerBox fill:#f8fafc,stroke:gray,stroke-width:0.5px,color:#2d3748,font-weight:bold + classDef component fill:white,stroke:#a0aec0,stroke-width:1px,color:#2d3748 + classDef edgeLabel fill:white,stroke:#e2e8f0,stroke-width:1px,color:#4a5568 + + %% Provider section + subgraph provider["Model provider"] + inference["🤖 Inference API /
Local model"] + end + + %% Weaviate section + subgraph weaviate["Weaviate"] + vectorizer["🔌 Model provider
integration"] + core["💾 Data &
vector store"] + end + + %% User System + subgraph user["🖥️ User System"] + data["📄 Data"] + end + + %% Connections with curved edges + data --->|"1\. Insert objects
(no vector)"| core + core --->|"2\. Request
vector"| vectorizer + vectorizer --->|"3\. Request
vector"| inference + inference --->|"4\. Vector"| vectorizer + vectorizer --->|"5\. Vector"| core + + %% Apply styles + class user systemBox + class weaviate weaviateBox + class cloud cloudBox + class provider providerBox + class data,core,vectorizer,inference component + + %% Linkstyle for curved edges + linkStyle default stroke:#718096,stroke-width:3px,fill:none,background-color:white +``` + +この統合により、ベクトル生成プロセスがユーザーから抽象化され、ユーザーはベクトル生成を意識せずにアプリケーションの開発や検索に集中できます。 + +:::info ベクトライザー設定は不変です + +一度設定すると、コレクションのベクトライザーは変更できません。これにより、ベクトルが一貫して生成され、互換性が保たれます。ベクトライザーを変更する必要がある場合は、目的のベクトライザーで新しいコレクションを作成し、[データを新しいコレクションへ移行](../../manage-collections/migrate.mdx)してください。 + +::: + +#### ベクトライザー設定時の手動ベクトル + +コレクションにベクトライザー モデルが設定されていても、オブジェクト登録やクエリ実行時にユーザーがベクトルを直接提供することが可能です。この場合、 Weaviate は新しいベクトルを生成せず、提供されたベクトルを使用します。 + +これは、同じモデルで既にベクトルを生成済みの場合(他システムからのインポートなど)に便利です。既存ベクトルを再利用することで、時間とリソースを節約できます。 + +### 独自ベクトルの持ち込み + +オブジェクトを登録する際に、ユーザーがベクトルを直接 Weaviate にアップロードできます。既にモデルでベクトルを生成している場合や、 Weaviate と統合されていない特定のベクトライザー モデルを使用したい場合に有用です。 + +```mermaid +%%{init: { + 'theme': 'base', + 'themeVariables': { + 'primaryColor': '#4a5568', + 'primaryTextColor': '#2d3748', + 'primaryBorderColor': '#718096', + 'lineColor': '#718096', + 'secondaryColor': '#f7fafc', + 'tertiaryColor': '#edf2f7', + 'fontFamily': 'Inter, system-ui, sans-serif', + 'fontSize': '14px', + 'lineHeight': '1.4', + 'nodeBorder': '1px', + 'mainBkg': '#ffffff', + 'clusterBkg': '#f8fafc' + } +}}%% + +flowchart LR + %% Style definitions + classDef systemBox fill:#f8fafc,stroke:#3182ce,stroke-width:1.5px,color:#2d3748,font-weight:bold + classDef weaviateBox fill:#f8fafc,stroke:gray,stroke-width:0.5px,color:#2d3748,font-weight:bold + classDef component fill:white,stroke:#a0aec0,stroke-width:1px,color:#2d3748 + classDef edgeLabel fill:white,stroke:#e2e8f0,stroke-width:1px,color:#4a5568 + + %% Weaviate section + subgraph weaviate["Weaviate"] + core["💾 Data &
vector store"] + end + + %% User System + subgraph user["🖥️ User System"] + data["📄 Data"] + end + + %% Connections with curved edges + data --->|"1\. Insert objects
(with vectors)"| core + + %% Apply styles + class user systemBox + class weaviate weaviateBox + class cloud cloudBox + class provider providerBox + class data,core,vectorizer,inference component + + %% Linkstyle for curved edges + linkStyle default stroke:#718096,stroke-width:3px,fill:none,background-color:white +``` + +このワークフローでは、ユーザーは任意のベクトライザー モデルやプロセスを Weaviate とは独立して使用できます。 + +独自モデルを使用する場合、ベクトライザー設定で `none` を明示的に指定し、誤って互換性のないベクトルを生成しないようにすることを推奨します。 + +### 名前付きベクトル + +:::info Added in `v1.24` +::: + +コレクションは設定により、各オブジェクトを複数のベクトル埋め込みで表現できます。 + +それぞれのベクトルは互いに独立したベクトル空間として機能し、「名前付きベクトル」と呼ばれます。 + +名前付きベクトルは、[ベクトライザーモデル統合](#model-provider-integration)で設定することも、「[独自ベクトルの持ち込み](#bring-your-own-vector)」で提供することも可能です。 + +## クエリ ベクトル + + Weaviate では、次の方法でクエリ ベクトルを指定できます。 + +- クエリ ベクトル( `nearVector` ) +- クエリ オブジェクト( `nearObject` ) +- クエリ テキスト( `nearText` ) +- クエリ メディア( `nearImage` または `nearVideo` ) + +いずれの場合も、クエリと保存済みオブジェクトのベクトルを基に、最も類似したオブジェクトが返されます。ただし、 Weaviate にクエリ ベクトルをどのように渡すかが異なります。 + +### `nearVector` + +`nearVector` クエリでは、ユーザーがベクトルを直接 Weaviate に渡します。このベクトルと保存済みオブジェクトのベクトルを比較して、最も類似したオブジェクトを検索します。 + +### `nearObject` + +`nearObject` クエリでは、ユーザーがオブジェクト ID を Weaviate に渡します。 Weaviate はそのオブジェクトのベクトルを取得し、保存済みオブジェクトのベクトルと比較して最も類似したオブジェクトを検索します。 + +### `nearText`(および `nearImage`、`nearVideo`) + +`nearText` クエリでは、ユーザーがテキストを Weaviate に渡します。 Weaviate は指定されたベクトライザー モデルを使用してテキストのベクトルを生成し、保存済みオブジェクトのベクトルと比較して最も類似したオブジェクトを検索します。 + +そのため、 `nearText` クエリはベクトライザー モデルが設定されているコレクションでのみ利用できます。 + +`nearImage` や `nearVideo` クエリも `nearText` と同様ですが、テキストの代わりに画像や動画を入力します。 + +## マルチターゲット ベクトル検索 + +:::info Added in `v1.26` +::: + +マルチターゲット ベクトル検索では、 Weaviate が複数のシングルターゲット ベクトル検索を同時に実行します。 + +これらの検索は、それぞれベクトル距離スコアを持つ複数の結果セットを生成します。 + + Weaviate は、["結合戦略"]( #available-join-strategies )を用いてこれらの結果セットを結合し、各結果の最終スコアを算出します。 + +オブジェクトがいずれかのターゲット ベクトルで検索リミットまたは距離しきい値内に入る場合、そのオブジェクトは検索結果に含まれます。 + +オブジェクトが選択されたターゲット ベクトルのいずれについてもベクトルを含まない場合、 Weaviate はそのオブジェクトを無視し、検索結果に含めません。 + +### 利用可能な結合戦略 + +- **minimum** (*default*) すべてのベクトル距離の最小値を使用します。 +- **sum** ベクトル距離の合計を使用します。 +- **average** ベクトル距離の平均を使用します。 +- **manual weights** 各ターゲット ベクトルに指定された重みを掛けた距離の合計を使用します。 +- **relative score** 各ターゲット ベクトルに指定された重みを掛けた正規化距離の合計を使用します。 +## ベクトルインデックスと検索 + +Weaviate は ベクトル検索 を効率化するために ベクトルインデックス を使用します。ほかの種類のインデックスと同様に、ベクトルインデックス は ベクトル埋め込み を高速に取得できるよう整理しつつ、検索品質(例: リコール)、スループット、メモリなどのリソース使用を最適化します。 + +Weaviate では `hnsw`、`flat`、`dynamic` など、複数種類の ベクトルインデックス を利用できます。 + +各 [コレクション](../data.md#collections) や [テナント](../data.md#multi-tenancy) は、それぞれ独自の ベクトルインデックス を持ちます。さらに、各コレクションまたはテナントは、異なる設定を持つ [複数の ベクトルインデックス](../data.md#multiple-vector-embeddings-named-vectors) を併用できます。 + +:::info +詳しくは次をご覧ください: +- [コレクション](../data.md#collections) +- [マルチテナンシー](../data.md#multi-tenancy) +- [ベクトルインデックス](../indexing/vector-index.md) +- [複数の名前付きベクトル](../data.md#multiple-vector-embeddings-named-vectors) +::: + +### 距離指標 + +ベクトル間の距離を測定する方法には、コサイン距離、ドット積、ユークリッド距離など多くの種類があります。Weaviate は、[距離指標](../../config-refs/distances.md) ページに記載されているさまざまな距離指標をサポートします。各 ベクトライザー モデルは特定の距離指標で学習されているため、検索時にも同じ距離指標を使用することが重要です。 + +Weaviate では、一般的な距離指標である コサイン距離 がデフォルトで使用されます。 + +:::tip Distance vs Similarity +「距離」では値が小さいほどベクトル同士が近く、「類似度」または「確信度」では値が大きいほど近くなります。コサイン距離のように、距離を類似度として表現できる指標もあれば、ユークリッド距離のように距離でしか表現できない指標もあります。 +::: + +## 注意事項とベストプラクティス + +互換性のあるベクトルは、程度の差こそあれ必ず何らかの類似性を持っています。 + +これには次の 2 つの影響があります。 + +1. 関連性に関係なく、常に「トップ」の検索結果が存在します。 +2. データセット全体が常に返されます。 + +たとえば、「Red」「Crimson」「LightCoral」という色のベクトルが保存されたデータベースに対して、「SkyBlue」のクエリベクトルで検索すると、たとえ意味的に近くなくても最も近い結果(例: 「Red」)が返ってきます。検索は絶対的に良い一致かどうかではなく、あくまで最も近い一致を返すためです。 + +そのため、Weaviate では検索結果を制限する複数の方法を提供しています。 + +- **Limit**: 返却する最大件数を指定します。 + - 指定しない場合、システム既定の [`QUERY_DEFAULTS_LIMIT`](/deploy/configuration/env-vars/index.md#general) である 10 が使用されます。 +- **AutoCut**: ベクトル距離や検索スコアなどの結果メトリクスの不連続性を基に結果を制限します。 +- **Threshold**: 最小類似度(例: コサイン距離の最大値)を指定します。 +- **フィルターを適用**: メタデータやプロパティなど、他の条件に基づいて結果を除外するために [フィルター](../filtering.md) を使用します。 + +これらの方法を組み合わせて、ユーザーにとって意味があり関連性の高い検索結果を提供してください。 + +一般的には、まず `limit` でユーザーに提示する最大件数を設定し、`threshold` を調整して無関係な結果が返りにくいようにします。 + +これにより、指定した件数(`limit`)まで、かつ指定した類似度(`threshold`)以上の結果のみが返されます。 + +### 参考リソース + +- [How-to: Search](../../search/index.mdx) +- [How-to: Vector similarity search](../../search/similarity.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/storage.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/storage.md new file mode 100644 index 000000000..d8d12cc66 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/storage.md @@ -0,0 +1,129 @@ +--- +title: ストレージ +sidebar_position: 18 +description: "オブジェクト、 ベクトル、 転置インデックス管理のための永続的で障害耐性のあるストレージアーキテクチャ。" +image: og/docs/concepts.jpg +# tags: ['architecture', 'storage'] +--- + +Weaviate は永続的で障害耐性のあるデータベースです。 +このページでは、 Weaviate 内でオブジェクトとベクトルがどのように保存され、インポート時に転置インデックスがどのように作成されるかを概観します。 + +ここで取り上げるコンポーネントは、 Weaviate が以下のような独自機能を実現するのに役立っています。 + +* 各書き込み操作は即座に永続化され、アプリケーションやシステムのクラッシュにも耐性があります。 +* ベクトル検索クエリでは、 Weaviate は ID などの参照だけでなくオブジェクト全体(他のデータベースでは「ドキュメント」と呼ばれることもあります)を返します。 +* 構造化検索とベクトル検索を組み合わせる場合、フィルターはベクトル検索の前に適用されます。これにより、後段でフィルタリングして結果数が予測できなくなるのではなく、常に指定した件数を取得できます。 +* オブジェクトとそのベクトルは、読み取り中であっても自由に更新・削除できます。 + +## 論理ストレージ単位: インデックス、シャード、ストア + +ユーザー定義スキーマ内の各クラスは、内部的にはインデックスの作成につながります。 +インデックスは 1 つ以上のシャードで構成されるラッパー型です。シャードは自己完結型のストレージ単位であり、複数シャードを利用すると負荷を複数サーバーノードへ自動的に分散できます。 + +### シャードの構成要素 + +各シャードには 3 つの主要コンポーネントがあります。 + +* オブジェクトストア (実質的にはキー・バリュー ストア) +* [転置インデックス](https://en.wikipedia.org/wiki/Inverted_index) +* ベクトルインデックスストア (プラガブルで、現在は [HNSW のカスタム実装](/weaviate/config-refs/indexing/vector-index.mdx#hnsw-index)) + +#### オブジェクトストアと転置インデックスストア + +`v1.5.0` 以降、オブジェクトストアと転置ストアは [LSM-Tree アプローチ](https://en.wikipedia.org/wiki/Log-structured_merge-tree) を採用しています。 +これにより、データはメモリ速度で取り込まれ、設定したしきい値に達すると Weaviate はメモリテーブル (memtable) 全体をソートした状態でディスクセグメントに書き込みます。読み取り要求が来ると、 Weaviate はまず memtable を確認し、対象オブジェクトの最新更新を探します。 memtable にない場合は、最新のセグメントから順に確認します。不要なセグメントを調べないようにするため、 [Bloom フィルター](https://en.wikipedia.org/wiki/Bloom_filter) を使用します。 + +Weaviate は定期的に古い小さなセグメントをマージして大きなセグメントを作成します。セグメントはすでにソートされているため、この操作は比較的低コストで、常にバックグラウンドで実行されます。セグメント数が少なく大きくなることで検索効率が向上します。転置インデックスではデータが置き換わることはほとんどなく、追加が主です。マージにより、過去の複数セグメントを走査して結果を集約するのではなく、 1 つ (または少数) のセグメントを参照するだけで関連オブジェクトポインタを即座に見つけられます。また、削除や更新によって古くなったオブジェクトの以前のバージョンをセグメントから除去できます。 + +考慮事項 + +* オブジェクトストレージと転置インデックスストレージは LSM アルゴリズムを実装しており、セグメンテーションを採用します。 +* ベクトルインデックスは異なるストレージアルゴリズムを用い、セグメンテーションを行いません。 + +`v1.5.0` より前の Weaviate バージョンでは B+Tree ストレージ機構を使用していました。 LSM 方式は高速で、時間計算量が一定となり、書き込み性能が向上します。 + +Weaviate の LSM ストアについて詳しくは、 [Go パッケージリポジトリ](https://pkg.go.dev/github.com/weaviate/weaviate/adapters/repos/db/lsmkv) のドキュメントをご覧ください。 + +#### HNSW ベクトルインデックスストレージ + +各シャードには、オブジェクトストアおよび転置インデックスストアに対応するベクトルインデックスが含まれます。ベクトルストアと他のストアは独立しており、ベクトルストアはセグメンテーションを管理する必要がありません。 + +ベクトルインデックスをオブジェクトストレージと同じシャードにまとめることで、各シャードを独立してリクエストを処理できる完全なユニットにできます。また、ベクトルインデックスをオブジェクトストアの「隣」に配置し (内部に入れず)、ベクトルインデックスをセグメント化することによるデメリットを回避しています。 + +さらに、 [永続化とクラッシュリカバリ](#persistence-and-crash-recovery) で詳述する Write-Ahead-Logging と HNSW スナップショットを組み合わせることで、永続化と起動時のロードを最適化しています。 + +### シャード構成要素の最適化 + +Weaviate のストレージ機構は、構造化/オブジェクトデータに対してセグメンテーションを使用します。セグメントは低コストでマージでき、 Bloom フィルターのおかげで未マージのセグメントでも効率的に走査できます。その結果、取り込み速度は高く、時間が経っても低下しません。 + +Weaviate はシャード内のベクトルインデックスを可能な限り大きく保ちます。 HNSW インデックスは効率的にマージできないため、小さいインデックスを多数順番に検索するより、 1 つの大きなインデックスを検索する方が効率的です。 + +CPU を効率良く使うには、コレクションに複数シャードを作成してください。最速でインポートしたい場合は、単一ノードでも複数シャードを作成することを推奨します。 + +### レイジーシャードロード + +:::info Added in `v1.23` +::: + +Weaviate 起動時には、デプロイ内のすべてのシャードからデータをロードします。このプロセスは時間がかかる場合があります。 `v1.23` 以前は、すべてのシャードがロード完了するまでデータをクエリできませんでした。各テナントが 1 シャードであるため、マルチテナント環境では再起動後の可用性が低下する可能性があります。 + +レイジーシャードロードにより、より早くデータにアクセスできます。再起動後、シャードはバックグラウンドでロードされます。クエリしたいシャードがすでにロード済みであれば、すぐに結果を取得できます。未ロードの場合、 Weaviate はそのシャードのロードを優先し、準備完了後にレスポンスを返します。 + +レイジーシャードロードを有効にするには、システム設定ファイルで `DISABLE_LAZY_LOAD_SHARDS` 環境変数を `false` に設定してください。 + +:::caution シングルテナントコレクションでは無効化を推奨 +シングルテナントコレクションでは、レイジーシャードロードがインポート操作を遅延または部分的失敗させる場合があります。そのようなシナリオでは、レイジーシャードロードを無効化することを推奨します。 +::: + +## 永続化とクラッシュリカバリ + +### Write-Ahead-Log + +オブジェクトおよび転置ストレージで使用する LSM ストアと、 HNSW ベクトルインデックスストアは、取り込み処理の途中でメモリを利用します。クラッシュ時のデータ損失を防ぐため、各操作は **[Write-Ahead-Log (WAL)](https://martinfowler.com/articles/patterns-of-distributed-systems/wal.html)** (コミットログとも呼ばれます) に追加で書き込まれます。 WAL は追記専用ファイルで書き込みが非常に高速であり、取り込みのボトルネックになることはほとんどありません。 + +Weaviate が取り込みリクエストへ成功ステータスを返す時点で、 WAL エントリは必ず作成されています。たとえばディスクが満杯で WAL エントリを作成できない場合、 Weaviate は挿入または更新リクエストにエラーで応答します。 + +LSM ストアは正常終了時にセグメントのフラッシュを試みます。操作が成功した場合のみ、 WAL は「完了」とマークされます。予期しないクラッシュが発生し Weaviate が「未完了」の WAL を検出した場合、これをリカバリします。リカバリプロセスでは、 WAL を基に新しいセグメントをフラッシュし、完了としてマークします。そのため、次回起動時にはこの WAL から復旧する必要がなくなります。 + +HNSW ベクトルインデックスにおいて、 Write-Ahead-Log (WAL) は災害復旧と最新変更の永続化に不可欠です。 HNSW インデックス構築のコストは、新規オブジェクトをどこに配置し隣接ノードとどうリンクするかを決定する計算にあります。 WAL にはその計算結果のみが格納されます。 + +WAL エントリをリプレイすることで、 HNSW インデックスの全状態を再構成できます。 + +数千万~数億規模の大規模インデックスでは、これは時間を要する場合があります。大規模インデックスで起動時間を短縮したい場合は、 **[HNSW スナップショット](../configuration/hnsw-snapshots.md)** 機能をご利用ください。 + +### HNSW スナップショット + +:::info Added in `v1.31` +::: + +巨大な HNSW ベクトルインデックスを持つ場合、 HNSW スナップショットによって起動時間を大幅に短縮できます。 + +スナップショットは HNSW インデックスの時点状態を表します。 Weaviate 起動時に有効なスナップショットが存在すれば、まずそれをメモリにロードします。これにより、 WAL からリプレイすべきエントリ数がスナップショット取得後の変更分だけに減り、起動が高速化されます。 + +スナップショットが何らかの理由でロードできない場合、安全に削除され、 Weaviate は従来通りコミットログ全体の読み込みへフォールバックします。 + +スナップショットは起動時と、経過時間またはコミットログの変化量に基づき定期的に作成されます。 + +起動時に前回スナップショット以降のコミットログに変更があれば、新しいスナップショットを作成します。変更がなければ既存スナップショットをロードします。 + +設定した時間間隔が経過し、十分な新規コミットが存在する場合にもスナップショットを作成します。これはコミットログの結合・圧縮を行うバックグラウンドプロセスと同じプロセスが担当し、スナップショット作成中に使用するコミットログは不変であるため安定性が保たれます。 + +各新規 HNSW スナップショットは、前回スナップショットとそれ以降の新しい (デルタ) コミットログを基に作成されます。 + +最新スナップショットがあっても、サーバーは通常少なくとも 1 つのそれ以降のコミットログをロードする必要があります。 + +WAL は依然としてすべての変更を即座に永続化し、応答済みの書き込みが失われないことを保証します。時間が経つと、最後のスナップショット以降の操作に関して WAL には冗長情報が蓄積します。バックグラウンドプロセスがこれらの WAL を継続的にコンパクトし、冗長情報を排除します。これとスナップショットにより、ディスク使用量を抑えつつ起動時間を高速に保ちます。 + +この機能の詳細設定は **[HNSW スナップショットの設定](../configuration/hnsw-snapshots.md)** をご覧ください。 + +`v1.31` 現在、 HNSW スナップショットはデフォルトで無効です。 + +## まとめ + +本ページでは Weaviate のストレージ機構を紹介しました。すべての書き込みが即時永続化されるしくみと、データセットをスケールさせるために Weaviate が用いているパターンを説明しました。構造化データではセグメンテーションを用いて書き込み時間を一定に保ち、 HNSW ベクトルインデックスではセグメンテーションを避けることでクエリ時間を効率化しています。 +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/vector-quantization.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/vector-quantization.md new file mode 100644 index 000000000..f71064e3e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/concepts/vector-quantization.md @@ -0,0 +1,186 @@ +--- +title: 圧縮(ベクトル量子化) +sidebar_position: 19 +description: "メモリ フットプリントを削減しつつ検索速度を向上させるベクトル圧縮技術。" +image: og/docs/concepts.jpg +# tags: ['vector compression', 'quantization'] +--- + +**ベクトル量子化** は、[vector index](./indexing/vector-index.md) に格納されるベクトル埋め込みを圧縮することでメモリ フットプリントを削減し、デプロイ コストを抑えながらベクトル類似度検索の速度を向上させます。 + +Weaviate では現在、以下の 4 つのベクトル量子化手法を提供しています。 + +- [バイナリ量子化 (BQ)](#binary-quantization) +- [直積量子化 (PQ)](#product-quantization) +- [スカラー量子化 (SQ)](#scalar-quantization) +- [回転量子化 (RQ)](#rotational-quantization) + +## 量子化 + +一般に量子化技術は、数値をより低い精度で表現することでメモリ フットプリントを削減します。たとえば数値を最も近い整数に丸めるような操作です。ニューラル ネットワークでは、モデルの重みや活性化を 32 ビット浮動小数点数(4 バイト)から 8 ビット整数(1 バイト)などの低精度数値に変換してメモリを節約します。 + +### ベクトル量子化 + +ベクトル量子化は、ベクトル埋め込み自体のメモリ フットプリントを削減する技術です。ベクトル埋め込みは通常 32 ビット浮動小数点数で表現されますが、量子化によって 8 ビット整数やバイナリ数などの小さな数値で表現できます。手法によってはベクトルの次元数も削減されます。 + +## 直積量子化 + +[Product quantization](https://ieeexplore.ieee.org/document/5432202) は、Weaviate の `hnsw` インデックスで使用できる多段階の量子化手法です。 + +PQ は各ベクトル埋め込みを 2 段階で小さくします。まずベクトル次元をより小さな「セグメント」に分割し、その後各セグメントを元のビット数(通常 32 ビット float)より少ないビット数に量子化します。 + +import PQTradeoffs from '/_includes/configuration/pq-compression/tradeoffs.mdx' ; + + + +PQ では、元のベクトル埋め込みを複数の小さなベクトル(セグメントまたはサブスペース)に分割し、それらを直積として表現します。その後、各セグメントを独立に量子化して圧縮ベクトルを生成します。 + +![PQ の概要図](./img/pq-illustrated.png "PQ の概要図") + +セグメント作成後、`centroids` を計算するためのトレーニング ステップがあります。既定では各セグメントを 256 個のセントロイドにクラスタリングし、これらのセントロイドによってコードブックを生成します。以降の圧縮処理では、このコードブック内で最も近いセントロイドの ID を用いて各ベクトル セグメントを表現します。 + +たとえば、各ベクトルが 768 要素(各 4 バイト)のコレクションを考えます。PQ 圧縮前は 1 ベクトルにつき `768 × 4 = 3 072` バイト必要ですが、圧縮後は `128 × 1 = 128` バイトで済みます。元の表現は PQ 圧縮版のほぼ 24 倍のサイズです(コードブックのわずかなオーバーヘッドは除く)。 + +PQ を有効化する方法は [Enable PQ compression](/weaviate/configuration/compression/pq-compression#enable-pq-compression) を参照してください。 + +### セグメント + +`segments` パラメーターはメモリ使用量とリコールのトレードオフを制御します。値を大きくするとメモリ使用量とリコールが向上します。なお、セグメント数は元のベクトル次元数を割り切れる必要があります。 + +代表的なベクトライザー モジュールで利用可能なセグメント値は次のとおりです。 + +| モジュール | モデル | 次元数 | セグメント数 | +|-----------------|------------------------------------------|--------|----------------------------------| +| openai | text-embedding-ada-002 | 1 536 | 512, 384, 256, 192, 96 | +| cohere | multilingual-22-12 | 768 | 384, 256, 192, 96 | +| huggingface | sentence-transformers/all-MiniLM-L12-v2 | 384 | 192, 128, 96 | + +### PQ 圧縮プロセス + +PQ にはコードブックを生成するトレーニング ステージがあります。シャードごとに 10 000 ~ 100 000 件のレコードでのトレーニングを推奨します。トレーニングは手動または自動で起動できます。詳細は [Configuration: Product quantization](../configuration/compression/pq-compression.md) を参照してください。 + +トレーニングが開始されるとバックグラウンド ジョブがインデックスを圧縮インデックスへ変換します。変換中はインデックスが読み取り専用となり、完了するとシャードのステータスが `READY` に戻ります。 + +Weaviate はトレーニングに `trainingLimit` 件まで(シャードごと)のオブジェクトしか使用しません。対象数が多くても上限で切り捨てます。 + +変換完了後は通常どおり検索や書き込みが行えます。ただし量子化の影響で距離がわずかに変化する場合があります。 + +:::info どのオブジェクトがトレーニングに使われますか? +- (`v1.27` 以降) コレクション内のオブジェクト数がトレーニング上限を超える場合、Weaviate はランダムにサンプリングしてコードブックを学習します。 + - (`v1.26` 以前) コレクションの先頭から `trainingLimit` 件を使用します。 +- コレクションのオブジェクト数がトレーニング上限未満の場合は、すべてのオブジェクトを使用します。 +::: + +### エンコーダー + +上記設定では `encoder` オブジェクトでセントロイド生成方法を指定できます。既定の `kmeans` は従来の手法です。 + +実験的な `tile` エンコーダーも利用可能です。SIFT や GIST などのデータセットで高速インポートと高いリコールを示しています。`tile` にはセントロイド生成時の `distribution` パラメーターがあります。`type` を `tile` または `kmeans` に設定してエンコーダーを選択してください。設定詳細は [Configuration: Vector index](../config-refs/indexing/vector-index.mdx) を参照してください。 + +### 距離計算 + +Product quantization では問い合わせベクトルは非圧縮のまま保持し、非対称的に距離計算を行います。これにより精度を保ちながら計算量を削減します。 + +:::tip +Weaviate での product quantization の設定方法は [こちら](../configuration/compression/pq-compression.md) をご覧ください。

+ブログ記事「[How to Reduce Memory Requirements by up to 90%+ using Product Quantization](https://weaviate.io/blog/pq-rescoring)」も参考になります。 +::: + +## バイナリ量子化 + +**Binary quantization (BQ)** は各ベクトル埋め込みをバイナリ表現へ変換する量子化手法です。通常 1 次元あたり 32 ビットを要しますが、バイナリ表現では 1 ビットで済むため、ストレージ要求を 32 倍削減できます。その結果、ディスクから読み込むデータ量が減少し、距離計算も簡素化されるため検索速度が向上します。 + +代償として BQ はロスの大きい手法です。バイナリ表現では情報が大幅に失われるため、距離計算の精度は元のベクトル埋め込みより低下します。 + +ベクトライザーによって BQ との相性は異なります。経験的には Cohere の V3 モデル(例: `embed-multilingual-v3.0`、`embed-english-v3.0`)や OpenAI の `ada-002` モデルで良好なリコールを確認しています。ご自身のデータとベクトライザーでテストし、適合性をご判断ください。 + +BQ を有効にするとベクトル キャッシュを用いたクエリ性能向上が可能です。キャッシュは量子化済みベクトルのディスク読み込みを減らして検索を高速化しますが、各ベクトルが `n_dimensions` ビットを占有するためメモリ使用量とのバランスが必要です。 + +## スカラー量子化 + +**Scalar quantization (SQ)** では、ベクトル埋め込みの各次元を 32 ビット float から 8 ビット整数へ変換します。これによりサイズを 4 倍圧縮できます。 + +SQ も BQ と同様にロスのある圧縮ですが、表現範囲が大きく、精度が高い点が特徴です。データを分析して値域を決定し、その範囲を 256 個(8 ビット)のバケットに一様分割します。各次元の値は該当バケットの番号(8 ビット整数)で表現されます。 + +トレーニング セットのサイズは設定可能で、既定はシャードあたり 100 000 件です。 + +SQ が有効な場合、Weaviate は圧縮結果を多めに取得してからオリジナルの非圧縮ベクトルで再スコアリングし、リコールを向上させます。再検索は対象が少数のため高速です。 + +## 回転量子化 + +:::caution Technical preview + +Rotational quantization (RQ) は **`v1.32`** で **技術プレビュー** として追加されました。

+今後のリリースで仕様変更や破壊的変更が発生する可能性があります。 +**本番環境での使用は現時点では推奨していません。** + +::: + +**Rotational quantization (RQ)** はトレーニング不要の 8 ビット量子化手法で、4 倍の圧縮率を保ちつつ多くのデータセットで 98–99 % のリコールを維持します。RQ はインデックス作成時にすぐ有効化でき、以下 2 ステップで動作します。 + +1. **高速疑似乱数回転**: 入力ベクトルに Walsh Hadamard Transform を利用した高速回転を適用します。1 536 次元ベクトルで約 7–10 µs です。出力次元は 64 の倍数へ切り上げられます。 +2. **スカラー量子化**: 回転後の各エントリを 8 ビット整数に量子化します。各ベクトル個別の最小値と最大値が量子化区間を決定します。 + +回転ステップにより量子化区間が短縮され誤差が減少し、距離情報が均等に分散されます。 + +なお、次元数が 64 未満または 128 未満の低次元データでは、64 の倍数へ切り上げるため圧縮効率が最適でない可能性があります。 + +本実装は extended RaBitQ に着想を得ていますが、パフォーマンス上の理由で大きく異なります。真の乱数回転ではなく高速疑似乱数回転を用い、RaBitQ の符号化ではなくスカラー量子化を採用しています(ビット数が多い場合 RaBitQ は非常に遅くなるため)。 + +:::tip +Weaviate での回転量子化の設定方法は [こちら](../configuration/compression/rq-compression.md) をご覧ください。 +::: + +## 過剰フェッチ / リスコアリング + +Weaviate は、 SQ、 RQ、 BQ を使用する場合に結果を過剰フェッチし、その後でリスコアリングを行います。これは、圧縮された ベクトル での距離計算が、元の ベクトル 埋め込みでの計算ほど正確ではないためです。 + +クエリを実行すると、 Weaviate はクエリの limit を設定可能な `rescoreLimit` パラメーターと比較します。 + +クエリは、いずれか大きいほうの上限に達するまで圧縮オブジェクトを取得します。その後、 Weaviate は圧縮 ベクトル に対応する元の非圧縮 ベクトル 埋め込みを取得し、それらを使ってクエリ距離スコアを再計算します。 + +たとえば、 limit が 10、 rescoreLimit が 200 のクエリの場合、 Weaviate は 200 件のオブジェクトを取得します。リスコアリング後、クエリは上位 10 件のオブジェクトを返します。このプロセスにより、圧縮によって発生する検索品質(リコール)の低下が補正されます。 + +:::note RQ 最適化 +RQ のネイティブリコールは 98〜99% と高いため、多くの場合リスコアリングを無効化( `rescoreLimit` を 0 に設定)しても、検索品質への影響を最小限に抑えながらクエリ性能を最大化できます。 +::: + +## ベクトルインデックスを用いたベクトル圧縮 + +### HNSW インデックスとの併用 + +[HNSW インデックス](./indexing/vector-index.md#hierarchical-navigable-small-world-hnsw-index) は、 [PQ](#product-quantization)、 [SQ](#scalar-quantization)、 [RQ](#rotational-quantization)、 [BQ](#binary-quantization) を使用して構成できます。HNSW はメモリ内インデックスであるため、圧縮によってメモリ使用量を削減したり、同じメモリ量でより多くのデータを保存したりできます。 + +:::tip +当社ブログ記事 [HNSW+PQ - Exploring ANN algorithms Part 2.1](https://weaviate.io/blog/ann-algorithms-hnsw-pq) もぜひご覧ください。 +::: + +### フラットインデックスとの併用 + +[BQ](#binary-quantization) は [フラットインデックス](./indexing/inverted-index.md) を使用できます。フラットインデックス検索はディスクから読み込むため、圧縮によって読み込むデータ量が減り、検索が高速化されます。 + +## リスコアリング + +量子化では情報の精度が下がるため、必然的に情報損失が発生します。これを軽減するために、 Weaviate はリスコアリングと呼ばれる手法を用います。圧縮 ベクトル とともに保存されている非圧縮 ベクトル を使用し、初回検索で返された候補の元の ベクトル 間の距離を再計算します。これにより、最も正確な結果がユーザーに返されます。 + +場合によっては、リスコアリングが過剰フェッチも伴い、初回検索で上位候補が欠落しないよう追加の候補を取得します。 + +## 参考リソース + +:::info Related pages +- [概念: インデックス化](./indexing/index.md) +- [概念: ベクトルインデックス](./indexing/vector-index.md) +- [設定: ベクトルインデックス](../config-refs/indexing/vector-index.mdx) +- [設定: スキーマ(意味インデックスの設定)](../config-refs/indexing/vector-index.mdx#configure-semantic-indexing) +- [設定方法: バイナリ量子化(圧縮)](../configuration/compression/bq-compression.md) +- [設定方法: 直積量子化(圧縮)](../configuration/compression/pq-compression.md) +- [設定方法: スカラー量子化(圧縮)](../configuration/compression/sq-compression.md) +- [設定方法: 回転量子化(圧縮)](../configuration/compression/rq-compression.md) +- [Weaviate Academy: 250 Vector Compression](../../academy/py/compression/index.md) +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/collections.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/collections.mdx new file mode 100644 index 000000000..52f275bd7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/collections.mdx @@ -0,0 +1,953 @@ +--- +title: コレクション定義 +description: Weaviate のコレクションパラメーターリファレンス。 +--- + +import SkipLink from "/src/components/SkipValidationLink"; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/config-refs/reference.collections.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.ts"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.classes.java"; +import JavaReplicationCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.replication.java"; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.classes_test.go"; +import PyCodeMultiTenancy from "!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.py"; +import TSCodeMultiTenancy from "!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.ts"; +import JavaCodeMultiTenancy from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.multi-tenancy.java"; +import GoCodeMultiTenancy from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.multi-tenancy_test.go"; + +**コレクション定義** は、Weaviate におけるデータオブジェクトの保存方法とインデックス方法を指定します。このページでは、コレクションを構成するために利用できるパラメーターについて説明します。 + +## コレクション定義パラメーター + +以下は、コレクションを作成する際に設定できるトップレベルのパラメーターです。 + +| パラメーター | 型 | 説明 | デフォルト | 変更可 | +| :------------------------------------------- | :----- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------ | +| [`class`](#class) | String | コレクションの名前。 | (必須) | No | +| [`description`](#description) | String | コレクションの説明。 | `""` | Yes | +| [`properties`](#properties) | Array | データスキーマを定義するプロパティオブジェクトの配列。 | `[]` | Partially\* | +| [`invertedIndexConfig`](#inverted-index) | Object | フィルタリングやキーワード検索に影響する 転置インデックス の設定。 | [Inverted Index リファレンス](./indexing/inverted-index.mdx#inverted-index-parameters) を参照 | Yes | +| [`vectorConfig`](#vector-configuration) | Object | それぞれに `vectorizer`、`vectorIndexType`、`vectorIndexConfig` フィールドを持つ複数の名前付き ベクトル を設定。 | `null` | Partially\*\* | +| [`vectorizer`](#vector-configuration) | String | 使用する ベクトライザー モジュール。 | [環境変数](/deploy/configuration/env-vars#DEFAULT_VECTORIZER_MODULE) で定義されたデフォルトベクトライザー。モジュール固有の既定値は [Model provider](../model-providers/index.md) を参照 | No | +| [`vectorIndexType`](#vector-configuration) | String | 使用する ベクトル インデックスのタイプ(`hnsw`、`flat`、`dynamic`)。 | `hnsw` | No | +| [`moduleConfig`](#module-configuration) | Object | モジュール固有の設定。 | [Module configuration](#module-configuration) を参照 | Partially | +| [`vectorIndexConfig`](#vector-configuration) | Object | 選択した `vectorIndexType` 固有の設定。 | [Vector index リファレンス](./indexing/vector-index.mdx) を参照 | Partially | +| [`shardingConfig`](#sharding) | Object | マルチノードクラスターにおけるシャーディング動作を制御。 | [Sharding セクション](#sharding) を参照 | No | +| [`replicationConfig`](#replication) | Object | 障害耐性のためのデータレプリケーション設定。 | [Replication セクション](#replication) を参照 | Partially | +| [`multiTenancyConfig`](#multi-tenancy) | Object | コレクションでマルチテナンシーを有効にする設定。 | [Multi-tenancy セクション](#multi-tenancy) を参照 | Partially | + +\* [新しいプロパティを追加できます](../manage-collections/collection-operations.mdx#add-a-property)。既存のプロパティは変更できません +\*\* [新しい名前付き ベクトル を追加できます](../manage-collections/vector-config.mdx#add-new-named-vectors)。一部の ベクトル インデックス設定は変更可能です + +
+ コレクション設定例 - JSON オブジェクト + +プロパティを含む完全なコレクションオブジェクトの例: + +```json +{ + "class": "Article", // The name of the collection in string format + "description": "An article", // A description for your reference + "vectorIndexType": "hnsw", // Defaults to hnsw + "vectorIndexConfig": { + ... // Vector index type specific settings, including distance metric + }, + "vectorizer": "text2vec-contextionary", // Vectorizer to use for data objects added to this collection + "moduleConfig": { + "text2vec-contextionary": { + "vectorizeClassName": true // Include the collection name in vector calculation (default true) + } + }, + "properties": [ // An array of the properties you are adding, same as a Property Object + { + "name": "title", // The name of the property + "description": "title of the article", // A description for your reference + "dataType": [ // The data type of the object as described above. When + // creating cross-references, a property can have + // multiple data types, hence the array syntax. + "text" + ], + "moduleConfig": { // Module-specific settings + "text2vec-contextionary": { + "skip": true, // If true, the whole property will NOT be included in + // vectorization. Default is false, meaning that the + // object will be NOT be skipped. + "vectorizePropertyName": true, // Whether the name of the property is used in the + // calculation for the vector position of data + // objects. Default false. + } + }, + "indexFilterable": true, // Optional, default is true. By default each property + // is indexed with a roaring bitmap index where + // available for efficient filtering. + "indexSearchable": true // Optional, default is true. By default each property + // is indexed with a searchable index for + // BM25-suitable Map index for BM25 or hybrid + // searching. + } + ], + "invertedIndexConfig": { // Optional, index configuration + "stopwords": { + ... // Optional, controls which words should be ignored in the inverted index, see section below + }, + "indexTimestamps": false, // Optional, maintains inverted indexes for each object by its internal timestamps + "indexNullState": false, // Optional, maintains inverted indexes for each property regarding its null state + "indexPropertyLength": false // Optional, maintains inverted indexes for each property by its length + }, + "shardingConfig": { + ... // Optional, controls behavior of the collection in a + // multi-node setting, see section below + }, + "multiTenancyConfig": {"enabled": true} // Optional, for enabling multi-tenancy for this + // collection (default: false) +} +``` + +
+ +#### コード例 - コレクションの作成方法 + +次のコード例は、クライアントライブラリーを使ってコレクションパラメーターを設定する方法を示しています。 + + + + + + + + +:::tip 追加リソース + +さらなるコード例や設定ガイドについては、[How-to: Manage collections](../manage-collections/index.mdx) セクションをご覧ください。 + +::: + +#### `class` + +`class` はコレクションの名前です。 + +コレクション名は大文字で始めます。大文字で始めることで、プロパティ値として使用される際にプリミティブデータ型との区別がつきます。 + +`dataType` プロパティを使用した次の例をご覧ください。 + +- `dataType: ["text"]` は `text` データ型です。 +- `dataType: ["Text"]` は `Text` という名前のコレクションへのクロスリファレンス型です。 + +最初の文字以降には、GraphQL 互換の任意の文字を使用できます。 + +コレクション名を検証する正規表現は `/^[A-Z][_0-9A-Za-z]*$/` です。 + +import InitialCaps from "/_includes/schemas/initial-capitalization.md"; + + + +#### `description` + +コレクションの説明です。これは利用者の参照用であり、[Weaviate エージェント](/docs/agents/index.md) へ追加情報を提供することもできます。 + +--- + +### プロパティ + +| パラメーター | タイプ | 説明 | デフォルト | 変更可 | +| :----------------------------------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------ | :--------- | :----- | +| [`name`](#name) | String | プロパティの名前です。 | (Required) | No | +| [`dataType`](./datatypes.md) | Array | 1 つ以上のデータタイプを含む配列です。クロスリファレンスの場合、大文字のコレクション名を使用します(例: `["Article"]`)。 | (Required) | No | +| `description` | String | 参照用のプロパティ説明です。 | `null` | Yes | +| [`tokenization`](#tokenization) | String | `text` プロパティの場合、転置インデックス用にテキストをどのようにトークン化するかを指定します。 | `word` | No | +| [`indexInverted`](#inverted-index) | Boolean | `true` の場合、このプロパティに対して転置インデックスが有効になります。 | `true` | No | +| [`indexFilterable`](#inverted-index) | Boolean | `true` の場合、効率的なフィルタリングを可能にする roaring ビットマップインデックスを構築します。 | `true` | No | +| [`indexSearchable`](#inverted-index) | Boolean | `true` の場合、 BM25 やハイブリッド検索に適した検索可能なマップインデックスを構築します。 | `true` | No | +| [`indexRangeFilters`](#inverted-index) | Boolean | `true` の場合、数値レンジフィルタリング用の roaring ビットマップインデックスを構築します。 | `false` | No | +| [`invertedIndexConfig`](#inverted-index) | Object | `bm25` パラメーターなど、転置インデックス設定のプロパティレベルでのオーバーライドです。 | `{}` | No | +| `moduleConfig` | Object | このプロパティのベクトル化をスキップするなど、モジュール固有の設定です。 | `{}` | No | + +
+ プロパティ設定例 - JSON オブジェクト + +An example of a complete property object: + +```json +{ + "name": "title", // The name of the property + "description": "title of the article", // A description for your reference + "dataType": [ + // The data type of the object as described above. When creating cross-references, a property can have multiple dataTypes. + "text" + ], + "tokenization": "word", // Split field contents into word-tokens when indexing into the inverted index. See "Property Tokenization" below for more detail. + "moduleConfig": { + // Module-specific settings + "text2vec-contextionary": { + "skip": true, // If true, the whole property is NOT included in vectorization. Default is false, meaning that the object will be NOT be skipped. + "vectorizePropertyName": true // Whether the name of the property is used in the calculation for the vector position of data objects. Default false. + } + }, + "indexFilterable": true, // Optional, default is true. By default each property is indexed with a roaring bitmap index where available for efficient filtering. + "indexSearchable": true // Optional, default is true. By default each property is indexed with a searchable index for BM25-suitable Map index for BM25 or hybrid searching. +} +``` + +
+ +#### コード例 - コレクションプロパティを設定する方法 + +このコード例では、クライアントライブラリを通じてプロパティパラメーターを設定する方法を示します。 + + + + + + + + +:::tip さらなるリソース + +より多くのコード例や設定ガイドについては、[How-to: Manage collections](../manage-collections/index.mdx) セクションをご覧ください。 + +::: + +#### `name` + +プロパティ名には次の文字を使用できます: `/[_A-Za-z][_0-9A-Za-z]*/`。 + +##### 予約語 + +以下の単語は予約語のため、プロパティ名として使用できません。 + +- `_additional` +- `id` +- `_id` + +さらに、将来的に予約語と衝突する可能性があるため、次の単語もプロパティ名として使用しないことを強く推奨します。 + +- `vector` +- `_vector` + +#### `tokenization` + +`text` データのトークン化および転置インデックスへの登録方法をカスタマイズできます。トークン化は、[`bm25`](../api/graphql/search-operators.md#bm25) や [`hybrid`](../api/graphql/search-operators.md#hybrid) オペレーター、[`where` フィルター](../api/graphql/filters.md) の結果に影響します。 + +トークン化は `text` プロパティに対するプロパティレベルの設定です。[クライアントライブラリでトークン化オプションを設定する方法はこちら](../manage-collections/vector-config.mdx#property-level-settings) + +
+ プロパティ設定例 - JSON オブジェクト + +```json +{ + "classes": [ + { + "class": "Question", + "properties": [ + { + "dataType": ["text"], + "name": "question", + // highlight-start + "tokenization": "word" + // highlight-end + }, + ], + ... + "vectorizer": "text2vec-openai" + } + ] +} +``` + +
+ +各トークンは転置インデックスに個別に登録されます。たとえば、値が `Hello, (beautiful) world` の `text` プロパティがある場合、各トークン化方法でインデックスされるトークンは次のとおりです。 + +import TokenizationDefinition from "/_includes/tokenization_definition.mdx"; + + + +##### トークン化と検索 / フィルタリング + +トークン化は、フィルターやキーワード検索の挙動に影響します。フィルターやキーワード検索クエリもインデックスと照合される前にトークン化されます。 + +次の表は、値が `Hello, (beautiful) world` の `text` プロパティをフィルターまたはキーワード検索でヒットとして識別するかどうかを示す例です。 + +- **行**: 各種トークン化方法 +- **列**: 各種検索文字列 + +| | `Beautiful` | `(Beautiful)` | `(beautiful)` | `Hello, (beautiful) world` | +| ---------------- | ----------- | ------------- | ------------- | -------------------------- | +| `word` (default) | ✅ | ✅ | ✅ | ✅ | +| `lowercase` | ❌ | ✅ | ✅ | ✅ | +| `whitespace` | ❌ | ❌ | ✅ | ✅ | +| `field` | ❌ | ❌ | ❌ | ✅ | + +
+ `gse` と `trigram` のトークン化方法 + +:::info `1.24` で追加 +::: + +日本語および中国語テキストには、`gse` または `trigram` のトークン化方法を推奨します。これらの言語は空白で容易に区切れないため、他の方法より適しています。 + +`gse` トークナイザーはリソース節約のためデフォルトでは読み込まれません。使用するには、 Weaviate インスタンスで環境変数 `ENABLE_TOKENIZER_GSE` を `true` に設定してください。 + +`gse` トークン化例: + +- `"素早い茶色の狐が怠けた犬を飛び越えた"`: `["素早", "素早い", "早い", "茶色", "の", "狐", "が", "怠け", "けた", "犬", "を", "飛び", "飛び越え", "越え", "た", "素早い茶色の狐が怠けた犬を飛び越えた"]` +- `"すばやいちゃいろのきつねがなまけたいぬをとびこえた"`: `["すばや", "すばやい", "やい", "いち", "ちゃ", "ちゃい", "ちゃいろ", "いろ", "のき", "きつ", "きつね", "つね", "ねが", "がな", "なま", "なまけ", "まけ", "けた", "けたい", "たい", "いぬ", "を", "とび", "とびこえ", "こえ", "た", "すばやいちゃいろのきつねがなまけたいぬをとびこえた"]` + +:::note `trigram` のファジーマッチング + +もともとアジア言語向けに設計されましたが、`trigram` トークン化は他言語におけるファジーマッチングやタイプミス許容にも非常に有効です。 + +::: + +
+ +
+ `kagome_ja` のトークン化方法 + +:::caution 実験的機能 +`v1.28.0` から利用可能です。実験的機能のため慎重にご使用ください。 +::: + +日本語テキストには `kagome_ja` トークン化方法も利用できます。これは [`Kagome` トークナイザー](https://github.com/ikawaha/kagome?tab=readme-ov-file) と日本語 [MeCab IPA](https://github.com/ikawaha/kagome-dict/) 辞書を使用してプロパティテキストを分割します。 + +`kagome_ja` トークナイザーはリソース節約のためデフォルトでは読み込まれません。使用するには、 Weaviate インスタンスで環境変数 `ENABLE_TOKENIZER_KAGOME_JA` を `true` に設定してください。 + +`kagome_ja` トークン化例: + +- `"春の夜の夢はうつつよりもかなしき 夏の夜の夢はうつつに似たり 秋の夜の夢はうつつを超え 冬の夜の夢は心に響く 山のあなたに小さな村が見える 川の音が静かに耳に届く 風が木々を通り抜ける音 星空の下、すべてが平和である"`: + - [`"春", "の", "夜", "の", "夢", "は", "うつつ", "より", "も", "かなしき", "\n\t", "夏", "の", "夜", "の", "夢", "は", "うつつ", "に", "似", "たり", "\n\t", "秋", "の", "夜", "の", "夢", "は", "うつつ", "を", "超え", "\n\t", "冬", "の", "夜", "の", "夢", "は", "心", "に", "響く", "\n\n\t", "山", "の", "あなた", "に", "小さな", "村", "が", "見える", "\n\t", "川", "の", "音", "が", "静か", "に", "耳", "に", "届く", "\n\t", "風", "が", "木々", "を", "通り抜ける", "音", "\n\t", "星空", "の", "下", "、", "すべて", "が", "平和", "で", "ある"`] +- `"素早い茶色の狐が怠けた犬を飛び越えた"`: + - `["素早い", "茶色", "の", "狐", "が", "怠け", "た", "犬", "を", "飛び越え", "た"]` +- `"すばやいちゃいろのきつねがなまけたいぬをとびこえた"`: + - `["すばやい", "ちゃ", "いろ", "の", "きつね", "が", "なまけ", "た", "いぬ", "を", "とびこえ", "た"]` + +
+ +
+ `kagome_kr` のトークン化方法 + +:::caution 実験的機能 +`v1.25.7` から利用可能です。実験的機能のため慎重にご使用ください。 +::: + +韓国語テキストには `kagome_kr` トークン化方法を推奨します。これは [`Kagome` トークナイザー](https://github.com/ikawaha/kagome?tab=readme-ov-file) と Korean MeCab([mecab-ko-dic](https://bitbucket.org/eunjeon/mecab-ko-dic/src/master/))辞書を使用してプロパティテキストを分割します。 + +`kagome_kr` トークナイザーはリソース節約のためデフォルトでは読み込まれません。使用するには、 Weaviate インスタンスで環境変数 `ENABLE_TOKENIZER_KAGOME_KR` を `true` に設定してください。 + +`kagome_kr` トークン化例: + +- `"아버지가방에들어가신다"`: + - `["아버지", "가", "방", "에", "들어가", "신다"]` +- `"아버지가 방에 들어가신다"`: + - `["아버지", "가", "방", "에", "들어가", "신다"]` +- `"결정하겠다"`: + - `["결정", "하", "겠", "다"]` + +
+ +
+ `gse` と `Kagome` トークナイザーの同時実行数を制限する + +`gse` と `Kagome` のトークナイザーはリソースを多く消費し、 Weaviate のパフォーマンスに影響を与える可能性があります。 +[`TOKENIZER_CONCURRENCY_COUNT` 環境変数](/deploy/configuration/env-vars/index.md) を使用して、`gse` と `Kagome` トークナイザーの同時実行数を制限できます。 + +
+ +
+ `trigram` トークン化によるファジーマッチング + +`trigram` トークン化はテキストを 3 文字ずつ重なり合うシーケンスに分割することでファジーマッチングを提供します。これにより、 BM25 検索でスペルミスや表記揺れがあっても一致を見つけられます。 + +**`trigram` ファジーマッチングのユースケース:** + +- **タイプミス許容**: スペルミスがあっても一致を見つける(例: "Reliace" が "Reliance" に一致) +- **名前の照合**: データセット間で異なる表記のエンティティ名をマッチング +- **サーチアズユータイプ**: オートコンプリート機能の構築 +- **部分一致**: 部分的な文字列一致でオブジェクトを検索 + +**動作の仕組み:** + +テキストを `trigram` でトークン化すると、すべての 3 文字シーケンスに分割されます。 + +- `"hello"` → `["hel", "ell", "llo"]` +- `"world"` → `["wor", "orl", "rld"]` + +類似する文字列は多くのトライグラムを共有するため、ファジーマッチングが可能になります。 + +- `"Morgan Stanley"` と `"Stanley Morgn"` は `"sta", "tan", "anl", "nle", "ley"` などのトライグラムを共有 + +**パフォーマンスに関する考慮事項:** + +- フィルタリング動作が大きく変わり、テキストフィルタリングは単語ではなくトライグラムベースで行われます +- トークン数が増えるため、転置インデックスが大きくなります +- 大規模データセットではクエリパフォーマンスに影響を与える可能性があります + +:::tip + +ファジーマッチングを必要とするフィールドだけに選択的に `trigram` トークン化を使用してください。正確な一致が必要なフィールドには `word` や `field` トークン化を維持して精度を保ちましょう。 + +::: + +
+ +--- + +### 転置インデックス {#inverted-index} + +Weaviate は ** 転置インデックス ** を使用して、迅速かつ効率的なフィルタリングと検索を実現します。転置インデックスは値(単語や数値など)とそれを含むオブジェクトを対応付け、属性ベースのフィルタリング( `where` フィルター)およびキーワード検索( `bm25`、 `hybrid` )を高速化します。問い合わせを行わないプロパティのインデックス化を無効にすると、データインポートの速度が向上し、ディスク使用量を削減できます。 + +`indexFilterable`、 `indexSearchable`、 `indexRangeFilters` および `invertedIndexConfig` パラメーターの詳細は、[リファレンス: 転置インデックス](./indexing/inverted-index.mdx) をご覧ください。 + +--- + +### ベクトル設定 + +Weaviate では、ベクトル設定に対して 2 つのアプローチをサポートしています: + +- ** シングルベクトルコレクション **: 上位レベルのパラメーター( `vectorizer`、 `vectorIndexType`、 `vectorIndexConfig` )を使用して、オブジェクトごとに 1 つのベクトル空間を持たせる方法 +- ** 複数の名前付きベクトル **: `vectorConfig` パラメーターを使用して、オブジェクトごとに複数のベクトル空間を持たせる方法(** 推奨 **) + +同じコレクション内でこれら 2 つのアプローチを混在させることはできません。 + +:::tip `vectorConfig` の使用を推奨します + +`vectorConfig` パラメーターを使用すると、まずコレクションにつき 1 つのベクトルから始め、後から[新しい名前付きベクトル](../manage-collections/vector-config.mdx#add-new-named-vectors)を追加できます。 + +::: + +#### ベクトル設定パラメーター + +| パラメーター | 型 | 説明 | デフォルト | 変更可 | +| :----------------------------------------------------------------------- | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------- | :------------ | +| `vectorizer` | String | 使用するベクトライザー モジュール(例: `text2vec-cohere`)。自動ベクトル化を無効にするには `none` を設定します。[利用可能なモデルプロバイダー](../model-providers/index.md) | Module-specific default | No | +| [`vectorIndexType`](./indexing/vector-index.mdx) | String | ベクトルインデックスタイプ: `hnsw`(デフォルト)、 `flat`、または `dynamic` | `hnsw` | No | +| [`vectorIndexConfig`](./indexing/vector-index.mdx) | Object | 選択した `vectorIndexType` 用の設定 | Index-specific defaults | Partially\* | +| `vectorConfig` | Object | ** 上記の代替 ** : 複数の名前付きベクトル空間を定義します | `null` | Partially\*\* | +| ↪ `vectorConfig..vectorizer` | Object | この名前付きベクトル用のベクトライザー設定(例: `{"text2vec-openai": {"properties": ["title"]}}`) | (Required) | No | +| [↪ `vectorConfig..vectorIndexType`](./indexing/vector-index.mdx) | String | この名前付きベクトルのインデックスタイプ | `hnsw` | No | +| [↪ `vectorConfig..vectorIndexConfig`](./indexing/vector-index.mdx) | Object | この名前付きベクトルのインデックス設定 | Index-specific defaults | Partially\* | + +\* [ベクトルインデックスの変更可能なパラメーター](./indexing/vector-index.mdx) を参照してください +\*\* コレクション作成後に[新しい名前付きベクトルを追加](../manage-collections/vector-config.mdx#add-new-named-vectors)できます + +#### シングルベクトルコレクション + +コレクション定義で [名前付きベクトル](#named-vectors) を明示的に定義しない場合、 Weaviate は自動的に _シングルベクトル_ コレクションを作成します。これらのベクトルは内部的に `default` という名前付きベクトル(予約済みのベクトル名)の下に保存されます。 + +どのプロパティがベクトル化されるかを確認するには、[セマンティックインデックスの設定](./indexing/vector-index.mdx#configure-semantic-indexing) のセクションをご覧ください。 + +##### コード例 - シングルベクトルコレクションの作成方法 + +以下のコード例は、クライアントライブラリを介してシングルベクトルコレクションのベクトライザーパラメーターを設定する方法を示しています。 + + + + + + + + + + + + + + + + +:::tip 追加リソース + +より多くのコード例と設定ガイドについては、[How-to: Vectorizer and vector index config](../manage-collections/vector-config.mdx) ガイドをご覧ください。 + +::: + +#### 複数ベクトル埋め込み(名前付きベクトル) {#named-vectors} + +import MultiVectorSupport from "/_includes/multi-vector-support.mdx"; + + + +##### コード例 - 複数の名前付きベクトルを作成する方法 + +以下のコード例は、クライアントライブラリを使用して複数の名前付きベクトルを設定する方法を示しています。 + + + + + + + + + + + + + + + + +:::tip 追加リソース + +より多くのコード例と設定ガイドについては、[How-to: Vectorizer and vector index config](../manage-collections/vector-config.mdx) ガイドをご覧ください。 + +::: + +--- + +### モジュール設定 + +`moduleConfig` パラメーターでは、ベクトライザーがベクトル計算時にコレクション名を含めるか除外するかを指定できます(デフォルトは `true` です)。また、コレクション単位でリランカーおよび生成 [モデル プロバイダー](../model-providers/index.md) を指定する際にも使用されます。 + +
+ モジュール設定例 - JSON オブジェクト + +完全な `moduleConfig` オブジェクトの例: + +```json + "moduleConfig": { + "text2vec-contextionary": { + "vectorizeClassName": true // Include the collection name in vector calculation (default true) + } + }, +``` + +
+ +--- + +### ベクトル インデックス {#vector-index} + +ベクトル インデックスは、ベクトル データを整理し、類似検索を高速かつ効率的に行えるようにします。クエリをすべてのベクトルと比較する代わりに、インデックスが検索対象を最も関連性の高い候補に急速に絞り込みます。 + +`vectorIndexType` と `vectorIndexConfig` パラメーターの詳細は、[リファレンス: ベクトル インデックス](./indexing/vector-index.mdx) をご覧ください。 + +--- + +### レプリケーション + + + +[Replication](/deploy/configuration/replication.md) の設定は、`replicationConfig` パラメーターを通じて定義内で指定できます。 + +| Parameter | Type | Description | Default | Mutable | +| :----------------- | :------ | :---------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------ | :-------------------------------------- | +| `factor` | Integer | 各シャードに保持するコピー(レプリカ)の数。`3` の factor はプライマリ 1 つとレプリカ 2 つを意味します。 | `1` | No in `v1.25+`, Yes in earlier versions | +| `asyncEnabled` | Boolean | 非同期レプリケーションを有効にします。`v1.26` で追加されました。 | `false` | Yes | +| `deletionStrategy` | String | レプリケーションでの削除処理戦略。`NoAutomatedResolution`、`DeleteOnConflict`、`TimeBasedResolution` から選択します。`v1.27` で追加されました。 | `"NoAutomatedResolution"` | Yes | + +
+ レプリケーション設定例 - JSON オブジェクト + +完全な `replicationConfig` オブジェクトの例: + +```json +{ + "class": "Article", + "vectorizer": "text2vec-openai", + // highlight-start + "replicationConfig": { + "factor": 3, + "asyncEnabled": false, + "deletionStrategy": "NoAutomatedResolution" + } + // highlight-end +} +``` + +
+ +#### コード例 - レプリケーションの設定方法 + +以下のコード例は、クライアント ライブラリを使ってレプリケーション パラメーターを設定する方法を示しています。 + + + + + + + + +:::tip さらに学ぶ + +より多くのコード例や設定ガイドについては、[How-to: コレクションを管理する](../manage-collections/index.mdx) セクションをご覧ください。 + +::: + +--- + +### シャーディング + +シャーディングは、コレクション定義内の `shardingConfig` オブジェクトで設定します。これらのパラメーターはイミュータブルで、コレクション作成後に変更することはできません。 + +| Parameter | Type | Description | Default | Mutable | +| :-------------------- | :------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------- | :------ | +| `desiredCount` | Integer | コレクションに対して希望する物理シャード数。この値がクラスタ ノード数より大きい場合、いくつかのノードが複数のシャードをホストします。 | Number of nodes | No | +| `virtualPerPhysical` | Integer | 物理シャード 1 つあたりの仮想シャード数。仮想シャードはリバランス時のデータ移動を減らすのに役立ちます。 | `128` | No | +| `strategy` | String | オブジェクトが属するシャードを決定する戦略。現在サポートされているのは `"hash"` のみです。ハッシュは `key` プロパティに基づきます。 | `"hash"` | No | +| `key` | String | ターゲット シャード決定のためにハッシュに使用されるプロパティ。現時点ではオブジェクトの内部 UUID (`_id`) のみが利用できます。 | `"_id"` | No | +| `function` | String | `key` に対して使用されるハッシュ関数。現在サポートされているのは `"murmur3"` のみで、64 ビット ハッシュを生成し、衝突は極めて起こりにくくなります。 | `"murmur3"` | No | +| `actualCount` | Integer | **(読み取り専用)** 実際に作成された物理シャード数。作成時に問題が発生しない限り、通常は `desiredCount` と一致します。 | `1` | No | +| `desiredVirtualCount` | Integer | **(読み取り専用)** `desiredCount * virtualPerPhysical` の計算値です。 | `128` | No | +| `actualVirtualCount` | Integer | **(読み取り専用)** 実際に作成された仮想シャード数。 | `128` | No | + +
+ シャーディング設定例 - JSON オブジェクト + +完全な `shardingConfig` オブジェクトの例: + +```json + "shardingConfig": { + "virtualPerPhysical": 128, + "desiredCount": 1, // defaults to the amount of Weaviate nodes in the cluster + "actualCount": 1, + "desiredVirtualCount": 128, + "actualVirtualCount": 128, + "key": "_id", + "strategy": "hash", + "function": "murmur3" + } +``` + +
+ +#### コード例 - シャーディングの設定方法 + +以下のコード例は、クライアント ライブラリを使ってシャーディング パラメーターを設定する方法を示しています。 + + + + + + + + +:::tip さらに学ぶ + +より多くのコード例や設定ガイドについては、[How-to: コレクションを管理する](../manage-collections/index.mdx) セクションをご覧ください。 + +::: + +--- + +### マルチテナンシー + +マルチテナンシーを使用すると、単一のコレクション内でデータをテナントごとに分離できます。オブジェクトは特定のテナントにひも付けられるため、SaaS アプリケーションや厳格なデータ分割を必要とするシステムに便利です。 + +:::note マルチテナンシーを使う理由 + +各テナントごとにコレクションを作成する場合と比べて低コストでデータを分離できるため、テナント数が多い場合でもスケーラブルです。 + +::: + +マルチテナンシーを有効にするには、`multiTenancyConfig` オブジェクトの `enabled` キーを `true` に設定します。このパラメーターはイミュータブルで、コレクション作成時にのみ設定できます。 + +| パラメーター | 型 | 説明 | デフォルト | 変更可能 | +| :----------- | :-- | :--- | :-------- | :------- | +| `enabled` | Boolean | `true` にするとコレクションでマルチテナンシーを有効化します。 | `false` | No | +| `autoTenantCreation` | Boolean | 存在しないテナントにオブジェクトを追加しようとした場合に新しいテナントを自動作成します。`v1.25` で追加 | `false` | Yes | +| `autoTenantActivation` | Boolean | 検索・読み取り・更新・削除操作が行われた際に、`INACTIVE` または `OFFLOADED` のテナントを自動的にアクティブ化します。`v1.25.2` で追加 | `false` | Yes | + +#### コード例 - マルチテナンシーを設定する方法 + + + + + + + + +:::tip さらに学ぶ + +より多くのコード例と設定ガイドは、[How-to: Manage collections](../manage-collections/index.mdx) セクションをご覧ください。 + +::: + +## 変更可能性 + +コレクションを作成した後でも、一部のパラメーターは変更できます。イミュータブルなパラメーターを変更する必要がある場合は、データをエクスポートし、新しいコレクションを作成してからデータをインポートしてください。[コレクションエイリアス](../starter-guides/managing-collections/index.mdx#migration-workflow-with-collection-aliases) を使用すると、ダウンタイムなしで移行できます。 + +
+ 変更可能なパラメーター + +import RaftRFChangeWarning from "/_includes/1-25-replication-factor.mdx"; + + + + + +import CollectionMutableParameters from "/_includes/collection-mutable-parameters.mdx"; + + + +
+ +コレクション作成後には[新しいプロパティを追加](../manage-collections/collection-operations.mdx#add-a-property)できますが、既存プロパティは変更できません。また、[新しい名前付き ベクトル](../concepts/data.md#adding-a-named-vector-after-collection-creation)を追加することも可能です。 + +## オートスキーマ + +「オートスキーマ」機能は、追加されるデータからパラメーターを推論して自動的にコレクション定義を生成します。デフォルトで有効になっており、`docker-compose.yml` などで環境変数 [`AUTOSCHEMA_ENABLED`](/docs/deploy/configuration/env-vars/index.md#AUTOSCHEMA_ENABLED) を `'false'` に設定すると無効化できます。 + +この機能により次が行われます。 + +- 存在しないコレクションにオブジェクトが追加された場合、コレクションを自動作成します。 +- 追加されるオブジェクトに不足しているプロパティがあれば自動追加します。 +- `int[]`, `text[]`, `number[]`, `boolean[]`, `date[]`, `object[]` などの配列型を推論します。 +- `object` と `object[]` のデータ型に対してネストされたプロパティを推論します。 +- 追加されるオブジェクトに既存スキーマと衝突するプロパティ型が含まれるとエラーを返します(例: `int` として存在するフィールドに text をインポートしようとする場合)。 + +:::tip 本番環境ではコレクションを手動で定義する + +一般的に、本番環境ではオートスキーマを無効にし、手動でコレクション定義を行うことを推奨します。 + +- 手動定義のほうが詳細な制御が可能です。 +- インポート時にデータ構造を推論するためのパフォーマンスコストが発生します。複雑なネスト構造などでは高コストになる場合があります。 + +::: + +#### オートスキーマのデータ型 + +オートスキーマがニーズに合ったプロパティを推論できるよう、追加の設定が用意されています。 + +- `AUTOSCHEMA_DEFAULT_NUMBER=number` - 数値を検出した場合に `number` 列を作成します(`int` などではなく)。 +- `AUTOSCHEMA_DEFAULT_DATE=date` - 日付らしい値を検出した場合に `date` 列を作成します。 + +以下は許可されません。 + +- `phoneNumber` と `geoCoordinates` の 2 種を除き、任意のマップ型は使用できません。 +- 明確にリファレンスタイプでない限り、任意の配列型は使用できません。リファレンスタイプの場合、Weaviate はビコンを解決してどのコレクションかを確認する必要があります。これはスキーマ変更にコレクション名が必要なためです。 + +## コレクション数の上限 {#collections-count-limit} + +:::info `v1.30` で追加 +::: + +最適なパフォーマンスを確保するため、Weaviate は**ノードあたりのコレクション数を制限**しています。各コレクションはインデックス作成、定義管理、ストレージにオーバーヘッドを追加するためです。この制限は Weaviate のパフォーマンス維持を目的としています。 + +- **デフォルトの上限**: `1000` コレクション +- **上限の変更**: 環境変数 [`MAXIMUM_ALLOWED_COLLECTIONS_COUNT`](/deploy/configuration/env-vars/index.md#MAXIMUM_ALLOWED_COLLECTIONS_COUNT) で調整できます。 + +:::note +すでに上限を超えている場合、Weaviate は新しいコレクションの作成を許可しません。既存のコレクションは削除されません。 +::: + +:::tip +**コレクション数の上限を引き上げる前に、アーキテクチャを再検討することをおすすめします**。詳細は [Starter Guides: Scaling limits with collections](../starter-guides/managing-collections/collections-scaling-limits.mdx) をご覧ください。 +::: + + + +## コレクション エイリアス + +:::caution Technical preview + +コレクション エイリアスは **`v1.32`** で **テクニカル プレビュー** として追加されました。

+これは、この機能が現在も開発中であり、将来のリリースで破壊的変更を含む変更が行われる可能性があることを意味します。 +**現時点では本番環境での使用は推奨していません。** + +::: + +コレクション エイリアスは、 Weaviate のコレクションに対して別名を割り当て、代替名でコレクションを参照できるようにする機能です。 + +Weaviate はエイリアスへのリクエストを自動的に対象コレクションへルーティングします。これにより、コレクション名が必要なあらゆる場面でエイリアスを使用できます。これには [コレクション管理](../manage-collections/index.mdx)、[クエリ](../search/index.mdx)、およびコレクション名を必要とするその他すべての操作が含まれますが、**例外** としてコレクションの削除は除きます。コレクションを削除するには、そのコレクション名を使用する必要があります。コレクションを削除しても、それを指すエイリアスが自動的に削除されることはありません。 + +エイリアス名は一意でなければならず(既存のコレクション名や他のエイリアスと重複できません)、複数のエイリアスを同じコレクションに割り当てることも可能です。コレクション エイリアスは、[クライアント ライブラリを通じてプログラム的に](../manage-collections/collection-aliases.mdx) または REST エンドポイント を使用して設定できます。 + +コレクション エイリアスを管理するには、対応する [`Collection aliases`](../configuration/rbac/index.mdx#available-permissions) 権限が必要です。エイリアスが参照する基盤となるコレクションを管理するには、そのコレクションに対する [`Collections`](../configuration/rbac/index.mdx#available-permissions) 権限も必要です。 + +## 参考リソース + +- [スターター ガイド: コレクション定義](/weaviate/starter-guides/managing-collections) +- [操作ガイド: コレクション管理](../manage-collections/index.mdx) +- [概念: データ構造](/weaviate/concepts/data) +- + REST API: コレクション定義(スキーマ) + + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/datatypes.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/datatypes.md new file mode 100644 index 000000000..9ad53cafc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/datatypes.md @@ -0,0 +1,629 @@ +--- +title: プロパティ データ型 +sidebar_label: Data types +description: オブジェクト プロパティとフィールド仕様を定義するための Weaviate スキーマ データ型リファレンスです。 +image: og/docs/configuration.jpg +# tags: ['Data types'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import SkipLink from '/src/components/SkipValidationLink' + +[プロパティを作成する](../manage-collections/collection-operations.mdx#add-a-property) ときには、データ型を指定する必要があります。Weaviate では次の型を利用できます。 + +## 利用可能なデータ型 + +:::note 配列型 +あるデータ型の配列を指定する場合は、その型に `[]` を付けます(例: `text` ➡ `text[]`)。すべてのデータ型が配列をサポートしているわけではありませんのでご注意ください。 +::: + +import DataTypes from '/\_includes/datatypes.mdx'; + + + +各データ型の詳細は以下をご覧ください。 + +## `text` + +あらゆるテキスト データに使用します。 + +- `text` 型のプロパティは、別途 [プロパティ設定](../manage-collections/vector-config.mdx#property-level-settings) で指定しない限り、ベクトル化およびキーワード検索に利用されます。 +- [名前付きベクトル](../concepts/data.md#multiple-vector-embeddings-named-vectors) を使用する場合、プロパティのベクトル化は [名前付きベクトル定義](../manage-collections/vector-config.mdx#define-named-vectors) で設定します。 +- テキスト プロパティは、キーワード/BM25 検索用にインデックス化される前にトークン化されます。詳細は [コレクション定義: tokenization](../config-refs/collections.mdx#tokenization) を参照してください。 + +
+ string は非推奨です + +`v1.19` より前の Weaviate では、トークン化の挙動が `text` と異なる `string` という追加データ型をサポートしていました。`v1.19` 以降、この型は非推奨となり、今後のリリースで削除される予定です。 + +`string` の代わりに `text` をお使いください。`text` は `string` で利用可能だったトークン化オプションをサポートしています。 + +
+ +### 例 + +import TextTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.text.py'; +import TextTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.text.ts'; + +#### プロパティ定義 + + + + + + + + + + +#### オブジェクト挿入 + + + + + + + + + + +## `boolean` / `int` / `number` + +`boolean`、`int`、`number` の各型は、それぞれブール値、整数、浮動小数点数を格納するために使用します。 + +### 例 + +import NumericalTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.numerical.py'; +import NumericalTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.numerical.ts'; + +#### プロパティ定義 + + + + + + + + + + + + +#### オブジェクト挿入 + + + + + + + + + + +### 注意: GraphQL と `int64` + +Weaviate は `int64` をサポートしていますが、GraphQL は現在 `int32` のみをサポートしており、`int64` には対応していません。つまり、Weaviate の _integer_ データフィールドに `int32` を超える値が格納されている場合、GraphQL クエリで返されません。この [issue](https://github.com/weaviate/weaviate/issues/1563) の解決に取り組んでいます。現時点での回避策としては、代わりに `string` を使用してください。 + +## `date` + +Weaviate における `date` は、[RFC 3339](https://datatracker.ietf.org/doc/rfc3339/) の `date-time` 形式タイムスタンプで表されます。このタイムスタンプには時刻とオフセットが含まれます。 + +例: + +- `"1985-04-12T23:20:50.52Z"` +- `"1996-12-19T16:39:57-08:00"` +- `"1937-01-01T12:00:27.87+00:20"` + +複数の日付を 1 つのエンティティとして追加する場合は、`date-time` 形式の文字列配列を使用します。例: `["1985-04-12T23:20:50.52Z", "1937-01-01T12:00:27.87+00:20"]` + +特定のクライアントライブラリでは、以下の例のようにネイティブ日付オブジェクトを使用できる場合があります。 + +### 例 + +import DateTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.date.py'; +import DateTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.date.ts'; + +#### プロパティ定義 + + + + + + + + + + +#### オブジェクト挿入 + + + + + + + + + + +## `uuid` + +専用の `uuid` および `uuid[]` データタイプは、[UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) を効率的に保存します。 + +- 各 `uuid` は 128-bit (16-byte) の数値です。 +- フィルタリング用インデックスには Roaring Bitmap が使用されます。 + +:::note 集計/ソートは現在利用できません +現在、`uuid` および `uuid[]` 型で集計やソートを行うことはできません。 +::: + +### 例 + +import UUIDTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.uuid.py'; +import UUIDTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.uuid.ts'; + +#### プロパティ定義 + + + + + + + + + + +#### オブジェクト挿入 + + + + + + + + + + +## `geoCoordinates` + +`geoCoordinates` は、クエリ地点から半径内にあるオブジェクトを検索するために使用できます。geo 座標の値は float として保存され、[ISO 規格](https://www.iso.org/standard/39242.html#:~:text=For%20computer%20data%20interchange%20of,minutes%2C%20seconds%20and%20decimal%20seconds) に従い [10 進度](https://en.wikipedia.org/wiki/Decimal_degrees) として処理されます。 + +`geoCoordinates` プロパティを指定するには、`latitude` と `longitude` を浮動小数点形式の 10 進度で入力してください。 + + + +### 例 + +import GeoTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.geocoordinates.py'; +import GeoTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.geocoordinates.ts'; + +#### プロパティ定義 + + + + + + + + + + +#### オブジェクト挿入 + + + + + + + + + + +import GeoLimitations from '/\_includes/geo-limitations.mdx'; + + + +## `phoneNumber` + +`phoneNumber` 入力は、`number` や `string` のような単一フィールドとは異なり、正規化およびバリデーションが行われます。このデータフィールドは複数のフィールドを持つオブジェクトです。 + +```yaml +{ + "phoneNumber": { + "input": "020 1234567", // Required. Raw input in string format + "defaultCountry": "nl", // Required if only a national number is provided, ISO 3166-1 alpha-2 country code. Only set if explicitly set by the user. + "internationalFormatted": "+31 20 1234567", // Read-only string + "countryCode": 31, // Read-only unsigned integer, numerical country code + "national": 201234567, // Read-only unsigned integer, numerical representation of the national number + "nationalFormatted": "020 1234567", // Read-only string + "valid": true // Read-only boolean. Whether the parser recognized the phone number as valid + } +} +``` + +入力を受け取るフィールドは 2 つあります。`input` は常に設定する必要がありますが、`defaultCountry` は特定の状況でのみ設定します。考えられるシナリオは次の 2 つです。 + +- `input` フィールドに国際電話番号(例: `"+31 20 1234567"`)を入力する場合、`defaultCountry` を設定する必要はありません。基盤となるパーサーが番号の国を自動で判別します。 +- 国番号を含まない国内電話番号(例: `"020 1234567"`)を入力する場合は、`defaultCountry` に国を指定する必要があります(この例では `"nl"`)。これにより、パーサーが番号を正しく各形式に変換できます。`defaultCountry` には [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) 形式の国コードを入力してください。 + +Weaviate で `phoneNumber` 型のフィールドを読み取る際には、`internationalFormatted`、`countryCode`、`national`、`nationalFormatted`、`valid` といった読み取り専用フィールドが追加されます。 + +### 例 + +import PhoneTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.phonenumber.py'; +import PhoneTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.phonenumber.ts'; + +#### プロパティ定義 + + + + + + + + + + +#### オブジェクトの挿入 + + + + + + + + + + +## `blob` + +データタイプ `blob` は、任意のバイナリデータを受け付けます。データは `base64` でエンコードされ、 `string` として渡す必要があります。特徴は次のとおりです。 + +- Weaviate は、エンコードされたデータの種類について一切の前提を置きません。モジュール(例: `img2vec`)は必要に応じてファイルヘッダーを調査できますが、Weaviate 自体は行いません。 +- 保存時には、データが `base64` デコードされるため、より効率的に保存されます。 +- 配信時には、データが `base64` エンコードされるため、 `json` として安全に提供できます。 +- ファイルサイズの上限はありません。 +- この `blob` フィールドは、設定に関わらず常に 転置インデックス からスキップされます。そのため、Weaviate GraphQL `where` フィルターでこの `blob` フィールドによる検索はできず、対応する `valueBlob` フィールドも存在しません。モジュールによっては、このフィールドをモジュール固有のフィルター(例: `img2vec-neural` フィルターの `nearImage`{})で使用できます。 + + + +To obtain the base64-encoded value of an image, you can run the following command - or use the helper methods in the Weaviate clients - to do so: + +```bash +cat my_image.png | base64 +``` + + + +### Examples + +import BlobTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.blob.py'; +import BlobTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.blob.ts'; + +#### Property definition + + + + + + + + + + +#### オブジェクトの挿入 + + + + + + + + + + +## `object` + +:::info `v1.22` で追加 +::: + +`object` タイプを使用すると、任意の深さでネストできる JSON オブジェクトとしてデータを保存できます。 + +たとえば、 `Person` コレクションに `address` プロパティを `object` として定義し、その中に `street` や `city` などのネストしたプロパティを含めることができます。 + +:::note 制限事項 +現在、 `object` および `object[]` データタイプのプロパティは インデックス化 も ベクトル化 もされません。 + +将来的には、ネストしたプロパティをインデックス化してフィルタリングやベクトル化を可能にする予定です。 +::: + +### Examples + +import ObjectTypePy from '!!raw-loader!/\_includes/code/python/config-refs.datatypes.object.py'; +import ObjectTypeTs from '!!raw-loader!/\_includes/code/typescript/config-refs.datatypes.object.ts'; + +#### プロパティ定義 + + + + + + + + + + +#### オブジェクトの挿入 + + + + + + + + + + + + + +## `cross-reference` + +import CrossReferencePerformanceNote from '/\_includes/cross-reference-performance-note.mdx'; + + + +The `cross-reference` type allows a link to be created from one object to another. This is useful for creating relationships between collections, such as linking a `Person` collection to a `Company` collection. + +The `cross-reference` type objects are `arrays` by default. This allows you to link to any number of instances of a given collection (including zero). + +For more information on cross-references, see the [cross-references](../concepts/data.md#cross-references). To see how to work with cross-references, see [how to manage data: cross-references](../manage-collections/cross-references.mdx). + +## Notes + +#### Formatting in payloads + +In raw payloads (e.g. JSON payloads for REST), data types are specified as an array (e.g. `["text"]`, or `["text[]"]`), as it is required for some cross-reference specifications. + +## Further resources + +- [How-to: Manage collections](../manage-collections/index.mdx) +- [Concepts: Data structure](../concepts/data.md) +- References: REST API: Schema + +## Questions and feedback + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/distances.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/distances.md new file mode 100644 index 000000000..71ecfcfaa --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/distances.md @@ -0,0 +1,75 @@ +--- +title: 距離メトリクス +description: "ベクトル類似度計算と検索結果ランキングアルゴリズムのための距離メトリクスのオプション。" +image: og/docs/configuration.jpg +--- + +import SkipLink from '/src/components/SkipValidationLink' + +## 利用可能な距離メトリクス + +明示的に指定しない場合、 Weaviate のデフォルトの距離メトリクスは `cosine` です。スキーマの一部として [vectorIndexConfig](/weaviate/config-refs/indexing/vector-index.mdx#hnsw-index) フィールドで設定でき([例](../manage-collections/vector-config.mdx#specify-a-distance-metric))、以下のいずれかの型を指定できます。 + +:::tip 距離の比較 +いずれの場合も、値が大きいほど類似度は低くなり、値が小さいほど類似度は高くなります。 +::: + +| Name | 説明 | 定義 | 範囲 | 例 | +| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------- | +| `cosine` | コサイン(角度)距離。
下記の注 1 を参照 | `1 - cosine_sim(a,b)` | `0 <= d <= 2` | `0`: 同一のベクトル

`2`: 反対方向のベクトル | +| `dot` | ドット積に基づく距離の指標。

より正確には負のドット積。
下記の注 2 を参照 | `-dot(a,b)` | `-∞ < d < ∞` | `-3`: `-2` より類似

`2`: `5` より類似 | +| `l2-squared` | 2 つのベクトル間の二乗ユークリッド距離。 | `sum((a_i - b_i)^2)` | `0 <= d < ∞` | `0`: 同一のベクトル | +| `hamming` | 各次元でのベクトルの差の数。 | sum(|a_i != b_i|) | `0 <= d < dims` | `0`: 同一のベクトル | +| `manhattan` | 直交軸に沿って測定した 2 つのベクトル次元間の距離。 | sum(|a_i - b_i|) | `0 <= d < ∞` | `0`: 同一のベクトル | + +お気に入りの距離タイプが見当たらず、 Weaviate に貢献したい場合は、ぜひ [PR](https://github.com/weaviate/weaviate) をお送りください。お待ちしています。 + +:::note 補足 + +1. `cosine` を選択した場合、読み取り時にすべてのベクトルが長さ 1 に正規化され、計算効率のためにドット積が距離計算に使用されます。 +2. ドット積自体は類似度メトリクスであり、距離メトリクスではありません。そのため Weaviate では、距離の値が小さいほど類似、値が大きいほど非類似という直感を保つために負のドット積を返します。 + +::: + +## 距離計算の実装と最適化 + +一般的な Weaviate のユースケースでは、 CPU 時間の大部分がベクトル距離計算に費やされます。近似最近傍インデックスを使用して計算回数を大幅に減らしても、距離計算の効率は [全体のパフォーマンス](/weaviate/benchmarks/ann.md) に大きな影響を与えます。 + +Weaviate は、以下の距離メトリクスとアーキテクチャに対して SIMD( Single Instruction, Multiple Data )命令を使用しています。利用可能な最適化は表に示す順序で解決されます(例: SVE → Neon)。 + +| 距離 | `arm64` | `amd64` | +| ----------------------------- | ----------- | --------------------------------------------- | +| `cosine`, `dot`, `l2-squared` | SVE または Neon | Sapphire Rapids with AVX512、または AVX2 対応 | +| `hamming`, `manhattan` | SIMD なし | SIMD なし | + +アセンブリ言語、 SIMD、ベクトル命令セットに興味がある方は、まだ最適化されていない組み合わせへのご貢献をお待ちしています。 + +## API における distance フィールド + +`distance` は API で 2 つの方法で利用できます。 + +- [ベクトル検索](../search/similarity.md#set-a-similarity-threshold) が関与する場合、`_additional { distance }` を使用して結果に距離を表示できます。 +- 同じく [ベクトル検索](../search/similarity.md#set-a-similarity-threshold) で、`nearVector({distance: 1.5, vector: ... })` のように距離を制限条件として指定できます。 + +## Distance と Certainty の比較 + +バージョン `v1.14` 以前は、 API で `certainty` のみが利用可能でした。 `certainty` の基本的な考え方は、距離スコアを `0 <= certainty <= 1` に正規化し、1 が同一ベクトル、0 が反対方向のベクトルを表すというものでした。 + +しかし、この概念は `cosine` 距離に特有です。ほかの距離メトリクスではスコアが無限に広がる場合があります。そのため、現在は `certainty` より `distance` の使用が推奨されています。 + +互換性維持のため、距離が `cosine` の場合に限り `certainty` を引き続き使用できます。それ以外の距離を選択した場合、 `certainty` は使用できません。 + +関連事項: [Search API: 追加プロパティ(メタデータ)](../api/graphql/additional-properties.md) + +## 参考情報 + +- [How-to: コレクションの管理](../manage-collections/index.mdx) +- REST API: コレクション定義(スキーマ) +- [概念: データ構造](../concepts/data.md) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/index.mdx new file mode 100644 index 000000000..a49463103 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/index.mdx @@ -0,0 +1,67 @@ +--- +title: 設定 +description: "コレクション、データタイプ、距離、および最適化設定を網羅した設定リファレンスガイド。" +image: og/docs/configuration.jpg +hide_table_of_contents: true +--- + +Weaviate の主要な概念と設定を理解するために、以下のリファレンスガイドを参照してください。これらのガイドでは、コレクション定義、データタイプ、距離メトリクス、環境変数などを扱い、Weaviate のデプロイを最適化するのに役立ちます。 + +import CardsSection from "/src/components/CardsSection"; + +export const mainReferencesData = [ + { + title: "Collection definition", + description: + "An overview of all top-level collection parameters and concepts.", + link: "/weaviate/config-refs/collections", + icon: "fas fa-cube", + }, + { + title: "Vector Index", + description: + "Tune HNSW, Flat, or Dynamic indexes to balance search speed and recall.", + link: "/weaviate/config-refs/indexing/vector-index", + icon: "fas fa-sitemap", + }, + { + title: "Inverted Index", + description: + "Optimize filtering and keyword search with BM25, stopwords, and other settings.", + link: "/weaviate/config-refs/indexing/inverted-index", + icon: "fas fa-filter", + }, + { + title: "Data Types", + description: + "Reference for supported data types and their handling in Weaviate.", + link: "/weaviate/config-refs/datatypes", + icon: "fas fa-list-ul", + }, + { + title: "Distance Metrics", + description: + "Learn about the distance metrics used for similarity calculations.", + link: "/weaviate/config-refs/distances", + icon: "fas fa-ruler", + }, + { + title: "Environment Variables", + description: + "Learn about the environment variables used for configuration.", + link: "/deploy/configuration/env-vars", + icon: "fas fa-gear", + }, + +]; + +
+ +
+ +:::info Deployment documentation + +セキュリティ、バックアップ、レプリケーション、クラスター情報、詳細設定などのデプロイ関連トピックについては、[デプロイメントドキュメント](/docs/deploy/configuration/index.mdx) を参照してください。 + +::: + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/indexing/inverted-index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/indexing/inverted-index.mdx new file mode 100644 index 000000000..008f52316 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/indexing/inverted-index.mdx @@ -0,0 +1,251 @@ +--- +title: 転置インデックス +description: Weaviate における転置インデックスのパラメーターリファレンスです。 +--- + +import SkipLink from "/src/components/SkipValidationLink"; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/config-refs/reference.collections.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.ts"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.classes.java"; +import JavaReplicationCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.replication.java"; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.classes_test.go"; + +**[転置インデックス](../../concepts/indexing/inverted-index.md)** は、値(単語や数値など)をそれを含むオブジェクトへマッピングします。これは、すべての属性ベースフィルタリング( `where` フィルター)およびキーワード検索( `bm25` 、 `hybrid` )の基盤となります。 + +## 転置インデックスのタイプ + +Weaviate では複数の [転置インデックスタイプ](../../concepts/indexing/inverted-index.md) が利用可能です。ただし、すべてのデータ型で利用できるわけではありません。利用可能な転置インデックスタイプは以下のとおりです。 + +import InvertedIndexTypesSummary from "/_includes/inverted-index-types-summary.mdx"; + + + +- `indexFilterable` と `indexRangeFilters` のいずれか、または両方を有効にしてプロパティをインデックス化すると、フィルタリングが高速化されます。 + - どちらか一方のみを有効にした場合、そのインデックスがフィルタリングに使用されます。 + - 両方を有効にした場合、比較演算子を含む操作では `indexRangeFilters` が、等価・非等価演算では `indexFilterable` が使用されます。 + +## 転置インデックスのパラメーター + +これらのパラメーターはコレクション定義内の `invertedIndexConfig` オブジェクトで設定します。 + +| Parameter | Type | Default | Details | +| :-------------------------------------------- | :------ | :------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`bm25`](#bm25) | Object | `{ "k1": 1.2, "b": 0.75 }` | BM25 ランキングアルゴリズムの `k1` と `b` を設定します。プロパティ単位で上書き可能です。詳細は [**BM25 の設定**](#bm25) をご覧ください。 | +| [`stopwords`](#stopwords) | Object | (Varies) | ストップワードリストを定義し、検索クエリから一般的な語を除外します。詳細は [**ストップワードの設定**](#stopwords) をご覧ください。 | +| [`indexTimestamps`](#indextimestamps) | Boolean | `false` | `true` にするとオブジェクトの作成・更新タイムスタンプをインデックス化し、 `creationTimeUnix` と `lastUpdateTimeUnix` でフィルタリングできるようになります。 | +| [`indexNullState`](#indexnullstate) | Boolean | `false` | `true` にすると各プロパティの null / 非 null 状態をインデックス化し、 `null` 値でフィルタリングできるようになります。 | +| [`indexPropertyLength`](#indexpropertylength) | Boolean | `false` | `true` にすると各プロパティの長さをインデックス化し、プロパティ長でフィルタリングできるようになります。 | + +:::caution パフォーマンスへの影響 +`indexTimestamps` 、 `indexNullState` 、 `indexPropertyLength` を有効にすると、これらの追加インデックスを作成・維持するためのオーバーヘッドが発生します。必要なフィルタリング機能がある場合のみ有効にしてください。 +::: + +#### コード例 + +以下の例は、クライアントライブラリを使用して転置インデックスのパラメーターを設定する方法を示しています。 + + + + + + + + + + + + + + + + + + + +--- + +#### `bm25` + +`invertedIndexConfig` の一部です。BM25 の設定項目は [自由パラメーター `k1` と `b`](https://en.wikipedia.org/wiki/Okapi_BM25#The_ranking_function) で、指定は任意です。デフォルト値( `k1` = 1.2、 `b` = 0.75)は多くのケースで良好に機能します。 + +コレクション単位で設定でき、プロパティ単位で上書きすることも可能です。 + +
+ 例 `bm25` 設定 - JSON オブジェクト + +`bm25` を設定した完全なコレクションオブジェクトの例: + +```json +{ + "class": "Article", + // Configuration of the sparse index + "invertedIndexConfig": { + "bm25": { + "b": 0.75, + "k1": 1.2 + } + }, + "properties": [ + { + "name": "title", + "description": "title of the article", + "dataType": ["text"], + // Property-level settings override the collection-level settings + "invertedIndexConfig": { + "bm25": { + "b": 0.75, + "k1": 1.2 + } + }, + "indexFilterable": true, + "indexSearchable": true + } + ] +} +``` + +
+ +#### `stopwords` + +`invertedIndexConfig` の一部です。`text` プロパティには検索結果に寄与しない非常に一般的な語が含まれる場合があります。それらを無視すると、クエリにストップワードが含まれる場合の検索速度が向上します。特にスコアリング検索(例: ` BM25 `)では顕著です。 + +ストップワード設定はプリセット方式を採用しています。特定の言語における一般的なストップワードを使用する場合はプリセットを選択します(例: [`"en"` プリセット](https://github.com/weaviate/weaviate/blob/main/adapters/repos/db/inverted/stopwords/presets.go))。より詳細に制御したい場合は、追加したい語を `additions` に、除外したい語を `removals` に設定できます。また、空のプリセット( `"none"` )から始めて完全にカスタムのストップワードリストを作成することも可能です。 + +
+ 例 `stopwords` 設定 - JSON オブジェクト + +`stopwords` を設定した完全なコレクションオブジェクトの例: + +```json + "invertedIndexConfig": { + "stopwords": { + "preset": "en", + "additions": ["star", "nebula"], + "removals": ["a", "the"] + } + } +``` + +
+ +この設定により、ストップワードはコレクション単位で設定できます。未設定の場合、以下のデフォルトが適用されます。 + +| Parameter | Default value | Acceptable values | +| ------------- | ------------- | -------------------------- | +| `"preset"` | `"en"` | `"en"` 、 `"none"` | +| `"additions"` | `[]` | 任意のカスタム語リスト | +| `"removals"` | `[]` | 任意のカスタム語リスト | + +:::note + +- `preset` が `none` の場合、コレクションは `additions` リストのみをストップワードとして使用します。 +- 同じ語が `additions` と `removals` の両方に含まれている場合、Weaviate はエラーを返します。 +::: + +`v1.18` 以降、ストップワードもインデックス化されます。そのため、ストップワードは転置インデックスに含まれますが、トークン化されたクエリには含まれません。この結果、BM25 アルゴリズム適用時にはストップワードは関連度計算の入力から除外されますが、スコアには影響します。 + +ストップワードはランタイムに設定変更が可能になりました。データをインデックス化した後でも RESTful API を使用して 更新 できます。 + +:::info + +ストップワードが除去されるのは [トークン化](../collections.mdx#tokenization) が `word` に設定されている場合のみです。 + +::: + +#### `indexTimestamps` + +`invertedIndexConfig` の一部です。タイムスタンプでフィルターするクエリを実行するには、対象コレクションにオブジェクトの内部タイムスタンプに基づく 転置インデックス を維持させます。現在サポートされているタイムスタンプは `creationTimeUnix` と `lastUpdateTimeUnix` です。 + +タイムスタンプベースのインデックスを有効にするには、`invertedIndexConfig` オブジェクトで `indexTimestamps` を `true` に設定します。 + +#### `indexNullState` + +`invertedIndexConfig` の一部です。`null` でフィルターするクエリを実行するには、対象コレクションに各プロパティの `null` 値を追跡する 転置インデックス を維持させます。 + +`null` ベースのインデックスを有効にするには、`invertedIndexConfig` オブジェクトで `indexNullState` を `true` に設定します。 + +#### `indexPropertyLength` + +`invertedIndexConfig` の一部です。プロパティの長さでフィルターするクエリを実行するには、対象コレクションにプロパティの長さに基づく 転置インデックス を維持させます。 + +プロパティ長ベースのインデックスを有効にするには、`invertedIndexConfig` オブジェクトで `indexPropertyLength` を `true` に設定します。 + +:::note +これらの機能を使用すると、より多くのリソースが必要になります。追加の 転置インデックス はコレクションの存続期間中、作成および維持されます。 +::: + +## Weaviate による転置インデックスの作成方法 + +Weaviate は **各プロパティと各インデックスタイプごとに個別の 転置インデックス を作成** します。たとえば、`title` プロパティが検索可能かつフィルター可能な場合、Weaviate はそのプロパティに対して検索操作用とフィルター操作用の 2 つの 転置インデックス を作成します。詳細は [概念: 転置インデックス](../../concepts/indexing/inverted-index.md#how-weaviate-creates-inverted-indexes) をご覧ください。 + +### コレクション作成後にプロパティを追加する場合 + +オブジェクトをインポートした後にプロパティを追加すると、新しいプロパティの長さや `null` 状態でのフィルタリングなど、 転置インデックス に関連する機能に制限が生じる可能性があります。 + +これは、 転置インデックス がインポート時に構築されるためです。オブジェクトのインポート後にプロパティを追加しても、長さや `null` 状態といったメタデータ用の 転置インデックス は新しいプロパティを含むよう更新されません。その結果、既存オブジェクトでは新しいプロパティがインデックスされず、クエリ時に予期しない動作が発生する可能性があります。 + +これを避けるには、以下のいずれかを実施してください。 + +- オブジェクトをインポートする前にプロパティを追加する +- コレクションを削除し、新しいプロパティを含めて再作成した後、データを再インポートする + +プロパティ追加後にデータを再インデックスできる API を開発中です。将来のリリースで提供予定です。 + +## トークナイゼーションが転置インデックスに与える影響 + +`text` プロパティでは、Weaviate はまず **[トークナイゼーション](../collections.mdx#tokenization)** を行い、その後 転置インデックス エントリを作成します。トークナイゼーションとは、テキストをインデックスや検索に利用できる個々のトークン(単語、フレーズ、文字など)へ分割するプロセスです。 + +選択したトークナイゼーション方式は次の点に直接影響します。 + +- テキストから生成されるトークン +- それらトークンが 転置インデックス にどのように保存されるか +- 検索クエリやフィルターがデータにどのようにマッチするか + +例として、テキスト `"Hello, (beautiful) world"` では次のようになります。 + +- **`word` トークナイゼーション**: `["hello", "beautiful", "world"]` +- **`whitespace` トークナイゼーション**: `["hello", "(beautiful)", "world"]` +- **`field` トークナイゼーション**: `["Hello, (beautiful) world"]` + +各トークンは 転置インデックス の個別エントリとなり、そのトークンを含むオブジェクトを指し示します。 + +:::tip +用途によって適切なトークナイゼーション方式は異なります。一般的なテキスト検索にはデフォルトの `word`、完全一致には `field`、アジア言語には `gse` や `kagome_ja` などの特殊なトークナイザーを選択してください。詳しくは [トークナイゼーションオプション](../collections.mdx#tokenization) をご覧ください。 +::: + +## 参考リソース + +- [概念: 転置インデックス](../../concepts/indexing/inverted-index.md) +- [ハウツー: 転置インデックスパラメーターの設定](../../manage-collections/collection-operations.mdx#set-inverted-index-parameters) +- [リファレンス: トークナイゼーションオプション](../collections.mdx#tokenization) - さまざまなトークナイゼーション方式とテキストインデックスへの影響について + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/indexing/vector-index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/indexing/vector-index.mdx new file mode 100644 index 000000000..f05e826da --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/config-refs/indexing/vector-index.mdx @@ -0,0 +1,354 @@ +--- +title: ベクトルインデックス +description: Weaviate におけるベクトルインデックスの種類とパラメーターのリファレンス。 +--- + +**[ベクトルインデックス](../../concepts/indexing/vector-index.md)** は、ベクトルファーストのデータ保存と検索を効率的に行うための仕組みです。 +サポートされているベクトルインデックスは次の 3 種類です: + +- **[HNSW インデックス](#hnsw-index)** +- **[Flat インデックス](#flat-index)** +- **[Dynamic インデックス](#dynamic-index)** + +## HNSW インデックス + +HNSW インデックスはスケーラブルでクエリ時には非常に高速ですが、インデックス構築中にデータを追加する際にはコストが高くなります。 + +### HNSW インデックスのパラメーター + +一部の HNSW パラメーターは変更可能ですが、コレクション作成後に変更できないものもあります。 + +| パラメーター | 型 | 説明 | 既定値 | 変更可 | +| :-------------------------- | :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------- | :----- | +| `cleanupIntervalSeconds` | integer | クリーンアップの実行間隔。通常は調整する必要はありません。値を大きくするとクリーンアップの実行回数が減りますが、一度に処理する量が増えます。値を小さくするとクリーンアップは頻繁になりますが、各実行あたりの効率が下がる場合があります。 | 300 | Yes | +| `distance` | string | 距離メトリック。任意の 2 つのベクトル間の距離を測定する指標です。利用可能なメトリックは [対応距離メトリック](/weaviate/config-refs/distances.md) をご参照ください。 | `cosine` | No | +| `ef` | integer | 検索速度とリコールのバランスを調整します。`ef` は検索時に HNSW が使用する動的リストのサイズです。`ef` が大きいほど検索の精度は向上しますが、速度は低下します。`ef` が 512 を超えるとリコールの改善は逓減します。

動的 `ef`。`ef` を -1 に設定すると、Weaviate が `ef` の値を自動で調整し、動的 `ef` リストを作成します。詳細は [dynamic ef](../../concepts/indexing/vector-index.md#dynamic-ef) をご覧ください。 | -1 | Yes | +| `efConstruction` | integer | インデックス検索速度と構築速度のバランスを調整します。`efConstruction` を高くすると `ef` を低く設定できますが、インポートは遅くなります。

`efConstruction` は 0 より大きい必要があります。 | 128 | No | +| `maxConnections` | integer | 要素ごとの最大接続数。`maxConnections` は 0 以外のレイヤーでの接続上限です。0 レイヤーでは (2 \* `maxConnections`) の接続が可能です。

`maxConnections` は 0 より大きい必要があります。 | 32 | No | +| `dynamicEfMin` | integer | [動的 `ef`](../../concepts/indexing/vector-index.md#dynamic-ef) の下限値。検索リストが短くなりすぎるのを防ぎます。

この設定は `ef` が -1 の場合のみ使用されます。 | 100 | Yes | +| `dynamicEfMax` | integer | [動的 `ef`](../../concepts/indexing/vector-index.md#dynamic-ef) の上限値。検索リストが長くなりすぎるのを防ぎます。

`dynamicEfMax` が制限値を超える場合、`dynamicEfMax` は無効となり、その場合の制限値は `ef` です。

この設定は `ef` が -1 の場合のみ使用されます。 | 500 | Yes | +| `dynamicEfFactor` | integer | [動的 `ef`](../../concepts/indexing/vector-index.md#dynamic-ef) の乗数。検索リストの潜在的な長さを設定します。

この設定は `ef` が -1 の場合のみ使用されます。 | 8 | Yes | +| `filterStrategy` | string | `v1.27.0` で追加。検索結果のフィルタリングに使用するフィルターストラテジー。`sweeping` または `acorn` を指定できます。

- `sweeping`: 既定のストラテジー
- `acorn`: Weaviate の ACORN 実装を使用します。[詳細](../../concepts/filtering.md#filter-strategy) | `sweeping` | Yes | +| `flatSearchCutoff` | integer | オプション。[フラット検索カットオフ](/weaviate/concepts/filtering.md#flat-search-cutoff) の閾値。ベクトルインデックス検索を強制するには `"flatSearchCutoff": 0` を設定してください。 | 40000 | Yes | +| `skip` | boolean | `true` にするとコレクションをインデックスしません。

Weaviate はベクトル生成とベクトル保存を分離しています。インデックスをスキップしてもベクトライザーが設定されている(または手動でベクトルを指定している)場合、インポートのたびに警告が記録されます。

インデックスとベクトル生成を共にスキップするには、`"skip": true` を設定する際に `"vectorizer": "none"` を指定してください。

詳細は [インデックスをスキップするタイミング](../../concepts/indexing/vector-index.md#when-to-skip-indexing) を参照してください。 | `false` | No | +| `vectorCacheMaxObjects` | integer | メモリキャッシュ内のオブジェクトの最大数。デフォルトでは、新しいコレクション作成時に 1 兆 (`1e12`) オブジェクトに設定されています。サイジングの推奨事項は [ベクトルキャッシュの考慮事項](../../concepts/indexing/vector-index.md#vector-cache-considerations) をご確認ください。 | `1e12` | Yes | +| `pq` | object | [直積量子化 (PQ)](/weaviate/concepts/indexing/vector-index.md) 圧縮を有効化して設定します。

PQ はある程度のデータがすでにロードされていることを前提とします。PQ を有効にする前に、1 シャード当たり 10,000 ~ 100,000 ベクトルがロードされていることを推奨します。

PQ の詳細設定は [PQ 設定パラメーター](#pq-parameters) をご覧ください。 | -- | Yes | + +### HNSW 用のデータベースパラメーター + +HNSW のインデックス動作を構成するためのデータベースレベルのパラメーターもあります。 + +- `PERSISTENCE_HNSW_MAX_LOG_SIZE` は HNSW の書き込み先行ログの最大サイズを設定します。既定値は `500MiB` です。 + +この値を大きくするとコンパクションプロセスの効率が向上しますが、データベースのメモリ使用量も増えます。逆に小さくするとメモリ使用量は減りますが、コンパクションが遅くなる可能性があります。 + +理想的には、`PERSISTENCE_HNSW_MAX_LOG_SIZE` は HNSW グラフのサイズに近い値に設定してください。 + +### Tombstone クリーンアップパラメーター + +:::info Environment variable availability + +- `TOMBSTONE_DELETION_CONCURRENCY` は `v1.24.0` 以降で利用可能です。 +- `TOMBSTONE_DELETION_MIN_PER_CYCLE` と `TOMBSTONE_DELETION_MAX_PER_CYCLE` は `v1.24.15` / `v1.25.2` 以降で利用可能です。 + +::: + +Tombstone は削除されたオブジェクトを示すレコードです。HNSW インデックスでは `cleanupIntervalSeconds` で定期的にクリーンアップがトリガーされます。 + +インデックスが大きくなると、クリーンアップ処理にかかる時間とリソースが増加し、大規模なインデックスではパフォーマンス問題を引き起こす場合があります。 + +クリーンアップサイクルあたりに削除される Tombstone の数を制御し、パフォーマンス問題を防ぐために、[`TOMBSTONE_DELETION_MAX_PER_CYCLE` と `TOMBSTONE_DELETION_MIN_PER_CYCLE` の環境変数](/deploy/configuration/env-vars/index.md#general) を設定してください。 + +- `TOMBSTONE_DELETION_MIN_PER_CYCLE` を設定して、不必要なクリーンアップサイクルの発生を防ぎます。 +- `TOMBSTONE_DELETION_MAX_PER_CYCLE` を設定して、クリーンアップが長時間実行されたり過剰にリソースを消費したりするのを防ぎます。 + +例として、1 シャードあたり 3 億オブジェクトのクラスターでは、`TOMBSTONE_DELETION_MIN_PER_CYCLE` を 1,000,000、`TOMBSTONE_DELETION_MAX_PER_CYCLE` を 10,000,000 に設定すると良い出発点となります。 + +また、`TOMBSTONE_DELETION_CONCURRENCY` 環境変数を設定して Tombstone クリーンアップに使用するスレッド数を制限できます。これにより、クリーンアップが不要に多くのリソースを消費したり、逆に時間がかかりすぎたりするのを防げます。 + +`TOMBSTONE_DELETION_CONCURRENCY` の既定値は、Weaviate が利用できる CPU コア数の半分です。 + +コア数が多いクラスターでは、クリーンアップがリソースを消費しすぎないよう `TOMBSTONE_DELETION_CONCURRENCY` を低めに設定することを検討してください。逆にコア数が少なく削除が多い場合は、クリーンアップを高速化するために値を高くするとよいでしょう。 + +### HNSW 設定のヒント + +ご自身のユースケースに適した値を決めるため、以下の質問を検討し、表と照らし合わせてください。 + +1. 1 秒あたりどれくらいのクエリを想定していますか? +1. インポートや更新は多いですか? +1. リコールはどの程度必要ですか? + +| クエリ数 | インポート / 更新が多いか | リコール | 構成の提案 | +| -------- | ------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 少ない | いいえ | 低い | 理想的なシナリオです。`ef` と `efConstruction` をいずれも低く保ちます。大きなマシンは不要で、結果にも満足できるでしょう。 | +| 少ない | いいえ | 高い | リコールを高くする必要があります。リクエストやインポートが少ないため、`ef` と `efConstruction` の両方を増やせます。リコールが満足いくまで段階的に増やしてください。この場合、ほぼ 100% に近づけることも可能です。 | +| 少ない | はい | 低い | インポート / 更新の量が多い点が課題です。`efConstruction` は低く保ちます。高いリコールは不要でクエリ数も少ないため、`ef` を調整して希望のリコールを得てください。 | +| 少ない | はい | 高い | 高いリコールが必要で、インポート / 更新も多いという難しいトレードオフです。`efConstruction` を低く保つ必要がありますが、クエリ数が少ないため `ef` を大きく設定できます。 | +| 多い | いいえ | 低い | クエリ数が多いため `ef` は低くする必要があります。幸いリコールは高くなくてよいので、`efConstruction` を大きくできます。 | +| 多い | いいえ | 高い | クエリ数が多いため `ef` は低くします。リコールを高くする必要がありますが、インポートや更新は多くないため `efConstruction` を増やしてリコールを調整します。 | +| 多い | はい | 低い | クエリ数が多いので `ef` は低く、インポート / 更新も多いため `efConstruction` も低くします。リコールを 100% に近づける必要がないので、`efConstruction` を比較的低く設定してインポート / 更新スループットを確保し、`ef` で QPS を調整します。 | +| 多い | はい | 高い | すべてを最高にしたい場合です。インポート / 更新の時間制限に達するまで `efConstruction` を増やし、その後クエリ数とリコールのバランスが取れるまで `ef` を増やします。

多くの人は 3 つすべての指標を最大化したいと考えがちですが、実際にはそうでないケースも多いです。判断に迷ったら [フォーラム](https://forum.weaviate.io) でご相談ください。 | + +:::tip +多くのユースケースでの出発点として、以下の値が適しています。 + +| パラメーター | 値 | +| :------------------ | :--- | +| `ef` | `64` | +| `efConstruction` | `128`| +| `maxConnections` | `32` | + +::: + +## Flat インデックス + +:::info Added in `v1.23` +::: + +Flat インデックスは、マルチテナンシーなど、インデックスあたりのオブジェクト数が少ないユースケースで推奨されます。 + +| パラメーター | 型 | 既定値 | 変更可 | 詳細 | +| :-------------------------- | :------ | :------ | :----- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `vectorCacheMaxObjects` | integer | `1e12` | Yes | メモリキャッシュ内のオブジェクトの最大数。デフォルトでは、新しいコレクション作成時に 1 兆 (`1e12`) オブジェクトに設定されています。サイジングの推奨事項は [ベクトルキャッシュの考慮事項](../../concepts/indexing/vector-index.md#vector-cache-considerations) をご参照ください。 | +| `bq` | object | -- | No | [バイナリ量子化 (BQ)](../../concepts/vector-quantization.md#binary-quantization) 圧縮を有効化して設定します。

BQ の詳細設定は [BQ 設定パラメーター](#bq-configuration-parameters) をご覧ください。 | + +### BQ 設定パラメーター + +`bq` は次のパラメーターで構成します。 + +| パラメーター | 型 | 既定値 | 詳細 | +| :--------------- | :------ | :----- | :--------------------------------------------------------- | +| `enabled` | boolean | `false`| BQ を有効化します。`true` にすると Weaviate は BQ 圧縮を使用します。| +| `rescoreLimit` | integer | -1 | リスコアを行う前に取得する最小候補数。 | +| `cache` | boolean | `false`| ベクトルキャッシュを使用するかどうか。 | + + + +## 動的インデックス + +:::caution Experimental feature +`v1.25` から利用可能です。動的インデックスは実験的機能です。ご使用の際はご注意ください。 +::: + +import DynamicAsyncRequirements from "/_includes/dynamic-index-async-req.mdx"; + + + +`dynamic` インデックスを使用すると、初期状態ではフラットインデックスが作成され、オブジェクト数がしきい値(デフォルトでは 10,000 件)を超えると自動的に HNSW インデックスへ切り替わります。 + +これはフラットインデックスを HNSW に一方向で変換するのみで、削除によってオブジェクト数がしきい値を下回ってもフラットインデックスへ戻ることはできません。 + +`dynamic` インデックスの目的は、より大きなメモリフットプリントと引き換えにクエリ時間のレイテンシを短縮することです。 + +### 動的インデックスのパラメーター + +| Parameter | Type | Default | Details | +| :---------- | :------ | :----------- | :------------------------------------------------------------------------------------ | +| `distance` | string | `cosine` | 距離メトリクス。2つの任意の ベクトル 間の距離を測定するメトリクスです。 | +| `hnsw` | object | default HNSW | 使用する [ HNSW インデックス設定](#hnsw-index-parameters)。 | +| `flat` | object | default Flat | 使用する [フラットインデックス設定](#flat-index)。 | +| `threshold` | integer | 10000 | `flat` から `hnsw` への変換が行われるオブジェクト数のしきい値 | + +## インデックス設定パラメーター + +:::caution Experimental feature +`v1.25` から利用可能です。動的インデックスは実験的機能です。ご使用の際はご注意ください。 +::: + +以下のパラメーターでインデックスタイプとそのプロパティを設定できます。これらは [コレクション設定](../../manage-collections/vector-config.mdx#set-vector-index-type) で指定します。 + +| Parameter | Type | Default | Details | +| :------------------ | :----- | :------ | :------------------------------------------------------------------- | +| `vectorIndexType` | string | `hnsw` | 任意。インデックスタイプ。`hnsw`、`flat`、`dynamic` から選択できます。 | +| `vectorIndexConfig` | object | - | 任意。 ベクトル インデックスタイプ固有のパラメーターを設定します。 | + +
+ インデックスタイプの選び方 + +一般的には、ほとんどのユースケースで `hnsw` インデックスタイプが推奨されます。`flat` インデックスタイプは、マルチテナンシーのようにインデックスあたりのデータ(オブジェクト)数が少ないケースで推奨されます。最初に `flat` インデックスを構成し、オブジェクト数が指定のしきい値を超えたら自動で `hnsw` に変換する `dynamic` インデックスを選択することもできます。 + +各インデックスタイプの詳細と選択方法については [こちらのセクション](../../concepts/indexing/vector-index.md#which-vector-index-is-right-for-me) を参照してください。 + +
+ +インポート速度をさらに高めたい場合は、[非同期インデックス](#asynchronous-indexing) を使用してオブジェクト作成とインデックス作成を分離できます。 + +### RQ パラメーター + +`vectorIndexConfig` 内で、RQ 圧縮に利用できるパラメーターは次のとおりです。 + +import RQParameters from "/_includes/configuration/rq-compression-parameters.mdx"; + + + +### SQ パラメーーター + +`vectorIndexConfig` 内で、SQ 圧縮に利用できるパラメーターは次のとおりです。 + +import SQParameters from "/_includes/configuration/sq-compression-parameters.mdx"; + + + +### PQ パラメーター + +`vectorIndexConfig` 内で、PQ 圧縮に利用できるパラメーターは次のとおりです。 + +import PQParameters from "/_includes/configuration/pq-compression/parameters.mdx"; + + + +### BQ パラメーター + +`vectorIndexConfig` 内で、BQ 圧縮に利用できるパラメーターは次のとおりです。 + +import BQParameters from "/_includes/configuration/bq-compression-parameters.mdx"; + + + +## セマンティックインデックスの設定 + +Weaviate は [モデルプロバイダー統合](/weaviate/model-providers/) を使用してオブジェクトのベクトル埋め込みを生成できます。 + +たとえば、テキスト埋め込み統合(Cohere 用の `text2vec-cohere` や Ollama 用の `text2vec-ollama` など)は、テキストオブジェクトから ベクトル を生成できます。Weaviate はコレクション設定と所定のルールに従ってオブジェクトをベクトライズします。 + +コレクション定義で別途指定しない限り、デフォルトの動作は以下のとおりです。 + +- `text` または `text[]` データタイプを使用するプロパティのみをベクトライズします([スキップ](../../manage-collections/vector-config.mdx#property-level-settings) されていない限り) +- プロパティ値を連結する前に、プロパティをアルファベット(a-z)順に並べ替えます +- `vectorizePropertyName` が `true`(デフォルトは `false`)の場合、各プロパティ値の前にプロパティ名を付けます +- (前置された)プロパティ値をスペースで結合します +- クラス名を先頭に付けます(`vectorizeClassName` が `false` の場合を除く) +- 生成された文字列を小文字に変換します + +例として、次のデータオブジェクト + +```js +Article = { + summary: "Cows lose their jobs as milk prices drop", + text: "As his 100 diary cows lumbered over for their Monday...", +}; +``` + +は以下のようにベクトライズされます。 + +```md +article cows lose their jobs as milk prices drop as his 100 diary cows lumbered over for their monday... +``` + +デフォルトでは、計算にはコレクション名とすべてのプロパティ値が含まれますが、プロパティ名はインデックスされません。 + +コレクション単位でベクトライズの挙動を設定するには `vectorizeClassName` を使用します。 + +プロパティ単位で設定するには `skip` と `vectorizePropertyName` を使用します。 + +## 非同期インデックス + +:::caution Experimental +`v1.22` から利用可能です。こちらは実験的機能です。ご使用の際はご注意ください。 +::: + +Weaviate `1.22` 以降では、オプトインにより非同期インデックスを使用できます。 + +非同期インデックスを有効にするには、Weaviate の設定(Docker Compose を使用している場合は `docker-compose.yml` ファイル)で環境変数 `ASYNC_INDEXING` を `true` に設定します。この設定により、すべてのコレクションで非同期インデックスが有効になります。 + +
+ Docker Compose 設定例 + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - "8080" + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + restart: on-failure:0 + ports: + - 8080:8080 + - 50051:50051 + environment: + QUERY_DEFAULTS_LIMIT: 25 + QUERY_MAXIMUM_RESULTS: 10000 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: "true" + PERSISTENCE_DATA_PATH: "/var/lib/weaviate" + ENABLE_API_BASED_MODULES: "true" + CLUSTER_HOSTNAME: "node1" + AUTOSCHEMA_ENABLED: "false" + ASYNC_INDEXING: "true" +``` + +
+ +インデックスのステータスを取得するには、[ノードステータス](/deploy/configuration/nodes.md) エンドポイントを確認します。 + +
+ Node status の使用例 + +`nodes/shards/vectorQueueLength` フィールドは、まだインデックス作成が必要なオブジェクト数を示します。 + +import Nodes from "/_includes/code/nodes.mdx"; + + + +次に、出力を確認して ベクトル インデックスキューの状態をチェックします。 + +
+ +`vectorQueueLength` フィールドには、残りのインデックス対象オブジェクト数が表示されます。下記の例では、`TestArticle` シャードの ベクトル インデックスキューに 1000 件中 425 件が残っていることを示しています。 + +```json +{ + "nodes": [ + { + "batchStats": { + "ratePerSecond": 0 + }, + "gitHash": "e6b37ce", + "name": "weaviate-0", + "shards": [ + { + "class": "TestArticle", + "name": "nq1Bg9Q5lxxP", + "objectCount": 1000, + // highlight-start + "vectorIndexingStatus": "INDEXING", + "vectorQueueLength": 425 + // highlight-end + } + ], + "stats": { + "objectCount": 1000, + "shardCount": 1 + }, + "status": "HEALTHY", + "version": "1.22.1" + } + ] +} +``` + +
+ + + +## 複数ベクトル埋め込み(名前付きベクトル) + +import MultiVectorSupport from "/_includes/multi-vector-support.mdx"; + + + +## 追加リソース + +- [概念: ベクトルインデックス](../../concepts/indexing/vector-index.md) +- [方法: コレクションを設定する](../../manage-collections/vector-config.mdx) + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/_category_.json new file mode 100644 index 000000000..67a073ab6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "How-to: Configure", + "position": 60 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/_enterprise-usage-collector.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/_enterprise-usage-collector.md new file mode 100644 index 000000000..84f0b61ed --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/_enterprise-usage-collector.md @@ -0,0 +1,84 @@ +--- +title: エンタープライズ使用量コレクター +sidebar_position: 7 +image: og/docs/configuration.jpg +# tags: ['configuration'] +--- + + + +Weaviate エンタープライズを使用する場合、ユーザー(またはロードバランサー)と Weaviate の間にプロキシサービスが配置されます。このサービスは、機能・処理時間・ペイロードサイズなどの機密情報を送信することなく、Weaviate の利用状況を計測します。以下では、プロキシサービスをセットアップに追加する手順を説明します。 + +## 1. Weaviate Enterprise トークンの取得 + +- [Weaviate Console](https://console.weaviate.cloud) にログインします。 +- 上部メニューのプロフィールアイコンをクリックし、表示されるキーを取得します。このキーはシークレットです。公開リポジトリなどに公開しないようご注意ください。 + +## 2. Docker Compose ファイルに Weaviate Enterprise 使用量コレクターを追加 + +インストールコンフィギュレーターで生成された Docker Compose ファイルを使用している場合は、以下のブロックを YAML ファイルに追加します。 + +```yaml +services: + enterprise-proxy: + image: cr.weaviate.io/semitechnologies/weaviate-enterprise-usage-collector:latest + environment: + - weaviate_enterprise_token=[[ WEAVIATE TOKEN ]] + - weaviate_enterprise_project=[[ PROJECT NAME ]] + links: + - "weaviate:weaviate.com" + ports: + - "8080:8080" + depends_on: + - weaviate +``` + +* `weaviate_enterprise_token` = 前の手順で取得したトークンです。 +* `weaviate_enterprise_project` = クラスターを識別する任意の文字列です。たとえば開発環境と本番環境がある場合は、`weaviate_enterprise_project=my-project-dev` と `weaviate_enterprise_project=my-project-prod` のように設定できます。 + +## 3. Weaviate のポートをプロキシにリダイレクト + +すべてのトラフィックをエンタープライズプロキシ経由でルーティングするため、Weaviate がポート 4000 で受信できるように設定する必要があります。 + +```yaml +services: + weaviate: + command: + - --port + - '4000' # <== SET TO 4000 + # rest of the docker-compose.yml +``` + +## Docker Compose コンフィギュレーターの使用 + +Docker Compose の [コンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator)も利用できます。Enterprise Usage Collector オプションでは「Enabled」を選択してください。 + +## Helm を使用した Kubernetes 上のコレクタープロキシ + +ステップ 1 と同様にトークンを取得します。 + +バージョン `||site.helm_version||` 以上の Weaviate [Helm チャート](https://github.com/weaviate/weaviate-helm/releases) を入手します。 + +`values.yaml` の `collector_proxy` キーを用いて、プロキシを有効化し設定します。 + +``` +collector_proxy: + enabled: true + tag: latest + weaviate_enterprise_token: "00000000-0000-0000-0000-000000000000" + weaviate_enterprise_project: "demo_project" + service: + name: "usage-proxy" + port: 80 + type: LoadBalancer +``` + +Helm チャートをデプロイし、リクエストにプロキシサービスを使用するようにしてください。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/authz-authn.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/authz-authn.md new file mode 100644 index 000000000..055eaedde --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/authz-authn.md @@ -0,0 +1,304 @@ +--- +title: 認証と認可 +sidebar_position: 30 +image: og/docs/configuration.jpg +# tags: ['authentication'] +--- + +:::info 認証と認可 +認証と認可は密接に関連する概念で、`AuthN` と `AuthZ` と略されることがあります。認証 (`AuthN`) はユーザーの身元を検証するプロセスであり、認可 (`AuthZ`) はユーザーがどの権限を持つかを決定するプロセスです。 +::: + +## 認証 + +Weaviate は API キーまたは OpenID Connect (OIDC) によるユーザー認証を通じてアクセスを制御します。また、匿名アクセスを許可するオプションもあります。認証後、ユーザーには下図のように異なる [認可](/deploy/configuration/authorization.md) レベルを割り当てられます。 + +```mermaid +flowchart LR + %% Define main nodes + Request["Client
Request"] + AuthCheck{"AuthN
Enabled?"} + AccessCheck{"Check
AuthZ"} + Access["✅ Access
Granted"] + Denied["❌ Access
Denied"] + + %% Define authentication method nodes + subgraph auth ["AuthN"] + direction LR + API["API Key"] + OIDC["OIDC"] + AuthResult{"Success?"} + end + + %% Define connections + Request --> AuthCheck + AuthCheck -->|"No"| AccessCheck + AuthCheck -->|"Yes"| auth + API --> AuthResult + OIDC --> AuthResult + AuthResult -->|"Yes"| AccessCheck + AuthResult -->|"No"| Denied + + AccessCheck -->|"Pass"| Access + AccessCheck -->|"Fail"| Denied + + %% Style nodes + style Request fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style AuthCheck fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style AccessCheck fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Access fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style Denied fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style API fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style OIDC fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style AuthResult fill:#ffffff,stroke:#B9C8DF,color:#130C49 + + %% Style subgraph + style auth fill:#ffffff,stroke:#130C49,stroke-width:2px,color:#130C49 +``` + +たとえば、API キー `jane-secret` でログインしたユーザーには管理者権限が付与され、API キー `ian-secret` でログインした別のユーザーには読み取り専用権限が付与される、といった運用が可能です。 + +まとめると、Weaviate では次の認証方法が利用できます。 + +- [API キー](/deploy/configuration/authentication.md#api-key-authentication) +- [OpenID Connect (OIDC)](/deploy/configuration/authentication.md#oidc-authentication) +- [匿名アクセス](/deploy/configuration/authentication.md#anonymous-access)(認証なし。開発・評価以外では非推奨) + +API キー認証と OIDC 認証は同時に有効化できます。 + +認証の設定方法は、Docker で実行するか Kubernetes で実行するかによって異なります。以下に両方の例を示します。 + +:::info Weaviate Cloud (WCD) では? +Weaviate Cloud (WCD) インスタンスでは、OIDC と API キーアクセスによる認証があらかじめ構成されています。OIDC を用いて WCD の資格情報で [Weaviate に認証](../connections/connect-cloud.mdx) するか、[API キー](/cloud/manage-clusters/connect.mdx) を使用できます。 +::: + +### API キー + +Weaviate での API キーの利用方法については、[認証ガイド](/deploy/configuration/authentication.md#api-key-authentication)をご覧ください。 + +Weaviate への認証にはクライアントライブラリの使用を推奨します。詳細は [How-to: Connect](docs/weaviate/connections/index.mdx) を参照してください。 + +### OIDC + +Weaviate での OIDC 認証の利用方法については、[認証ガイド](/deploy/configuration/authentication.md#oidc-authentication)をご覧ください。 + +OIDC ではトークンを取得するためのさまざまな手法 _(フロー)_ が定義されています。適切な手法はトークン発行者の設定や要件により異なります。 + +OIDC 認証フロー自体の詳細は本ドキュメントの範囲外ですが、検討すべき主なオプションを以下に示します。 + +1. `client credentials flow` を使用してマシン間認可を行う(これはユーザーではなくアプリを認可します)。 + - Okta と Azure をアイデンティティプロバイダーとして検証済み。GCP は 2022 年 12 月時点で client credentials grant flow をサポートしていません。 + - Weaviate の Python クライアントはこの方式を直接サポートします。 + - client credentials flow には通常リフレッシュトークンが付随せず、クライアントに資格情報を保存してトークン失効時に新しいアクセストークンを取得します。 +2. `resource owner password flow` を使用して、[Weaviate Cloud](/cloud/manage-clusters/connect) のような信頼済みアプリケーションに適用する。 +3. トークン発行者が Azure である場合やパスワードの露出を避けたい場合には `hybrid flow` を使用する。 + +### Weaviate クライアントのサポート + +Weaviate Database が `client credentials grant` フローまたは `resource owner password flow` を使用するよう構成されている場合、Weaviate クライアントは認証フローを組み込んだ接続を生成できます。 + +import OIDCExamples from '/\_includes/code/connections/oidc-connect.mdx'; + + + +### トークンを手動で取得・送信する + +
+ + トークンを手動で取得して送信する + + +ワークフローによってはトークンを手動で取得したい場合があります。以下に resource owner password flow と hybrid flow での手順を示します。 + +#### Resource owner password flow + +1. `WEAVIATE_INSTANCE_URL/v1/.well-known/openid-configuration` に GET リクエストを送り、Weaviate の OIDC 設定 (`wv_oidc_config`) を取得します。`WEAVIATE_INSTANCE_URL` は実際のインスタンス URL に置き換えてください。 +2. `wv_oidc_config` から `clientId` と `href` を取得します。 +3. `href` に GET リクエストを送り、トークン発行者の OIDC 設定 (`token_oidc_config`) を取得します。 +4. `token_oidc_config` にオプションの `grant_types_supported` キーが含まれる場合、値のリストに `password` があることを確認します。 + - `password` が無い場合、トークン発行者が `resource owner password flow` に対応していない可能性があります。トークン発行者を再設定するか別の方法を利用してください。 + - `grant_types_supported` キーが無い場合、トークン発行者に `resource owner password flow` がサポートされているか問い合わせてください。 +5. `token_oidc_config` の `token_endpoint` に対し、以下の内容で POST リクエストを送信します。 + - `{"grant_type": "password", "client_id": client_id, "username": USERNAME, "password": PASSWORD}` + `USERNAME` と `PASSWORD` は実際の値に置き換えてください。 +6. レスポンス (`token_resp`) を解析し、`access_token` を取得します。これが Bearer トークンです。 + +#### Hybrid flow + +1. `WEAVIATE_INSTANCE_URL/v1/.well-known/openid-configuration` に GET リクエストを送り、Weaviate の OIDC 設定 (`wv_oidc_config`) を取得します。`WEAVIATE_INSTANCE_URL` は実際のインスタンス URL に置き換えてください。 +2. `wv_oidc_config` から `clientId` と `href` を取得します。 +3. `href` に GET リクエストを送り、トークン発行者の OIDC 設定 (`token_oidc_config`) を取得します。 +4. `authorization_endpoint` を基に以下のパラメータで URL (`auth_url`) を構築します。 + - `{authorization_endpoint}`?client_id=`{clientId}`&response_type=code%20id_token&response_mode=fragment&redirect_url=`{redirect_url}`&scope=openid&nonce=abcd + - `redirect_url` はトークン発行者に[事前登録](https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest)されている必要があります。 +5. ブラウザで `auth_url` にアクセスし、必要に応じてログインします。成功するとトークン発行者はブラウザを `redirect_url` にリダイレクトし、`id_token` などのパラメータを付与します。 +6. `id_token` の値を取得します。これが Bearer トークンです。 + +#### コード例 + +以下は OIDC トークンを取得する例です。 + +```python +import requests +import re + +url = "http://localhost:8080" # <-- Replace with your actual Weaviate URL + +# Get Weaviate's OIDC configuration +weaviate_open_id_config = requests.get(url + "/v1/.well-known/openid-configuration") +if weaviate_open_id_config.status_code == "404": + print("Your Weaviate instance is not configured with openid") + +response_json = weaviate_open_id_config.json() +client_id = response_json["clientId"] +href = response_json["href"] + +# Get the token issuer's OIDC configuration +response_auth = requests.get(href) + +if "grant_types_supported" in response_auth.json(): + # For resource owner password flow + assert "password" in response_auth.json()["grant_types_supported"] + + username = "username" # <-- Replace with the actual username + password = "password" # <-- Replace with the actual password + + # Construct the POST request to send to 'token_endpoint' + auth_body = { + "grant_type": "password", + "client_id": client_id, + "username": username, + "password": password, + } + response_post = requests.post(response_auth.json()["token_endpoint"], auth_body) + print("Your access_token is:") + print(response_post.json()["access_token"]) +else: + # For hybrid flow + authorization_url = response_auth.json()["authorization_endpoint"] + parameters = { + "client_id": client_id, + "response_type": "code%20id_token", + "response_mode": "fragment", + "redirect_url": url, + "scope": "openid", + "nonce": "abcd", + } + # Construct 'auth_url' + parameter_string = "&".join([key + "=" + item for key, item in parameters.items()]) + response_auth = requests.get(authorization_url + "?" + parameter_string) + + print("To login, open the following url with your browser:") + print(authorization_url + "?" + parameter_string) + print( + "After the login you will be redirected, the token is the 'id_token' parameter of the redirection url." + ) + + # You could use this regular expression to parse the token + resp_txt = "Redirection URL" + token = re.search("(?<=id_token=).+(?=&)", resp_txt)[0] + +print("Set as bearer token in the clients to access Weaviate.") +``` + +#### トークンの有効期間 + +トークンの有効期限はトークン発行者によって設定可能です。有効期限前に新しいトークンを取得するワークフローを確立することを推奨します。 + +
+ +### リクエストに Bearer を追加する + +import APIKeyUsage from '/\_includes/clients/api-token-usage.mdx'; + + + +たとえば cURL コマンドは次のようになります。 + +```bash +curl https://localhost:8080/v1/objects -H "Authorization: Bearer ${WEAVIATE_API_KEY}" | jq +``` + +## 認可 + +Weaviate はユーザーの [認証](#認証) 状態に基づいて、権限レベルを分けたアクセス制御を提供します。ユーザーには管理者権限、読み取り専用権限、あるいは権限なしのいずれかを付与できます。`v1.29.0` からは、ユーザー権限をより細かく制御できる [ロールベースアクセス制御 (RBAC)](./rbac/index.mdx) もサポートされました。 + +次の図は、ユーザーリクエストが認証・認可のプロセスを経る流れを示しています。 + +```mermaid +flowchart TB + User(["Authenticated User"]) --> AuthScheme{"Authorization
Scheme?"} + + subgraph rbac ["RBAC Authorization"] + direction TB + AdminRole["Admin Role"] + ViewerRole["Viewer Role"] + CustomRole["Custom Roles"] + + Perms1["Full Access
All Operations"] + Perms2["Read-only
Access"] + Perms3["Custom
Permissions"] + + AdminRole --> Perms1 + ViewerRole --> Perms2 + CustomRole --> Perms3 + end + + subgraph adminlist ["Admin List Authorization"] + direction TB + AdminUser["Admin Users"] + ReadOnly["Read-only Users"] + AnonUser["Anonymous Users
(Optional)"] + + AllPerms["Full Access
All Operations"] + ReadPerms["Read-only
Access"] + + AdminUser --> AllPerms + ReadOnly --> ReadPerms + AnonUser -.->|"If enabled"| AllPerms + AnonUser -.->|"If enabled"| ReadPerms + end + + subgraph undiffer ["Undifferentiated Access"] + AllAccess["Full Access
All Operations"] + end + + AuthScheme -->|"RBAC"| rbac + AuthScheme -->|"Admin List"| adminlist + AuthScheme -->|"Undifferentiated"| undiffer + + %% Style nodes + style User fill:#f9f9f9,stroke:#666 + style AuthScheme fill:#f5f5f5,stroke:#666 + style AnonUser fill:#f9f9f9,stroke:#666,stroke-dasharray: 5 5 + + %% Style subgraphs + style rbac fill:#e6f3ff,stroke:#4a90e2 + style adminlist fill:#e6ffe6,stroke:#2ea44f + style undiffer fill:#fff0e6,stroke:#ff9933 +``` + +Weaviate で利用できる認可方式は以下のとおりです。 + +- [ロールベースアクセス制御 (RBAC)](../../deploy/configuration/authorization.md#role-based-access-control-rbac) +- [管理者リスト](../../deploy/configuration/authorization.md#admin-list) +- [区別なしアクセス](../../deploy/configuration/authorization.md#undifferentiated-access) + +Admin リスト方式では、[匿名ユーザー](../../deploy/configuration/authorization.md#anonymous-users) に権限を付与することも可能です。 + +認可の設定方法は、Docker で実行するか Kubernetes で実行するかによって異なります。以下に両方の例を示します。 + + + +## 追加リソース + +- [構成: 認証](/deploy/configuration/authentication.md) +- [構成: 認可](/deploy/configuration/authorization.md) +- [構成: 環境変数 - 認証と認可](/deploy/configuration/env-vars/index.md#authentication-and-authorization) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/bq-compression.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/bq-compression.md new file mode 100644 index 000000000..49a7f65fd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/bq-compression.md @@ -0,0 +1,223 @@ +--- +title: バイナリ量子化 (BQ) +sidebar_position: 6 +image: og/docs/configuration.jpg +# tags: ['configuration', 'compression', 'bq'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/\_includes/code/howto/configure.bq-compression.py'; +import PyCodeV3 from '!!raw-loader!/\_includes/code/howto/configure.bq-compression-v3.py'; +import TSCode from '!!raw-loader!/\_includes/code/howto/configure.bq-compression.ts'; +import TSCodeBQOptions from '!!raw-loader!/\_includes/code/howto/configure.bq-compression.options.ts'; +import TSCodeLegacy from '!!raw-loader!/\_includes/code/howto/configure.bq-compression-v2.ts'; +import GoCode from '!!raw-loader!/\_includes/code/howto/go/docs/configure/compression.bq_test.go'; +import JavaCode from '!!raw-loader!/\_includes/code/howto/java/src/test/java/io/weaviate/docs/bq-compression.java'; + +:::info Added in `v1.23` +BQ は `v1.23` 以降で [`flat` index](/weaviate/concepts/indexing/vector-index.md#flat-index) タイプに対応し、`v1.24` からは [`hnsw` index](/weaviate/config-refs/indexing/vector-index.mdx#hnsw-index) タイプにも対応しています。 +::: + +バイナリ量子化 (BQ) は、ベクトルのサイズを削減できるベクトル圧縮手法です。 + +BQ を使用するには、以下のように有効化し、コレクションにデータを追加します。 + +
+ 追加情報 + +- [インデックス タイプを設定する方法](../../manage-collections/vector-config.mdx#set-vector-index-type) + +
+ +## 新規コレクションでの圧縮の有効化 + +コレクション作成時に、コレクション定義で BQ を有効化できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 既存コレクションでの圧縮の有効化 + +:::info Added in `v1.31` +コレクション作成後に BQ 圧縮を有効化する機能は Weaviate `v1.31` で追加されました。 +::: + +既存のコレクションでも、コレクション定義を更新することで BQ を有効化できます。 + + + + + + + + + + + + + + + +## BQ パラメーター + +BQ 圧縮には、`vectorIndexConfig` 内で次のパラメーターを使用できます: + +import BQParameters from '/\_includes/configuration/bq-compression-parameters.mdx' ; + + + +例: + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 追加の考慮事項 + +### 複数 ベクトル 埋め込み(名前付き ベクトル) + +import NamedVectorCompress from '/\_includes/named-vector-compress.mdx'; + + + +### マルチ ベクトル 埋め込み(ColBERT、ColPali など) + +import MultiVectorCompress from '/\_includes/multi-vector-compress.mdx'; + + + +## 追加リソース + +- [スターターガイド: 圧縮](/docs/weaviate/starter-guides/managing-resources/compression.mdx) +- [リファレンス: ベクトル インデックス](/weaviate/config-refs/indexing/vector-index.mdx) +- [コンセプト: ベクトル 量子化](/docs/weaviate/concepts/vector-quantization.md) +- [コンセプト: ベクトル インデックス](/weaviate/concepts/indexing/vector-index.md) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/index.md new file mode 100644 index 000000000..a9483c219 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/index.md @@ -0,0 +1,19 @@ +--- +title: 圧縮 +sidebar_position: 5 +image: og/docs/configuration.jpg +# tags: ['configuration', 'compression', 'pq'] +--- + +未圧縮のベクトルは大きくなる場合があります。圧縮したベクトルは一部の情報を失いますが、使用リソースが少なく、コスト効率に優れています。 + +リソースコストとシステム性能を両立させるために、次のオプションを検討してください。 + +- [バイナリ量子化 ( BQ )](/weaviate/configuration/compression/bq-compression) +- [直積量子化 ( PQ )](/weaviate/configuration/compression/pq-compression) +- [回転量子化 ( RQ )](/weaviate/configuration/compression/rq-compression) +- [スカラー量子化 ( SQ )](/weaviate/configuration/compression/sq-compression) + +量子化以外にも、Weaviate ではマルチ ベクトル埋め込み向けのエンコーディングを提供しています: +- [MUVERA エンコーディング](./multi-vectors.md) + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/multi-vectors.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/multi-vectors.md new file mode 100644 index 000000000..030c2f274 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/multi-vectors.md @@ -0,0 +1,86 @@ +--- +title: マルチ ベクトル エンコーディング +sidebar_position: 30 +image: og/docs/configuration.jpg +# tags: ['configuration', 'compression'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/\_includes/code/howto/manage-data.collections.py'; +import TSCode from '!!raw-loader!/\_includes/code/howto/manage-data.collections.ts'; + + +マルチ ベクトル 埋め込みは、ドキュメントや画像などの単一データ オブジェクトを 1 本の ベクトル ではなく、複数の ベクトル の集合で表現します。これにより、各 ベクトル がオブジェクトの異なる部分を表すことで、より細かな意味情報を捉えられます。しかし、その分各アイテムに複数の ベクトル を保持するため、メモリ使用量が大幅に増加します。 + +そのため、ストレージ コストを抑えクエリ レイテンシを改善するには、マルチ ベクトル システムにおける圧縮技術が特に重要になります。**エンコーディング** は、マルチ ベクトル 全体を新しいコンパクトな単一 ベクトル 表現へと変換し、意味的な関係性を維持しようとします。 + +## MUVERA エンコーディング + +** MUVERA **( _Multi-Vector Retrieval via Fixed Dimensional Encodings_ )は、マルチ ベクトル 埋め込みを固定次元の単一 ベクトル にエンコードすることで、メモリ使用量の増加と処理速度の低下という課題に取り組みます。これにより、従来のマルチ ベクトル 手法と比べてメモリ消費を抑えられます。 + + + + + + + + + + + + +```java +// Java support coming soon +``` + + + + +```go +// Go support coming soon +``` + + + + +MUVERA でエンコードされた ベクトル の最終次元数は +`repetition * 2^ksim * dprojections` になります。これらのパラメータを慎重にチューニングし、メモリ使用量と検索精度のバランスを取ることが重要です。 + +以下のパラメータで MUVERA を微調整できます。 + +- **`ksim`** (`int`): + SimHash パーティショニング関数のためにサンプリングされるガウシアン ベクトル の本数です。この値がハッシュのビット数、ひいては空間分割ステップで作成されるバケット数を決定します。総バケット数は $2^{ksim}$ となります。`ksim` を大きくすると埋め込み空間がより細かく分割され、近似精度が向上する可能性がありますが、中間エンコード ベクトル の次元数も増加します。 + +- **`dprojections`** (`int`): + 次元削減ステップでランダム線形射影後のサブ ベクトル の次元数です。バケットごとに集約された ベクトル はランダム行列を用いて `dprojections` 次元に射影されます。`dprojections` を小さくすると、最終的な固定次元エンコーディングの総次元数を抑えられるためメモリ消費を削減できますが、情報損失と検索精度低下を招く可能性があります。 + +- **`repetition`** (`int`): + 空間分割と次元削減ステップを繰り返す回数です。繰り返しによってマルチ ベクトル 埋め込みの異なる側面を捉え、最終的な固定次元エンコーディングの堅牢性と精度を高められます。各繰り返しで得られた単一 ベクトル は連結されます。`repetition` を増やすと最終エンコーディングの次元数は増加しますが、元のマルチ ベクトル 類似度をより良く近似できる場合があります。 + +:::note Quantization +量子化(Quantization)は、マルチ ベクトル 埋め込みに対する圧縮技術としても利用できます。値を低精度で近似することで各 ベクトル のメモリ フットプリントを削減します。単一 ベクトル と同様に、マルチ ベクトル でも [PQ](./pq-compression.md)、[BQ](./bq-compression.md)、[RQ](./rq-compression.md)、[SQ](./sq-compression.md) の量子化をサポートしています。 +::: + +## 参考リソース + +- [操作ガイド: コレクションの管理](../../manage-collections/vector-config.mdx#define-multi-vector-embeddings-eg-colbert-colpali) +- [概念: ベクトル 量子化](../../concepts/vector-quantization.md) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/pq-compression.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/pq-compression.md new file mode 100644 index 000000000..78d789972 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/pq-compression.md @@ -0,0 +1,393 @@ +--- +title: 直積量子化 (PQ) +sidebar_position: 5 +image: og/docs/configuration.jpg +# tags: ['configuration', 'compression', 'pq'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/\_includes/code/howto/configure.pq-compression.py'; +import PyCodeV3 from '!!raw-loader!/\_includes/code/howto/configure.pq-compression-v3.py'; +import TSCodeAutoPQ from '!!raw-loader!/\_includes/code/howto/configure.pq-compression.autopq.ts'; +import TSCodeManualPQ from '!!raw-loader!/\_includes/code/howto/configure.pq-compression.manual.ts'; +import TSCodeLegacy from '!!raw-loader!/\_includes/code/howto/configure.pq-compression-v2.ts'; +import GoCode from '!!raw-loader!/\_includes/code/howto/go/docs/configure/compression.pq_test.go'; +import JavaCode from '!!raw-loader!/\_includes/code/howto/java/src/test/java/io/weaviate/docs/pq-compression.java'; + +:::note +v1.23 から、AutoPQ は新しいコレクションでの PQ 設定を簡素化します。 +::: + +import PQOverview from '/\_includes/configuration/pq-compression/overview-text.mdx' ; + + + +import PQTradeoffs from '/\_includes/configuration/pq-compression/tradeoffs.mdx' ; + + + +HNSW を設定するには、[設定: ベクトル インデックス](/weaviate/config-refs/indexing/vector-index.mdx) を参照してください。 + +## PQ 圧縮の有効化 + +PQ はコレクション単位で設定します。PQ 圧縮を有効にする方法は 2 つあります。 + +- [AutoPQ を使用して PQ 圧縮を有効化](./pq-compression.md#configure-autopq) +- [手動で PQ 圧縮を有効化](./pq-compression.md#manually-configure-pq) + +## AutoPQ の設定 + +:::info v1.23.0 で追加 +::: + +新しいコレクションでは AutoPQ を使用してください。AutoPQ は、コレクションのサイズに基づき PQ のトレーニング ステップのトリガーを自動化します。 + +### 1. 環境変数の設定 + +AutoPQ には非同期インデックス作成が必要です。 + +- **オープンソース版 Weaviate 利用者**: AutoPQ を有効にするには、環境変数 `ASYNC_INDEXING=true` を設定し、Weaviate インスタンスを再起動します。 +- [**Weaviate Cloud (WCD)**](https://console.weaviate.cloud/) 利用者: WCD コンソールで非同期インデックス作成を有効にし、Weaviate インスタンスを再起動します。 + +### 2. PQ の設定 + +コレクションで PQ を設定するには、[PQ パラメーター](./pq-compression.md#pq-parameters) を使用します。 + + + + + + + + + + + + + + + + + + + + +### 3. データのロード + +データをロードします。トレーニング用の初期データをロードする必要はありません。 + +AutoPQ は、オブジェクト数がトレーニング上限に達した時点で PQ コードブックを作成します。デフォルトでは、トレーニング上限はシャードあたり 100,000 オブジェクトです。 + +## PQ を手動で設定 + +既存のコレクションに対して PQ を手動で有効にできます。PQ を有効にすると、Weaviate は PQ コードブックをトレーニングします。PQ を有効にする前に、トレーニング セットがシャードあたり 100,000 オブジェクトあることを確認してください。 + +PQ を手動で有効にするには、次の手順に従います。 + +- フェーズ 1: コードブックの作成 + + - [PQ なしでコレクションを定義](./pq-compression.md#1-define-a-collection-without-pq) + - [トレーニング データをロード](./pq-compression.md#2-load-training-data) + - [PQ を有効化し、コードブックを作成](./pq-compression.md#3-enable-pq-and-create-the-codebook) + +- フェーズ 2: 残りのデータをロード + + - [残りのデータをロード](./pq-compression.md#4-load-the-rest-of-your-data) + +:::tip トレーニング セットの推奨サイズ +シャードあたり 10,000 〜 100,000 オブジェクトを推奨します。 +::: + +PQ が有効になったとき、そしてベクトル圧縮が完了したときに、Weaviate は[メッセージをログに出力](#check-the-system-logs)します。初期トレーニング ステップが完了するまでは、残りのデータをインポートしないでください。 + +以上が、PQ を手動で有効にする手順です。 + + + +### 1. PQ なしのコレクション定義 + +[コレクションを作成](../../manage-collections/collection-operations.mdx#create-a-collection) し、量子化器を指定しません。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +### 2. 学習データの読み込み + +PQ の学習に使用する [オブジェクトを追加](/weaviate/manage-objects/import.mdx) します。Weaviate は、学習上限とコレクションサイズのうち大きい方を使用して PQ を学習します。 + +学習済みのセントロイドが全データセットを代表するように、代表的なサンプルを読み込むことを推奨します。 + +バージョン v1.27.0 から、Weaviate は手動で PQ を有効にした場合に利用可能なオブジェクトから学習セットを選択するため、疎な [Fisher-Yates アルゴリズム](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle) を使用します。それでもなお、学習済みのセントロイドがデータセット全体を代表するように、代表的なサンプルを読み込むことを推奨します。 + +### 3. PQ の有効化とコードブックの作成 + +コレクション定義を更新して PQ を有効化します。PQ が有効になると、Weaviate は学習データを使用してコードブックを学習します。 + +import PQMakesCodebook from '/\_includes/configuration/pq-compression/makes-a-codebook.mdx' ; + + + +PQ を有効にするには、以下のようにコレクション定義を更新します。追加の設定オプションについては、[PQ パラメータ一覧](./pq-compression.md#pq-parameters) を参照してください。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +### 4. 残りのデータのロード + +[コードブックのトレーニング完了後](#3-enable-pq-and-create-the-codebook)、通常どおりにデータを追加できます。Weaviate は新しいデータをデータベースに追加する際に圧縮します。 + +コードブックを作成する時点で既に Weaviate インスタンスにデータが存在する場合、Weaviate は残りのオブジェクト(初期トレーニングセット以降のもの)を自動的に圧縮します。 + +## PQ パラメーター + +コレクションレベルで以下のパラメーターを設定することで、PQ 圧縮を構成できます。 + +import PQParameters from '/\_includes/configuration/pq-compression/parameters.mdx' ; + + + +## 追加ツールと留意事項 + +### コードブックのトレーニング上限の変更 + +一般的なユースケースでは、100,000 オブジェクトが最適なトレーニングサイズです。`trainingLimit` を増やしても大きな効果は得られません。`trainingLimit` を大きくするとトレーニング時間が長くなるほか、高すぎるとメモリ不足が発生する可能性があります。 + +小規模データセットで圧縮を有効にしたい場合は、[バイナリ量子化 (BQ)](./bq-compression.md) の利用を検討してください。BQ はトレーニングを必要としない、よりシンプルな圧縮方式です。 + +### システムログの確認 + +圧縮が有効になると、Weaviate は次のような診断メッセージをログに記録します。 + +```bash +pq-conf-demo-1 | {"action":"compress","level":"info","msg":"switching to compressed vectors","time":"2023-11-13T21:10:52Z"} + +pq-conf-demo-1 | {"action":"compress","level":"info","msg":"vector compression complete","time":"2023-11-13T21:10:53Z"} +``` + +`docker-compose` で Weaviate を実行している場合、システムコンソールからログを取得できます。 + +```bash +docker compose logs -f --tail 10 weaviate +``` + +また、ログファイルを直接確認することもできます。ファイルの場所は `docker` でご確認ください。 + +```bash +docker inspect --format='{{.LogPath}}' +``` + +### 現在の `pq` 設定の確認 + +現在の `pq` 設定を確認するには、次のように取得できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +### 複数ベクトル埋め込み(名前付きベクトル) + +import NamedVectorCompress from '/\_includes/named-vector-compress.mdx'; + + + +### マルチベクトル埋め込み(ColBERT、ColPali など) + +import MultiVectorCompress from '/\_includes/multi-vector-compress.mdx'; + + + +## さらなる参考資料 + +- [スターターガイド: 圧縮](/docs/weaviate/starter-guides/managing-resources/compression.mdx) +- [リファレンス: ベクトルインデックス](/weaviate/config-refs/indexing/vector-index.mdx) +- [コンセプト: ベクトル量子化](/docs/weaviate/concepts/vector-quantization.md) +- [コンセプト: ベクトルインデックス](/weaviate/concepts/indexing/vector-index.md) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/rq-compression.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/rq-compression.md new file mode 100644 index 000000000..b8787b13c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/rq-compression.md @@ -0,0 +1,183 @@ +--- +title: 回転量子化 (RQ) +sidebar_position: 25 +image: og/docs/configuration.jpg +# tags: ['configuration', 'compression', 'rq'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/\_includes/code/howto/configure-rq/rq-compression-v4.py'; +import GoCode from '!!raw-loader!/\_includes/code/howto/go/docs/configure/compression.rq_test.go'; +import TSCode from '!!raw-loader!/\_includes/code/howto/configure-rq/rq-compression-v3.ts'; +import JavaCode from '!!raw-loader!/\_includes/code/howto/java/src/test/java/io/weaviate/docs/rq-compression.java'; + +:::caution 技術プレビュー + +回転量子化 ( RQ ) は **`v1.32`** で **技術プレビュー** として追加されました。

+これは、この機能がまだ開発中であり、将来のリリースで変更される可能性があることを意味します。互換性が破壊される変更が含まれる場合もあります。 +**現時点では本番環境での使用は推奨しません。** + +::: + +[**回転量子化 ( RQ )**](../../concepts/vector-quantization.md#rotational-quantization) は、4 倍の圧縮率でほぼ完璧なリコール ( ほとんどのデータセットで 98-99% ) を維持する、高速で学習不要なベクトル圧縮手法です。 + +:::note HNSW のみ +RQ は現在、フラットインデックス型をサポートしていません。 +::: + +## 新しいコレクションでの圧縮の有効化 + +RQ はコレクション作成時に、コレクション定義を通じて有効化できます。 + + + + + + + + + + + + + + + + +## 既存コレクションでの圧縮の有効化 + +RQ は、既存のコレクションに対してもコレクション定義を更新することで有効化できます。 + + + + + + + + + + + + + +## RQ パラメーター + +RQ を調整するには、以下の量子化およびベクトルインデックスパラメーターを使用します。 + +import RQParameters from '/\_includes/configuration/rq-compression-parameters.mdx' ; + + + + + + + + + + + + + + + + + + + + + + +## 追加の考慮事項 + +### 複数 ベクトル エンベディング(名前付き ベクトル) + +import NamedVectorCompress from '/\_includes/named-vector-compress.mdx'; + + + +### マルチベクトル エンベディング (ColBERT、ColPali など) + +import MultiVectorCompress from '/\_includes/multi-vector-compress.mdx'; + + + +:::note マルチベクトルのパフォーマンス +RQ はマルチベクトル エンベディングをサポートしています。各トークン ベクトルは 64 次元の倍数に切り上げられるため、非常に短いベクトルでは 4x 未満の圧縮になる場合があります。これは技術的な制限であり、将来のバージョンで改善される可能性があります。 +::: + +## 追加リソース + +- [スターター ガイド: 圧縮](/docs/weaviate/starter-guides/managing-resources/compression.mdx) +- [リファレンス: ベクトル インデックス](/weaviate/config-refs/indexing/vector-index.mdx) +- [コンセプト: ベクトル 量子化](/docs/weaviate/concepts/vector-quantization.md) +- [コンセプト: ベクトル インデックス](/weaviate/concepts/indexing/vector-index.md) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/sq-compression.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/sq-compression.md new file mode 100644 index 000000000..95f52b131 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/compression/sq-compression.md @@ -0,0 +1,172 @@ +--- +title: スカラー量子化 (SQ) +sidebar_position: 27 +image: og/docs/configuration.jpg +# tags: ['configuration', 'compression', 'sq'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/\_includes/code/howto/configure-sq/sq-compression-v4.py'; +import PyCodeV3 from '!!raw-loader!/\_includes/code/howto/configure-sq/sq-compression-v3.py'; +import TSCode from '!!raw-loader!/\_includes/code/howto/configure-sq/sq-compression-v3.ts'; +import TSCodeSQOptions from '!!raw-loader!/\_includes/code/howto/configure-sq/sq-compression.options-v3.ts'; +import TSCodeLegacy from '!!raw-loader!/\_includes/code/howto/configure-sq/sq-compression-v2.ts'; +import GoCode from '!!raw-loader!/\_includes/code/howto/go/docs/configure/compression.sq_test.go'; +import JavaCode from '!!raw-loader!/\_includes/code/howto/java/src/test/java/io/weaviate/docs/sq-compression.java'; + +:::info Added in v1.26.0 + +::: + +[スカラー量子化 (SQ)](/weaviate/concepts/vector-quantization#scalar-quantization) は、ベクトルのサイズを削減できるベクトル圧縮手法です。 + +SQ を使用するには、コレクション定義で有効化してからデータをコレクションに追加します。 + +## 新規コレクションでの圧縮の有効化 + +SQ はコレクション作成時に、コレクション定義を通じて有効化できます。 + + + + + + + + + + + + + + + + +## 既存コレクションでの圧縮の有効化 + +:::info Added in `v1.31` +コレクション作成後に SQ 圧縮を有効化できる機能は Weaviate `v1.31` で追加されました。 +::: + +既存のコレクションでも、コレクション定義を更新することで SQ を有効化できます。 + + + + + + + + + + + + + +## SQ パラメーター + +SQ を調整するには、これらの `vectorIndexConfig` パラメーターを設定します。 + +import SQParameters from '/\_includes/configuration/sq-compression-parameters.mdx' ; + + + + + + + + + + + + + + + + + + + + +## 追加の考慮事項 + +### 複数ベクトル埋め込み(名前付きベクトル) + +import NamedVectorCompress from '/\_includes/named-vector-compress.mdx'; + + + +### マルチベクトル埋め込み( ColBERT、 ColPali など) + +import MultiVectorCompress from '/\_includes/multi-vector-compress.mdx'; + + + +## さらに学ぶ + +- [スターターガイド: 圧縮](/docs/weaviate/starter-guides/managing-resources/compression.mdx) +- [リファレンス: ベクトル インデックス](/weaviate/config-refs/indexing/vector-index.mdx) +- [概念: ベクトル 量子化](/docs/weaviate/concepts/vector-quantization.md) +- [概念: ベクトル インデックス](/weaviate/concepts/indexing/vector-index.md) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/hnsw-snapshots.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/hnsw-snapshots.md new file mode 100644 index 000000000..a71e80a0b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/hnsw-snapshots.md @@ -0,0 +1,65 @@ +--- +title: HNSW スナップショット +sidebar_position: 47 +sidebar_label: HNSW Snapshots +description: Weaviate における HNSW スナップショットで起動時間を短縮する方法と、その管理方法について学びます。 +--- + +:::info Added in `v1.31` +::: + +HNSW (Hierarchical Navigable Small World) スナップショットは、大規模な ベクトル インデックス を持つインスタンスの起動時間を大幅に短縮できます。 + +デフォルトでは、HNSW スナップショット機能は **無効** です。この機能を使用するには、以下に示す [環境変数](/deploy/configuration/env-vars/index.md) を設定してください。 + +:::info Concepts: HNSW snapshots +詳細な説明は、この [概念ページ](../concepts/storage.md#hnsw-snapshots) をご覧ください。 +::: + +## 1. HNSW スナップショットの有効化 + +`PERSISTENCE_HNSW_DISABLE_SNAPSHOTS` を `false` に設定して HNSW スナップショット機能を有効にします。(デフォルト: `true`) + +## 2. スナップショット作成の設定 + +以下のオプションの環境変数を設定することで、スナップショット動作を調整できます。 + +:::note +新しいスナップショットを作成する前に、前回のスナップショットとコミットログの差分をメモリに読み込む必要があります。この処理を行うのに十分なメモリがあることをご確認ください。 +::: + +### 起動時のスナップショット + +起動時のスナップショット作成を有効または無効にします: + +- `PERSISTENCE_HNSW_SNAPSHOT_ON_STARTUP`: `true` の場合、最後のスナップショット以降にコミットログに変更があれば、起動時に新しいスナップショットを作成します。変更がなければ既存のスナップショットが読み込まれます。 + - **Default:** `true` + +### 定期的なスナップショット + +定期的なスナップショット作成を設定します。スナップショットをトリガーするには、以下 **すべて** の条件を満たす必要があります: + +1. **一定時間が経過していること:** + + - `PERSISTENCE_HNSW_SNAPSHOT_INTERVAL_SECONDS`: 前回のスナップショットからの最小経過時間(秒)。 + - **Default:** `21600` 秒(6 時間) + +2. **新しいコミットログが十分な数あること:** + + - `PERSISTENCE_HNSW_SNAPSHOT_MIN_DELTA_COMMITLOGS_NUMBER`: 前回のスナップショット以降に作成された新しいコミットログファイル数の最小値。 + - **Default:** `1` + +3. **新しいコミットログの合計サイズが十分であること(割合):** + - `PERSISTENCE_HNSW_SNAPSHOT_MIN_DELTA_COMMITLOGS_SIZE_PERCENTAGE`: 前回のスナップショットサイズに対する新しいコミットログ合計サイズの最小割合。 + - **Default:** `5` (前回のスナップショットサイズの 5% に相当するコミットログが必要)。例えば前回のスナップショットが 1000MB の場合、新しいコミットログが 50MB 以上になるとスナップショットが作成されます。 + +## 参考リソース + +- [概念: ストレージ - 永続化とクラッシュリカバリー](../concepts/storage.md#persistence-and-crash-recovery) + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-async-queue.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-async-queue.png new file mode 100644 index 000000000..903f8aa6e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-async-queue.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-importing.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-importing.png new file mode 100644 index 000000000..09fceb956 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-importing.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-lsm.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-lsm.png new file mode 100644 index 000000000..7cd3a9fd5 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-lsm.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-objects.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-objects.png new file mode 100644 index 000000000..4b0c148bc Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-objects.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-startup.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-startup.png new file mode 100644 index 000000000..aae320f17 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-startup.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-usage.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-usage.png new file mode 100644 index 000000000..09706dca1 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-usage.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-vector.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-vector.png new file mode 100644 index 000000000..aa3e28a19 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/img/weaviate-sample-dashboard-vector.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/index.mdx new file mode 100644 index 000000000..8bce0c156 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/index.mdx @@ -0,0 +1,196 @@ +--- +title: Weaviate の設定方法 +sidebar_position: 0 +image: og/docs/configuration.jpg +hide_table_of_contents: true +# tags: ['configuration'] +--- + +以下のガイドを使用して、 Weaviate インスタンスの主要な運用面を設定および管理します: + +import CardsSection from "/src/components/CardsSection"; + +export const configOpsData = [ + { + title: "圧縮 / 量子化 (PQ/BQ/RQ/SQ)", + description: + "直積、バイナリ、回転、スカラーの量子化手法でメモリ使用量を削減します。", + link: "/weaviate/configuration/compression", + icon: "fas fa-compress-alt", + }, + { + title: "モジュール", + description: + " Weaviate のベクトライザー、検索拡張生成 (RAG) などのモジュール エコシステムを探索します。", + link: "/weaviate/configuration/modules", + icon: "fas fa-puzzle-piece", + }, + { + title: "認証と認可", + description: + "アクセスを許可する前にユーザーの身元を認証・確認する方法を設定します。", + link: "/weaviate/configuration/authz-authn", + icon: "fas fa-key", + }, + { + title: "RBAC", + description: + "ロールベースアクセス制御の概念、事前定義 / カスタム ロール、および権限について学びます。", + link: "/weaviate/configuration/rbac", + icon: "fas fa-user-shield", + }, +]; + +
+ +
+ +## デプロイ ガイド + +### 設定 + +export const configurationData = [ + { + title: "バックアップ", + description: + " Weaviate インスタンスのバックアップとリストア手順を設定します。", + link: "/deploy/configuration/backups", + icon: "fas fa-save", + }, + { + title: "環境変数", + description: + "接続文字列、ポート、セキュリティ資格情報のために環境変数を設定します。", + link: "/deploy/configuration/env-vars", + icon: "fas fa-cog", + }, + { + title: "水平スケーリング", + description: "高可用性のためにデプロイメントをスケールします。", + link: "/deploy/configuration/horizontal-scaling", + icon: "fas fa-arrow-up-right-dots", + }, + { + title: "永続化", + description: "バックアップを有効化し、保持ポリシーを設定します。", + link: "/deploy/configuration/persistence", + icon: "fas fa-floppy-disk", + }, + { + title: "テナント オフロード", + description: + "マルチテナント構成で非アクティブなテナントをオフロードしてリソース使用量を管理します。", + link: "/deploy/configuration/tenant-offloading", + icon: "fas fa-pause-circle", + }, +]; + +
+ +
+ +### 認可と認証 + +export const authData = [ + { + title: "認証", + description: "デプロイメントのアクセス管理を設定します。", + link: "/deploy/configuration/authentication", + icon: "fas fa-shield-halved", + }, + { + title: "認可", + description: "ユーザー ロールと権限を定義および管理します。", + link: "/deploy/configuration/authorization", + icon: "fas fa-user-shield", + }, + { + title: "RBAC の設定", + description: + "詳細な権限のためにロールベースアクセス制御を設定します。", + link: "/deploy/configuration/configuring-rbac", + icon: "fas fa-users-cog", + }, + { + title: "OIDC 設定", + description: + " Weaviate と安全に連携する OpenID Connect を設定します。", + link: "/deploy/configuration/oidc", + icon: "fas fa-lock", + }, +]; + +
+ +
+ + +### レプリケーション + +export const replicationData = [ + { + title: "レプリケーション", + description: + "高可用性と障害耐性を実現するため、ノード間でデータのレプリケーションを設定します。", + link: "/deploy/configuration/replication", + icon: "fas fa-copy", + }, + { + title: "非同期レプリケーション", + description: + "分散クラスタ内のノード間で最終的な整合性を確保します。", + link: "/deploy/configuration/async-rep", + icon: "fas fa-clone", + }, +]; + +
+ +
+ +### クラスタ情報 + +export const clusterInfoData = [ + { + title: "クラスタメタデータ", + description: "Weaviate クラスタに関するメタデータへアクセスし、管理します。", + link: "/deploy/configuration/meta", + icon: "fas fa-info-circle", + }, + { + title: "モニタリング、メトリクス、およびログ", + description: "Weaviate インスタンスの状態と健全性を監視します。", + link: "/deploy/configuration/monitoring", + icon: "fas fa-chart-bar", + }, + { + title: "クラスタノードデータ", + description: "クラスタ内の各ノードに関するデータを表示および管理します。", + link: "/deploy/configuration/nodes", + icon: "fas fa-server", + }, + { + title: "ステータス", + description: "Weaviate インスタンスの状態と健全性を監視します。", + link: "/deploy/configuration/status", + icon: "fas fa-heartbeat", + }, + { + title: "テレメトリ", + description: + "Weaviate のテレメトリがどのように機能するかを理解し、設定方法を確認します。", + link: "/deploy/configuration/telemetry", + icon: "fas fa-chart-line", + }, +]; + +
+ +
+ +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/modules.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/modules.md new file mode 100644 index 000000000..e3d5074b5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/modules.md @@ -0,0 +1,158 @@ +--- +title: モジュール +sidebar_position: 11 +image: og/docs/configuration.jpg +# tags: ['configuration', 'modules'] +--- + +Weaviate の機能は、[モジュール](/weaviate/concepts/modules.md) を使用してカスタマイズできます。ここでは、モジュールを有効化して設定する方法について説明します。 + +## インスタンスレベルの設定 + +インスタンス (つまり Weaviate クラスター) レベルでは、次のことが行えます。 + +- モジュールの有効化 +- デフォルト ベクトライザー モジュールの設定 +- モジュール固有の変数 (例: API キー) の設定 + +これらは、以下のように適切な [環境変数](/deploy/configuration/env-vars/index.md) を設定することで行えます。 + +:::tip WCD については? +Weaviate Cloud (WCD) のインスタンスにはモジュールがあらかじめ設定されています。詳細は [こちらのページ](/cloud/manage-clusters/status#enabled-modules) をご覧ください。 +::: + +### 個別モジュールの有効化 + +`ENABLE_MODULES` 変数にモジュールのリストを指定すると、モジュールを有効化できます。たとえば、以下のコードは `text2vec-transformers` モジュールを有効化します。 + +```yaml +services: + weaviate: + environment: + ENABLE_MODULES: 'text2vec-transformers' +``` + +複数のモジュールを有効化する場合は、カンマ区切りで追加します。 + +次の例では、`text2vec-huggingface`、`generative-cohere`、`qna-openai` モジュールを有効化します。 + +```yaml +services: + weaviate: + environment: + ENABLE_MODULES: 'text2vec-huggingface,generative-cohere,qna-openai' +``` + +### すべての API ベース モジュールを有効化 + +:::caution 実験的機能 +`v1.26.0` 以降で利用可能な実験的機能です。使用にはご注意ください。 +::: + +`ENABLE_API_BASED_MODULES` 変数を `true` に設定すると、すべての API ベース [モデル統合](../model-providers/index.md) (Anthropic、Cohere、OpenAI など) を有効化できます。これにより関連モジュールがすべて有効化されます。これらのモジュールは軽量のため、まとめて有効化してもリソース使用量が大幅に増えることはありません。 + +```yaml +services: + weaviate: + environment: + ENABLE_API_BASED_MODULES: 'true' +``` + +API ベース モジュールの一覧は [モデルプロバイダー統合ページ](../model-providers/index.md#api-based) で確認できます。また、リストが定義されている [ソースコード](https://github.com/weaviate/weaviate/blob/main/adapters/handlers/rest/configure_api.go) を参照することも可能です。 + +個別モジュールの有効化と組み合わせることもできます。たとえば、次の例ではすべての API ベース モジュール、Ollama モジュール、そして `backup-s3` モジュールを有効化しています。 + +```yaml +services: + weaviate: + environment: + ENABLE_API_BASED_MODULES: 'true' + ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-s3' +``` + +複数のベクトライザー (例: `text2vec`, `multi2vec`) モジュールを有効化すると、[`Explore` 機能](../api/graphql/explore.md) が無効化されます。`Explore` を使用する必要がある場合は、ベクトライザー モジュールを 1 つだけ有効化してください。 + +### モジュール固有の変数 + +モジュールによっては、追加の環境変数設定が必要です。たとえば、`backup-s3` モジュールでは `BACKUP_S3_BUCKET` にバックアップ用 S3 バケットを指定する必要があり、`text2vec-contextionary` モジュールでは `TRANSFORMERS_INFERENCE_API` に推論 API の場所を指定する必要があります。 + +詳細は各 [モジュールのドキュメント](../modules/index.md) を参照してください。 + +## ベクトライザーモジュール + +[ベクトル化統合](../model-providers/index.md) により、インポート時にデータをベクトル化し、`nearText` や `nearImage` などの [`near`](../search/similarity.md) 検索を実行できます。 + +:::info 利用可能なベクトライザー統合の一覧 +[こちらのセクション](../model-providers/index.md) に掲載しています。 +::: + +### ベクトライザーモジュールの有効化 + +`ENABLE_MODULES` 環境変数に追加することで、ベクトライザーモジュールを有効化できます。下記コードは `text2vec-cohere`、`text2vec-huggingface`、`text2vec-openai` の各ベクトライザーモジュールを有効化します。 + +```yaml +services: + weaviate: + environment: + ENABLE_MODULES: 'text2vec-cohere,text2vec-huggingface,text2vec-openai' +``` + +### デフォルト ベクトライザー モジュール + +`DEFAULT_VECTORIZER_MODULE` 変数を使用して、デフォルトのベクトライザーモジュールを指定できます。 + +デフォルト ベクトライザーモジュールを設定しない場合、スキーマでベクトライザーを設定するまで `near` やインポート時のベクトル化は利用できません。 + +次のコードでは `text2vec-huggingface` をデフォルト ベクトライザーとして設定しています。そのため、クラスで別のベクトライザーを指定しない限り、`text2vec-huggingface` が使用されます。 + +``` yaml +services: + weaviate: + environment: + DEFAULT_VECTORIZER_MODULE: text2vec-huggingface +``` + +## 生成モデル統合 + +[生成モデル統合](../model-providers/index.md) により、[検索拡張生成](../search/generative.md) 機能を利用できます。 + +### 生成モジュールの有効化 + +生成モジュールを有効化するには、目的のモジュールを `ENABLE_MODULES` 環境変数に追加します。以下のコードは、`generative-cohere` モジュールと `text2vec-huggingface` ベクトライザーモジュールを有効化します。 + +```yaml +services: + weaviate: + environment: + ENABLE_MODULES: 'text2vec-huggingface,generative-cohere' +``` + +:::tip `generative` モジュールと `text2vec` モジュールの選択は独立 +`text2vec` モジュールの選択が `generative` モジュールの選択を制限することはありません。逆も同様です。 +::: + +## テナントオフロードモジュール + +テナントをコールドストレージにオフロードしてメモリとディスクの使用量を削減し、必要に応じてオンロードできます。 + +設定方法の詳細は [テナントオフロード設定](/deploy/configuration/tenant-offloading.md) の専用ページをご覧ください。テナントのオフロードとオンロードの方法については、[How-to: テナント状態の管理](../manage-collections/tenant-states.mdx) を参照してください。 + +## カスタムモジュール + +独自モジュールの作成と使用方法については [こちら](../modules/custom-modules.md) をご覧ください。 + +## 使用量モジュール + +[使用量モジュール](../modules/usage-modules.md) は、使用状況の分析データを GCS または S3 に収集しアップロードします。 + +## 関連ページ +- [概念: モジュール](../concepts/modules.md) +- [リファレンス: モジュール](../modules/index.md) + +## 質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/_category_.json new file mode 100644 index 000000000..cf965eaf1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "RBAC", + "position": 36 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/index.mdx new file mode 100644 index 000000000..27b2593b1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/index.mdx @@ -0,0 +1,438 @@ +--- +title: RBAC 概要 +sidebar_label: RBAC +sidebar_position: 0 +image: og/docs/configuration.jpg +# tags: ['rbac', 'roles', 'configuration', 'authorization'] +--- + +import Link from '@docusaurus/Link'; +import SkipLink from '/src/components/SkipValidationLink' + +:::info `v1.29` で追加 +ロールベースアクセス制御(RBAC)は、バージョン `v1.29` から Weaviate で正式に利用可能になりました。 +::: + +Weaviate は、[認証](/deploy/configuration/authentication.md) 済みユーザーの ID に基づき、[認可](/deploy/configuration/authorization.md) レベルごとに差別化されたアクセスを提供します。 + +RBAC を有効にすると、ユーザーのロールに基づいてさらにアクセスを制限できます。以下の図は Weaviate における RBAC モデルを示しており、ロールを定義し、それぞれに特定の権限を割り当てることでアクセスを制御します。これらの権限は、指定されたリソースタイプに対してユーザーが実行できる操作を決定します。 + +主な構成要素は次のとおりです。 + +- **ユーザー** + 個々のユーザー(例: `user-a`, `user-b`)は特定のロールに割り当てられます。 + +- **ロール** + 各ロールは一連の権限をカプセル化します。この抽象化により、ユーザーグループが実行できる操作を管理できます。 + +- **権限** + 権限は 3 つの要素で構成されます。 + - **アクション**: create、read、update、delete、manage などの操作 + - **リソース**: コレクションやバックアップなど、これらの操作の対象 + - **オプションの制約**: コレクション名でのフィルタリングなど、リソース固有の制約 + +```mermaid +graph LR + %% Users Subgraph + subgraph Users + UA["user-a"] + UB["user-b"] + end + + %% Roles Subgraph + subgraph Roles + RWR["readWriteRole"] + BM["backupManager"] + end + + %% Permissions Group (contains Actions and Resources) with extra newline for spacing + subgraph Permissions["Permissions"] + %% Actions Subgraph + subgraph Actions + C["create"] + R["read"] + U["update"] + D["delete"] + M["manage"] + end + + %% Resources Subgraph + subgraph Resources + COL["collections"] + BAC["backups"] + end + end + + %% Connections for user-a + UA --> RWR + RWR --> C + RWR --> R + RWR --> U + RWR --> D + + %% Connections for user-b + UB --> BM + BM --> M + + %% Connections from actions to resources + C --> COL + R --> COL + U --> COL + D --> COL + M --> BAC + +%% Styling with soothing, Weaviate-compatible colors and slightly darker borders +style Users fill:#AEDFF7,stroke:#90C7E5,stroke-width:1px +style Roles fill:#C8E6C9,stroke:#A5D6A7,stroke-width:1px +style Actions fill:#ECEFF1,stroke:#B0BEC5,stroke-width:1px +style Resources fill:#CFD8DC,stroke:#AAB4BA,stroke-width:1px +style Permissions fill:#E0F7FA,stroke:#B2EBF2,stroke-width:1px +``` + +この RBAC システムにより、ユーザーは自身のロールに必要な最小限のアクセスのみを持つことになり、Weaviate 内のセキュリティと管理性が向上します。ロールと権限は、Weaviate の REST API もしくは **[クライアントライブラリ](/weaviate/configuration/rbac/manage-roles)** からプログラムで管理できます。 + +## ロール + +### 事前定義ロール + +Weaviate には、いくつかの事前定義ロールが用意されています。 + +- `root`: すべてのリソースに対する **フルアクセス** を持ちます。 +- `viewer`: すべてのリソースに対する **読み取り専用アクセス** を持ちます。 + +`root` ロールは、[`AUTHORIZATION_RBAC_ROOT_USERS`](/deploy/configuration/env-vars/index.md#rbac-authorization) 環境変数を使用して Weaviate の設定ファイル経由でユーザーに割り当てられます。事前定義ロールは変更できませんが、ユーザーには Weaviate API を通じて追加ロールを付与することが可能です。 + +事前定義ロールを含むすべてのロールは、Weaviate API でユーザーに割り当てたり取り消したりできます。事前定義ロール自体を変更することはできません。 + +ユーザーへ事前定義ロールを割り当てる方法の詳細は、[RBAC: 設定](/deploy/configuration/configuring-rbac.md) を参照してください。 + +### カスタムロール + +事前定義ロールが割り当てられていない認証済みユーザーには、デフォルトでロールも権限もありません。 + +これらのユーザーの権限は、**ロール管理** の適切な権限を持つユーザーによって Weaviate 上で変更できます。これにより、必要に応じてカスタムロールを作成し、ユーザーに割り当てることが可能です。 + +ロール管理は、[事前定義 `root` ロール](/deploy/configuration/configuring-rbac.md) または [`manage_roles` 権限](/weaviate/configuration/rbac/manage-roles#role-management-permissions) を持つカスタムロールで実行できます。 + +:::caution Role Management Permissions +ロールを管理する権限をロールに付与する際は注意してください。これらの権限を利用して、ユーザーに追加のロールを割り当てることで特権を昇格させる可能性があります。信頼できるユーザーにのみ付与してください。 +::: + +## 権限 + +Weaviate における権限は、ユーザーが特定リソースに対してどの操作を実行できるかを定義します。各権限は以下で構成されます。 + +- リソースタイプ(例: collections, objects) +- アクセスレベル(read, write, update, delete, manage) +- オプションのリソース固有制約 + +### 利用可能な権限 + +権限は、以下のリソース・アクセスレベル・オプション制約で定義できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
リソースタイプアクセスレベルリソース固有のオプション制約
+ + ロール管理 + + +
ロールの作成
+
ロール情報の読み取り
+
ロール権限の更新
+
ロールの削除
+
+
+

ロール名フィルタ:

+
    +
  • + string または regex: 管理対象のロールを指定 +
  • +
+
+
+

ロールスコープ:

+
    +
  • + all: すべての権限でロール管理を許可 +
  • +
  • + match: 現在のユーザーと同レベルの権限でのみロール管理を許可 +
  • +
+
+
+ + ユーザー管理 + + +
ユーザーの作成
+
ユーザー情報の読み取り
+
ユーザー API キーの更新/ローテート
+
ユーザーの削除
+
+ ユーザーへのロール付与および取り消し +
+
+
+

ユーザー名フィルタ:

+
    +
  • + string または regex: 管理対象のユーザーを指定 +
  • +
+
+
+ + コレクション + +
+ + (コレクション定義のみ、データオブジェクトの権限は別) + +
+
コレクションの作成
+
コレクション定義の読み取り
+
コレクション定義の更新
+
コレクションの削除
+
+

コレクション名フィルタ:

+
    +
  • + string または regex: 管理対象のコレクションを指定 +
  • +
+
+ + テナント + + +
テナントの作成
+
テナント情報の読み取り
+
テナントの更新
+
テナントの削除
+
+

コレクション名フィルタ:

+
    +
  • + string または regex: 管理対象のコレクションを指定 +
  • +
+

テナント名フィルタ:

+
    +
  • + string または regex: 管理対象のテナントを指定 +
  • +
+
+ + データオブジェクト + + +
オブジェクトの作成
+
オブジェクトの読み取り
+
オブジェクトの更新
+
オブジェクトの削除
+
+

コレクション名フィルタ:

+
    +
  • + string または regex: 管理対象のコレクションを指定 +
  • +
+

テナント名フィルタ:

+
    +
  • + string または regex: 管理対象のテナントを指定 +
  • +
+
+ + バックアップ + + バックアップの管理 +

コレクション名フィルタ:

+
    +
  • + string または regex: 管理対象のコレクションを指定 +
  • +
+
+ + クラスター データアクセス + + クラスター メタデータの読み取り
+ + ノード データアクセス + + 指定した詳細度でノードメタデータを読み取り +
+

詳細度 (Verbosity level):

+
    +
  • + minimal: すべてのコレクションに対し最小限の読み取り +
  • +
  • + verbose: 指定したコレクションに対し詳細な読み取り +
  • +
+
+
+

+ コレクション名フィルタ(verbose のみ): +

+
    +
  • + string または regex: 管理対象のコレクションを指定 +
  • +
+
+
+ + コレクションエイリアス + + +
エイリアスの作成
+
エイリアスの読み取り
+
エイリアスの更新
+
エイリアスの削除
+
+

エイリアス名フィルタ:

+
    +
  • + string または regex: 管理対象のエイリアスを指定 +
  • +
+
+ + レプリケーション + + +
レプリケーションの作成
+
レプリケーションの読み取り
+
レプリケーションの更新
+
レプリケーションの削除
+
+

コレクション名フィルタ:

+
    +
  • + string または regex: 管理対象のコレクションを指定 +
  • +
+

シャード名フィルタ:

+
    +
  • + string または regex: 管理対象のシャードを指定 +
  • +
+
+ + + +### 権限の動作 + +権限を定義する際、ある権限を `False` に設定すると、それはアクセスを明示的に拒否するのではなく _設定されていない_ ことを意味します。したがって、ユーザーが複数のロールを持ち、一方のロールが権限を付与し、もう一方のロールがその権限を `False` に設定している場合でも、権限を付与しているロールによってユーザーはその権限を保持します。 + +たとえば、ユーザーが次の 2 つのロールを持っている場合: + +- ロール A は Collection X に対して `read` を `False` に設定 +- ロール B は Collection X に対して `read` を `True` に設定 + +ユーザーは Collection X に対する読み取りアクセスを持ちます。これは、ロール B が権限を付与しており、ロール A の `False` はアクセスをブロックするのではなく権限が設定されていないことを示すだけだからです。 + +### 権限における名前フィルター + +一部の権限では、その権限を適用するコレクションを指定するためにコレクション名フィルターが必要です。 + +この場合、`"*"` は複数文字のワイルドカードとして機能します。たとえば、コレクション名フィルターに `"Test*"` を指定すると、`Test` で始まるすべてのコレクションにその権限が適用されます。また、`"*"` をフィルターに指定すると、利用可能なすべてのコレクションに適用されます。 + +### コレクションとテナントの権限 + +コレクションに対する権限は、テナントに対する権限とは独立しています。 + +あるコレクションに属するテナントを操作する権限を得るには、そのコレクションに対する適切なテナントレベルの権限が必要です。コレクションの作成などのコレクションレベルの権限は、そのコレクションのテナントを作成するなどの同等のテナントレベルの権限を付与しません。 + +たとえば、`TestCollection` というコレクションでテナントを作成するには、そのコレクション内のテナントを "create" する権限が必要です。これは `TestCollection` というコレクションを作成する権限とは別です。 + +## ユーザー + +[user 管理](./manage-users.mdx) API を使用して、ユーザーの作成、削除、一覧取得、API キーのローテーション、およびロールの管理ができます。 + +## 参考リソース + +- [RBAC: 設定](/deploy/configuration/configuring-rbac.md) +- [RBAC: ロール管理](./manage-roles.mdx) +- [RBAC: ユーザー管理](./manage-users.mdx) +- [RBAC: チュートリアル](/deploy/tutorials/rbac.mdx) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/manage-roles.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/manage-roles.mdx new file mode 100644 index 000000000..498f8493e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/manage-roles.mdx @@ -0,0 +1,772 @@ +--- +title: ロールの管理 +sidebar_label: Manage roles +sidebar_position: 1 +image: og/docs/configuration.jpg +# tags: ['rbac', 'roles', 'configuration', 'authorization'] +--- + +import Link from '@docusaurus/Link'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/python/howto.configure.rbac.permissions.py'; +import TSCode from '!!raw-loader!/_includes/code/typescript/howto.configure.rbac.permissions.ts'; +import RolePyCode from '!!raw-loader!/_includes/code/python/howto.configure.rbac.roles.py'; +import RoleTSCode from '!!raw-loader!/_includes/code/typescript/howto.configure.rbac.roles.ts'; + +:::info Added in `v1.29` +ロールベースアクセス制御 (RBAC) は、Weaviate ではバージョン `v1.29` から一般公開されています。 +::: + +Weaviate における RBAC では、ロールを定義し、そのロールに権限を割り当てることができます。ユーザーをロールに割り当てることで、そのロールに付与された権限を継承できます。 + +このページでは、Weaviate クライアントライブラリを使用して **ロールと権限を管理** する方法の例を紹介します。 + +import ConfigureRbac from '/_includes/configuration/configure-rbac.mdx'; + + + +## ロール管理の前提条件 {#requirements} + +ロール管理には、以下の方法で取得できる適切な `role` リソース権限が必要です。 + +- [RBAC を構成](/deploy/configuration/configuring-rbac.md) する際に定義された `root` ロール +- [`Role Management`](#role-management-permissions) 権限が付与されたロール + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +## ロール管理 {#role-management} + +### 権限付きの新しいロールの作成 + +次のリソースタイプに対する権限をロールに割り当てることができます。 + +1. [**Role Management**](#role-management-permissions) + +1. [**User Management**](#user-management-permissions) + +1. [**Collections**](#collections-permissions)(コレクション定義のみ。データオブジェクトの権限は別途設定) + +1. [**Tenants**](#tenants-permissions) + +1. [**Data Objects**](#data-permissions) + +1. [**Backup**](#backups-permissions) + +1. [**Cluster Data Access**](#clusters-permissions) + +1. [**Node Data Access**](#nodes-permissions) + +#### `Role Management` 権限を持つロールの作成 {#role-management-permissions} + +この例では、`testRole` というロールを作成し、以下の権限を付与します。 + +- `testRole*` で始まるすべてのロールを作成、読み取り、更新、削除できます。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + + + +#### `User Management` パーミッションを持つロールの作成 {#user-management-permissions} + +この例では、`testRole` というロールを作成し、次の権限を付与します: + +- `testUser*` で始まるすべてのユーザーの作成、読み取り、更新、および削除。 +- `testUser*` で始まるユーザーへのロールの付与および取り消し。 + + + + + + + +```typescript +// TS/JS support coming soon +``` + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +#### `Collections` パーミッションを持つロールの作成 {#collections-permissions} + +この例では、`testRole` というロールを作成し、次の権限を付与します: + +- `TargetCollection` で始まるすべてのコレクションの作成、読み取り、更新、および削除。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +#### `Tenant` パーミッションを持つロールの作成 {#tenants-permissions} + +この例では、`testRole` というロールを作成し、次の権限を付与します: + +- `TargetCollection` で始まるコレクション内で、`TargetTenant` で始まるテナントの作成および削除。 +- `TargetCollection` で始まるコレクション内で、`TargetTenant` で始まるテナントのメタデータ(テナント名やステータスなど)の読み取り。 +- `TargetCollection` で始まるコレクション内で、`TargetTenant` で始まるテナントのステータスの更新。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +#### `Data Objects` パーミッションを持つロールの作成 {#data-permissions} + +この例では、`testRole` というロールを作成し、次の権限を付与します: + +- `TargetCollection` で始まるコレクションのデータの作成、読み取り、更新、および削除。 +- マルチテナンシーが有効で `tenant` フィルターが設定されている場合、この権限は `TargetTenant` で始まるテナントにのみ適用されます。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +#### `Backups` 権限を持つロールの作成 {#backups-permissions} + +この例では、 `testRole` というロールを作成し、以下の権限を付与します: + +- `TargetCollection` で始まるコレクションのバックアップを管理します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +#### `Cluster Data Access` 権限を持つロールの作成 {#clusters-permissions} + +この例では、 `testRole` というロールを作成し、以下の権限を付与します: + +- クラスター メタデータを読み取ります。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +#### `Node Data Access` 権限を持つロールの作成 {#nodes-permissions} + +この例では、 `testRole` というロールを作成し、以下の権限を付与します: + +- `TargetCollection` で始まるコレクションについて、指定した詳細レベルでノード メタデータを読み取ります。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +#### `Collection Aliases` 権限を持つロールの作成 {#aliases-permissions} + +この例では、 `testRole` というロールを作成し、以下の権限を付与します: + +- `TargetAlias` で始まるコレクション エイリアスの作成、読み取り、更新、削除を行います。 + + + + + + + +```typescript +// TS/JS support coming soon +``` + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + + +#### `Replications` パーミッションを持つロールの作成 {#replications-permissions} + +この例では、 `testRole` という名前のロールを作成し、以下のパーミッションを付与します。 + +- `TargetCollection` で始まるコレクションおよび `TargetShard` で始まるシャードに対するレプリカ移動操作の作成・読み取り・更新・削除 + + + + + + + +```typescript +// TS/JS support coming soon +``` + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### 追加パーミッションの付与 + +追加パーミッションはいつでもロールに付与できます。対象のロールは既に存在している必要があります。 + +この例では、ロール `testRole` に以下の追加パーミッションを付与します。 + +- `TargetCollection` で始まるコレクションに **新しいデータを作成** する + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### ロールからのパーミッション削除 + +パーミッションはいつでもロールから取り消すことができます。すべてのパーミッションを削除すると、そのロール自体も削除されます。 + +この例では、ロール `testRole` から以下のパーミッションを削除します。 + +- `TargetCollection` で始まるコレクションのデータを読み取る +- `TargetCollection` で始まるコレクションを作成および削除する + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### ロールの存在確認 + +ロール `testRole` が存在するかどうかを確認します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + + + +### ロールの確認 + +ロールに割り当てられている権限を表示します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### すべてのロールの一覧 + +システム内のすべてのロールとそれらの権限を表示します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### ロールを持つユーザーの一覧 + +`testRole` を持つすべてのユーザーを一覧表示します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### ロールの削除 + +ロールを削除すると、システムからそのロールが削除され、該当するユーザーから関連する権限が取り消されます。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +## ユーザー管理 {#user-management} + +ユーザーにロールを割り当てたり、ユーザーの作成・更新・削除について詳しく知るには、[ユーザー管理](./manage-users.mdx) ページをご覧ください。 + +## 追加リソース + +- [ RBAC: 概要](./index.mdx) +- [ RBAC: 設定](/deploy/configuration/configuring-rbac.md) +- [ RBAC: ユーザー管理](./manage-users.mdx) + +## ご質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/manage-users.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/manage-users.mdx new file mode 100644 index 000000000..264df1a52 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/configuration/rbac/manage-users.mdx @@ -0,0 +1,496 @@ +--- +title: ユーザー管理 +sidebar_label: ユーザー管理 +sidebar_position: 1 +image: og/docs/configuration.jpg +# tags: ['rbac', 'roles', 'configuration', 'authorization'] +--- + +import Link from '@docusaurus/Link'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/python/howto.configure.rbac.permissions.py'; +import TSCode from '!!raw-loader!/_includes/code/typescript/howto.configure.rbac.permissions.ts'; +import UserPyCode from '!!raw-loader!/_includes/code/python/howto.configure.rbac.users.py'; +import UserTSCode from '!!raw-loader!/_includes/code/typescript/howto.configure.rbac.users.ts'; +import OidcUserPyCode from '!!raw-loader!/_includes/code/python/howto.configure.rbac.oidc.users.py'; +import OidcUserTSCode from '!!raw-loader!/_includes/code/typescript/howto.configure.rbac.oidc.users.ts'; + + +:::info `v1.29` と `v1.30` で追加 +ロールベースアクセス制御 ( RBAC ) は Weaviate `v1.29` から一般提供されています。 +ユーザー管理機能は `v1.30` から利用可能です。 +::: + +Weaviate では、ロールベースアクセス制御 ( RBAC ) により、ロールを定義し、それぞれに権限を割り当てられます。ユーザーはロールに紐付けられ、そのロールに設定された権限を継承します。 + +Weaviate には複数種類のユーザーが存在します。**データベースユーザー** は Weaviate インスタンスによって完全に管理され、**OIDC** ユーザーは外部アイデンティティプロバイダーによって管理されます。どちらのタイプも RBAC と併用できます。 + +このページでは、Weaviate クライアントライブラリーを使用して **ユーザー** とそのロールをプログラムで管理する方法を示します。 + +:::note Weaviate におけるユーザータイプ + + + +内部的には、Weaviate は次の 3 種類のユーザーを区別します。 + +- `db_user`: API を通じて完全に管理できるデータベースユーザー +- `db_env_user`: `AUTHENTICATION_APIKEY_USERS` 環境変数で定義され、変数の変更と Weaviate 再起動によってのみ更新可能なデータベースユーザー +- `oidc`: 外部 OIDC サービスでのみ作成/削除できるユーザー + +::: + +## ユーザー管理 {#user-management} + +### ユーザー一覧 + +この例では、Weaviate 内のすべてのユーザー (`db_user`, `db_env_user`, `oidc`) を取得する方法を示します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +
+ 結果例 + +```text +[ + UserDB(user_id='custom-user', role_names=['viewer', 'testRole'], user_type=, active=True), + UserDB(user_id='root-user', role_names=['root'], user_type=, active=True) +] +``` + +
+ +### データベースユーザーの作成 {#create-a-user} + +この例では `custom-user` というユーザーを作成します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +
+ 結果例 + +```text +RXF1dU1VcWM1Q3hvVndYT0F1OTBOTDZLZWx0ME5kbWVJRVdPL25EVW12QT1fMXlDUEhUNjhSMlNtazdHcV92MjAw +``` + +
+ + + +### データベースユーザーの削除 + +この例では `custom-user` というユーザーを削除します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### データベースユーザー API キーのローテーション {#rotate-user-api-key} + +この例では `custom-user` の API キーを更新(ローテーション)します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +
+ 実行結果の例 + +```text +SSs3WGVFbUxMVFhlOEsxVVMrQVBzM1VhQTJIM2xXWngwY01HaXFYVnM1az1fMXlDUEhUNjhSMlNtazdHcV92MjAw +``` + +
+ +## データベースユーザー:権限管理 {#user-permissions-management} + +### データベースユーザーへのロール割り当て + +カスタムユーザーには、ゼロ個を含む任意の数のロールを割り当てることができます。ロールはあらかじめ定義されたロール(例: `viewer`)でも、カスタムロールでもかまいません。 + +この例では、カスタムロール `testRole` と、事前定義済みロール `viewer` を `custom-user` に割り当てます。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### データベースユーザーからのロール削除 + +特定のユーザーから 1 つ以上のロールを取り消すことができます。 + +この例では、ユーザー `custom-user` からロール `testRole` を削除します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + + +### データベース ユーザーのロール取得 + +任意のユーザーのロール情報を取得します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +
+ 結果例 + +```text +testRole +viewer +``` + +
+ +## OIDC ユーザー: 権限管理 {#oidc-user-permissions-management} + +[OIDC](/deploy/configuration/oidc.md) を使用すると、アイデンティティ プロバイダーがユーザーを認証してトークンを発行し、それを Weaviate が検証します。これらのユーザーには RBAC を用いてカスタム権限を持つロールを割り当てられます。 + +### OIDC ユーザーへのロール割り当て + +OIDC ユーザーには、ロールを 0 個以上割り当てることができます。ロールはあらかじめ定義されたロール(例: `viewer`)でも、カスタム ロールでも構いません。 + +この例では、カスタム ロール `testRole` と、定義済みロール `viewer` を `custom-user` に割り当てます。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### OIDC ユーザーからのロール削除 + +特定の OIDC ユーザーから 1 つ以上のロールを取り消すことができます。 + +この例では、ユーザー `custom-user` からロール `testRole` を削除します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +### OIDC ユーザーのロール取得 + +OIDC ユーザーのロール情報を取得します。 + + + + + + + + + + +```go +// Go support coming soon +``` + + + + +```java +// Java support coming soon +``` + + + + +
+ 結果例 + +```text +testRole +viewer +``` + +
+ + + +## 追加リソース + +- RBAC :概要](./index.mdx) +- RBAC :設定](/deploy/configuration/configuring-rbac.md) +- RBAC :ロールの管理](./manage-roles.mdx) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/_category_.json new file mode 100644 index 000000000..8afb96e09 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "How-to: Connect", + "position": 70 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-cloud.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-cloud.mdx new file mode 100644 index 000000000..2a881f643 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-cloud.mdx @@ -0,0 +1,183 @@ +--- +title: Weaviate クラウド +sidebar_position: 10 +image: og/docs/connect.jpg +# tags: ['getting started', 'connect'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; + +import PyCodeV3 from '!!raw-loader!/_includes/code/connections/connect-python-v3.py'; +import PyCodeV4 from '!!raw-loader!/_includes/code/connections/connect-python-v4.py'; +import TsCodeV3 from '!!raw-loader!/_includes/code/connections/connect-ts-v3.ts'; +import TsCodeV2 from '!!raw-loader!/_includes/code/connections/connect-ts-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/connections/connect.java'; +import ShellCode from '!!raw-loader!/_includes/code/connections/connect.sh'; +import GoCode from '!!raw-loader!/_includes/code/connections/connect.go'; + +以下の手順で Weaviate クラウド (WCD) インスタンスに接続します。 + +## API キーと REST エンドポイントの取得 + +import RetrieveAPIKeys from '/_includes/wcs/retrieve-api-keys.mdx'; + + + +## 接続例 + + + +接続には、`REST Endpoint` と `Admin` API キーを [環境変数](#environment-variables) に保存して使用します。 + +import HostnameWarning from '/_includes/wcs/hostname-warning.mdx'; + + + + + + + + + + + + + + + + + + + + + + + + + + + +## サードパーティ API キー + +ベクトル化や RAG に API ベースのモデルを使用する場合、サービスの API キーが必要です。サードパーティ API キーを追加するには、以下の例に従ってください。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 環境変数 + +import EnvVarsHowto from '/_includes/environment-variables.mdx'; + + + +## gRPC タイムアウト + +import GRPCTimeoutIntro from '/_includes/connect/timeouts-intro.mdx'; + + + +import GRPCTimeouts from '/_includes/code/connections/timeouts-cloud.mdx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-custom.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-custom.mdx new file mode 100644 index 000000000..7fde96f0c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-custom.mdx @@ -0,0 +1,97 @@ +--- +title: カスタム接続 +sidebar_position: 30 +image: og/docs/connect.jpg +# tags: ['getting started', 'connect'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; + +import PyCodeV4 from '!!raw-loader!/_includes/code/connections/connect-python-v4.py'; +import TsCodeV3 from '!!raw-loader!/_includes/code/connections/connect-ts-v3.ts'; + +[Python クライアント v4](/weaviate/client-libraries/python) と [TypeScript クライアント v3](../client-libraries/typescript/index.mdx) では、一般的な接続タイプ向けのヘルパーメソッドを提供しています。さらに、追加の接続設定が必要な場合に使用できるカスタムメソッドも用意されています。 + +他のクライアントを使用している場合でも、標準の接続メソッドはすべての接続で設定可能です。 + + + + + + + + + + +## 環境変数 + +import EnvVarsHowto from '/_includes/environment-variables.mdx'; + + + +## gRPC タイムアウト + +import GRPCTimeoutIntro from '/_includes/connect/timeouts-intro.mdx'; + + + +import GRPCTimeouts from '/_includes/code/connections/timeouts-custom.mdx'; + + + +## サードパーティ API キー + +外部 API を利用するインテグレーションでは、API キーが必要になることがよくあります。サードパーティの API キーを追加するには、次の例を参考にしてください: + + + + + + + + + + +## OIDC 認証 + +import WCDOIDCWarning from '/_includes/wcd-oidc.mdx'; + + + +import OIDCConnect from '/_includes/connect/oidc-connect-ref.mdx'; + + + +import OIDCExamples from '/_includes/code/connections/oidc-connect.mdx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-embedded.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-embedded.mdx new file mode 100644 index 000000000..74b2574cf --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-embedded.mdx @@ -0,0 +1,56 @@ +--- +title: 組み込み Weaviate +sidebar_position: 30 +image: og/docs/connect.jpg +# tags: ['getting started', 'connect'] +--- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; + +import PyCodeV3 from '!!raw-loader!/_includes/code/connections/connect-python-v3.py'; +import PyCodeV4 from '!!raw-loader!/_includes/code/connections/connect-python-v4.py'; +import TsCodeV3 from '!!raw-loader!/_includes/code/connections/connect-ts-v3.ts'; +import TsCodeV2 from '!!raw-loader!/_includes/code/connections/connect-ts-v2.ts'; + +import EMBDIntro from '/_includes/embedded-intro.mdx'; + + + +組み込み Weaviate の使用方法の詳細については、[組み込み Weaviate](/deploy/installation-guides/embedded) を参照してください。 + +## Embedded Weaviate インスタンスの起動 + + + + + + + + + + + + + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-local.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-local.mdx new file mode 100644 index 000000000..096168fc9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-local.mdx @@ -0,0 +1,316 @@ +--- +title: ローカル インスタンス +sidebar_position: 20 +image: og/docs/connect.jpg +# tags: ['getting started', 'connect'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; + +import WCSWithoutAuthentication from '/_includes/code/wcs.without.authentication.mdx'; +import WCSAuthenticationApiKey from '/_includes/code/wcs.authentication.api.key.mdx'; +import WCDAuthAndInferenceKeys from '/_includes/code/wcs.authentication.api.key.with.inference.key.mdx'; + +import PyCodeV3 from '!!raw-loader!/_includes/code/connections/connect-python-v3.py'; +import PyCodeV4 from '!!raw-loader!/_includes/code/connections/connect-python-v4.py'; +import TsCodeV3 from '!!raw-loader!/_includes/code/connections/connect-ts-v3.ts'; +import TsCodeV2 from '!!raw-loader!/_includes/code/connections/connect-ts-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/connections/connect.java'; +import ShellCode from '!!raw-loader!/_includes/code/connections/connect.sh'; +import GoCode from '!!raw-loader!/_includes/code/connections/connect.go'; + +ローカルにホストした Weaviate インスタンスへ接続するには、次の手順に従います。 + +## ローカル接続 URL + +Docker インスタンスのデフォルト URL は `http://localhost:8080` です。gRPC ポート `50051` も `localhost` でリッスンしています。 + +インスタンスを Kubernetes 上で実行している場合は、Helm チャートの `values.yaml` ファイルにある `host` と `port` の値を確認してください。 + +## 認証なしでの接続 + +認証を有効にしていないローカル インスタンスへ接続するには、以下の例を参照してください。 + + + + + + + + + + + + + + + + + + + + + + + + + +## URL またはポートを変更する + +デフォルトの URL やポート番号を変更する場合は、以下の例を参照してください。 + + + + + + + + + + + + + + + + + + + + + + + + + + +## 認証の有効化 + +Weaviate の API キーで認証するには、次の例に従ってください。 + + + + + + + + + + + + + + + + + + + + + + + + + +### OIDC 認証 + +import OIDCConnect from '/_includes/connect/oidc-connect-ref.mdx'; + + + +その他のクライアント例については、[OIDC 認証](/weaviate/connections/connect-custom#oidc-authentication) を参照してください。 + +## サードパーティ API キー + +外部 API を利用する統合では、API キーが必要になることがよくあります。サードパーティ API キーを追加するには、次の例に従ってください: + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 環境変数 + +import EnvVarsHowto from '/_includes/environment-variables.mdx'; + + + +## gRPC タイムアウト + +import GRPCTimeoutIntro from '/_includes/connect/timeouts-intro.mdx'; + + + +import GRPCTimeouts from '/_includes/code/connections/timeouts-local.mdx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-query.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-query.mdx new file mode 100644 index 000000000..a8c9a7bd5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/connect-query.mdx @@ -0,0 +1,64 @@ +--- +title: Query App で接続する +sidebar_position: 60 +image: og/docs/connect.jpg +# tags: ['getting started', 'connect'] +--- + +import WCDQueryConsoleLocation from '/docs/cloud/img/wcs-query-console-location.jpg'; + +[Query アプリケーション(query tool)](/cloud/tools/query-tool) は、ブラウザー ベースの GraphQL IDE です。Query ツールは Weaviate Cloud (WCD) コンソールで利用できます。 + +Query ツールを使用すると、Weaviate Cloud 上でホストされているクラスターやセルフホスト環境のインスタンスと対話的に作業できます。 + +## Query ツールの起動 + +Query ツールを使用するには、[WCD ダッシュボード](https://console.weaviate.cloud) を開きます。 + +左側のメニューで Query ツールのアイコンをクリックします。 + +WCD Query ツールの場所 + +## Weaviate インスタンスの選択 + +Query ツールは WCD クラスターに直接接続します。匿名アクセスが有効になっているか、認証情報がある場合は外部の Weaviate インスタンスにも接続できます。 + +クラスターを選択するには、`Query` ボタンをクリックし、クラスター一覧から目的のクラスターを選択します。 + +### 認証情報の指定 + +import ExternalAuth from '/_includes/wcs/query-auth-details.mdx'; + + + +### 推論キーの指定 + +推論モジュール用の API キーを渡すには、リクエストヘッダーを使用します。 + +1 つのヘッダーで複数のキーを渡せます。 + +```shell +{ + "X-Cohere-Api-key": "replaceWithYourCohereKey", + "X-HuggingFace-Api-key": "replaceWithYourHuggingFaceKey", + "X-OpenAI-Api-key": "replaceWithYourOpenAIKey", +} +``` + +## クエリ例 + +この例では、[キーワード検索](/weaviate/search/bm25) を使って映画データベースを検索します。左側には GraphiQL エディター があり、クエリの構築を支援します。クエリを実行すると、右側に結果が表示されます。 + +import QueryAppExample from '/docs/cloud/img/query-app-example.jpg'; + +Query ツールの例 + +GraphQL API の詳細は、[GraphQL API](/weaviate/api/graphql) を参照してください。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/index.mdx new file mode 100644 index 000000000..05aae9666 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/connections/index.mdx @@ -0,0 +1,28 @@ +--- +title: Weaviate への接続 +sidebar_position: 15 +image: og/docs/connect.jpg +# tags: ['getting started', 'connect'] +--- + +クライアントアプリケーションを Weaviate インスタンスに接続します: + +- [ Weaviate Cloud インスタンス](./connect-cloud.mdx) +- [ローカルホストのインスタンス](./connect-local.mdx) +- [カスタム接続](./connect-custom.mdx) + +埋め込み Weaviate インスタンスに接続します: + +- [埋め込み Weaviate インスタンス](./connect-embedded.mdx) + +Weaviate アプリを使用してセルフホスト型インスタンスへ接続します: + +- [Query アプリ](./connect-query.mdx) + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/guides.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/guides.mdx new file mode 100644 index 000000000..d545d176f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/guides.mdx @@ -0,0 +1,54 @@ +--- +title: 操作マニュアルとガイド +sidebar_label: Overview +sidebar_position: 0 +image: og/docs/introduction.jpg +# tags: [] +--- + + Weaviate の設定、管理、クエリ方法をまとめた簡潔なガイドをご覧ください。 +高度な設定のセットアップからデータ操作まで、ステップバイステップの手順と例が、 Weaviate をすばやく習得するのに役立ちます。 + +import CardsSection from "/src/components/CardsSection"; + +## ハウツー マニュアル + +import { howToGuidesCardsData } from "/_includes/configuration/how-to-manuals.js"; + +
+ +
+ +## その他のガイドとチュートリアル + +export const otherGuidesCardsData = [ + { + title: "デプロイ ガイド", + description: "本番環境で Weaviate をインストールして設定する方法を学べます。", + link: "/deploy/configuration", + icon: "fa fa-database", + }, + { + title: "チュートリアル", + description: "ステップバイステップのガイドと実践例。", + link: "/weaviate/tutorials", + icon: "fas fa-chalkboard-teacher", + }, + { + title: "スターター ガイド", + description: " Weaviate の使い方を学ぶ新規ユーザー向けのガイドとヒント。", + link: "/weaviate/starter-guides", + icon: "fas fa-compass", + }, + { + title: "レシピ", + description: + "さまざまなユースケースと機能を紹介する Jupyter Notebooks。", + link: "/weaviate/recipes", + icon: "fas fa-scroll", + }, +]; + +
+ +
\ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/index.mdx new file mode 100644 index 000000000..5bf42f4d3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/index.mdx @@ -0,0 +1,191 @@ +--- +title: Weaviate データベース +sidebar_position: 0 +description: "オープンソースの AI ネイティブ ベクトル データベース、 Weaviate の完全なドキュメント。" +image: og/docs/home.jpg +hide_table_of_contents: false +# tags: [] +--- + +import CardsSection from "/src/components/CardsSection"; +import DeploymentCards from "/src/components/DeploymentCards"; +import styles from "/src/components/CardsSection/styles.module.scss"; +import secondaryNavbarItems from "/secondaryNavbar.js"; + +export const welcomeCardsData = [ + { + id: "new", + title: " Weaviate を初めてお使いですか?", + description: ( + <> + まずは{" "} + クイックスタート チュートリアル から始めましょう。15〜30 分で完了するエンドツーエンドのデモです。 + + ), + link: "/weaviate/quickstart", + icon: "fas fa-star", // use Font Awesome CSS class + }, +]; + + Weaviate _(we-vee-eight)_ はオープンソースの AI ネイティブ ベクトル データベースです。ここでは Weaviate を使い始める方法と、 Weaviate の機能を最大限に活用する方法をご案内します。 + + + +
+ +## 適切なドキュメントとリソースを見つける + + Weaviate のドキュメントは、サービスと機能ごとに複数のユニットに分かれています。 + +{/* Filter out items where isSmall is true */} +{(() => { + const regularItems = Object.fromEntries( + Object.entries(secondaryNavbarItems).filter(([, value]) => !value.isSmall) + ); + +
+ return ; +
+})()} + +## Weaviate とは + + Weaviate は **オープンソースのベクトル データベース** で、データオブジェクトとそのベクトル埋め込みの両方を保存・インデックス化します。このアーキテクチャにより、キーワード一致のみに依存せず、ベクトルにエンコードされた意味を比較する高度なセマンティック検索が可能になります。主な機能は次のとおりです。 + +- **[セマンティック検索とハイブリッド検索](./search/basics.md)** + ベクトルでデータをインデックス化することで、セマンティック類似度とキーワードの両方に基づく検索をサポートします。検索語が保存されたデータと完全に一致しない場合でも、より関連性の高い結果を返します。 + +- **[検索拡張生成 (RAG)](./search/generative.md)** + Weaviate は RAG ワークフローの堅牢なバックエンドとして機能します。ベクトル検索で取得したコンテキストを生成モデルに提供し、正確でコンテキストに沿った回答生成を容易にします。 + +- **[エージェント駆動型ワークフロー](../agents/index.md)** + 柔軟な API と最新 AI モデルとの統合により、インテリジェント エージェントに依存するアプリケーションの基盤としても適しています。これらのエージェントは Weaviate に保存されたデータのセマンティックな洞察を活用して意思決定やアクションのトリガーを行えます。 + +## Weaviate エコシステム + + Weaviate エコシステムは、クラウドネイティブな AI 搭載アプリケーション構築を中心とした複数のツールとサービスで構成されています。 + +import WeaviateEcosystem from "@site/static/img/weaviate-ecosystem.png"; + + +
+ +上図のハイレベルな概要のとおり、エコシステムは次の要素から成ります。 + +- **[Weaviate Database](#what-is-weaviate)**: オブジェクトとベクトルの両方を保存するオープンソースのベクトル データベース。 +- **[Weaviate Cloud](/cloud)**: Weaviate ベクトル データベースのフルマネージド クラウド デプロイ。 +- **[Weaviate Agents](/agents)**: Weaviate Cloud ユーザー向けのプリビルド エージェント サービス。 +- **[Weaviate Embeddings](/cloud/embeddings)**: Weaviate Cloud ユーザー向けのマネージド埋め込み推論サービス。 +- **[外部モデルプロバイダー](/weaviate/model-providers)**: Weaviate と統合できるサードパーティーモデル。 + +## デプロイ方法を選ぶ + +export const deploymentCardsData = [ + { + tabs: [ + { label: "評価", active: true }, + { label: "デプロイ", active: true }, + { label: "本番", active: true }, + ], + header: "Weaviate Cloud", + bgImage: "/img/site/hex-weaviate.svg", + bgImageLight: "/img/site/hex-weaviate-light.svg", + listItems: [ + "評価 (サンドボックス) から本番まで", + "サーバーレス (インフラは Weaviate が管理)", + " (オプション) データ レプリケーション (高可用性)", + " (オプション) ゼロダウンタイム アップデート", + ], + button: { + text: "WCD インスタンスを設定", + link: "/cloud/manage-clusters/create", + }, + }, + { + tabs: [ + { label: "評価", active: true }, + { label: "デプロイ", active: true }, + { label: "本番", active: false }, + ], + header: "Docker", + bgImage: "/img/site/docker-doc-icon.svg", + bgImageLight: "/img/site/docker-doc-icon-light.svg", + listItems: [ + "ローカルでの評価 & 開発向け", + "ローカル推論コンテナ", + "マルチモーダル モデル", + "カスタマイズ可能な構成", + ], + button: { + text: "Docker で Weaviate を実行", + link: "/deploy/installation-guides/docker-installation", + }, + }, + { + tabs: [ + { label: "評価", active: false }, + { label: "デプロイ", active: true }, + { label: "本番", active: true }, + ], + header: "Kubernetes", + bgImage: "/img/site/kubernetes-doc-icon.svg", + bgImageLight: "/img/site/kubernetes-doc-icon-light.svg", + listItems: [ + "開発から本番まで対応", + "ローカル推論コンテナ", + "マルチモーダル モデル", + "カスタマイズ可能な構成", + "セルフデプロイまたは Marketplace デプロイ", + " (オプション) ゼロダウンタイム アップデート", + ], + button: { + text: "Kubernetes で Weaviate を実行", + link: "/deploy/installation-guides/k8s-installation", + }, + }, + { + tabs: [ + { label: "評価", active: true }, + { label: "デプロイ", active: false }, + { label: "本番", active: false }, + ], + header: "Embedded Weaviate", + bgImage: "/img/site/hex-weaviate.svg", + bgImageLight: "/img/site/hex-weaviate-light.svg", + listItems: [ + "ベーシックかつ迅速な評価向け", + "Python や JS/TS から手軽に Weaviate を起動", + ], + button: { + text: "Embedded Weaviate を実行", + link: "/deploy/installation-guides/embedded", + }, + }, +]; + + +## コミュニティとサポート + +export const communityCardsData = [ + { + id: "questions", + title: "Questions", + description: + "Please visit our forum. The Weaviate team and our awesome community can help.", + link: "https://forum.weaviate.io/c/support/", + icon: "fas fa-comments", + }, + { + id: "github", + title: "Open-source on GitHub", + description: "Give us a star on GitHub to support our work.", + link: "https://github.com/weaviate/weaviate", + icon: "fab fa-github", // note: brand icons use "fab" + }, +]; + + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/collection-aliases.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/collection-aliases.mdx new file mode 100644 index 000000000..32e9bfee6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/collection-aliases.mdx @@ -0,0 +1,341 @@ +--- +title: コレクション エイリアス +sidebar_label: Collection aliases +sidebar_position: 2 +image: og/docs/howto.jpg +--- + +import SkipLink from "/src/components/SkipValidationLink"; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/howto/manage-data.aliases.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.aliases.ts"; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.aliases_test.go"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.collection-aliases.java"; + +:::caution Technical preview + +コレクション エイリアスは **`v1.32`** で **技術プレビュー** として追加されました。

+この機能は現在も開発中であり、将来のリリースで変更される可能性があります。互換性が失われる変更が入ることもあります。 +**現時点では、本番環境での使用はおすすめしません。** + +::: + +コレクション エイリアスを使用すると、コレクションに別名を設定できます。これにより、ダウンタイムなしでのコレクション定義の変更、A/B テスト、あるいはより分かりやすい名前の提供などが可能になります。エイリアスはコレクションへの参照として機能し、エイリアス名でクエリを実行すると、 Weaviate が自動的に対象コレクションへリクエストをルーティングします。 + +## エイリアスの作成 + +エイリアスを作成するには、エイリアス名と、それが参照する対象コレクションを指定します。 + + + + + + + + + + + + + + + + +:::note + +- エイリアス名は一意でなければならず、既存のコレクション名またはエイリアス名と重複できません +- 複数のエイリアスを同じコレクションに向けることができます +- コレクションを削除する場合を除き、ほとんどの操作でコレクション名の代わりにエイリアスを使用できます +::: + +## すべてのエイリアスの一覧 + + Weaviate インスタンス内のすべてのエイリアスを取得します。 + + + + + + + + + + + + + + + + +## 特定のコレクションのエイリアス一覧 + +特定のコレクションを参照しているすべてのエイリアスを取得します。 + + + + + + + + + + + + + + + + + + +## エイリアス詳細の取得 + +特定のエイリアスに関する情報を取得します。 + + + + + + + + + + + + + + + + +## エイリアスの更新 + +エイリアスが参照するターゲット コレクションを変更します。この操作はアトミックで、コレクション間を即座に切り替えられます。 + + + + + + + + + + + + + + + + +:::tip ユースケース: ゼロダウンタイム マイグレーション + +エイリアスを更新することで、マイグレーションをシームレスに行えます。 + +1. 更新したコレクション定義で新しいコレクションを作成 +2. 新しいコレクションにデータをインポート +3. エイリアスを新しいコレクションへ向けて更新 +4. エイリアスを引き続き使用 — これ以降、そのエイリアスへのクエリはすべて新しいコレクションへ転送されます + +マイグレーションを実行するコード例については、[スターター ガイド: コレクション管理](../starter-guides/managing-collections/index.mdx#collection-aliases) を参照してください。 +::: + +## エイリアスの削除 + +エイリアスを削除します。これはエイリアス ポインターのみを削除し、基盤となるコレクションは削除しません。 + + + + + + + + + + + + + + + + +:::note + +- コレクションを削除しても、それを参照するエイリアスは自動で削除されません + +::: + + +## 操作でのエイリアスの使用 + +エイリアスを作成すると、ほとんどの操作でコレクション名の代わりに使用できます(コレクションを削除する場合を除く): + + + + + + + + + + + + + + + + +## 参考リソース + +- [コレクションの管理:基本操作](./collection-operations.mdx) +- [リファレンス:コレクション定義](/weaviate/config-refs/collections.mdx) +- + API リファレンス:REST:エイリアス + + +## ご質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/collection-operations.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/collection-operations.mdx new file mode 100644 index 000000000..d27c97d22 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/collection-operations.mdx @@ -0,0 +1,734 @@ +--- +title: 基本的なコレクション操作 +sidebar_label: Collection operations (CRUD) +sidebar_position: 1 +image: og/docs/howto.jpg +--- + +import SkipLink from "/src/components/SkipValidationLink"; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.py"; +import PyCodeV3 from "!!raw-loader!/_includes/code/howto/manage-data.collections-v3.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.ts"; +import TSCodeLegacy from "!!raw-loader!/_includes/code/howto/manage-data.collections-v2.ts"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.classes.java"; +import JavaReplicationCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.replication.java'; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.classes_test.go"; + +Weaviate のすべてのオブジェクトは、必ず 1 つのコレクションに属します。ここに示す例を参考に、コレクションを管理してください。 + +:::note Terminology +新しい Weaviate のドキュメントでは「コレクション」と呼称しますが、古いドキュメントでは「クラス」と表記されています。両方の用語がドキュメント中に登場することがあります。 +::: + +import VectorConfigSyntax from "/_includes/vector-config-syntax.mdx"; + + + +## コレクションの作成 + +コレクションを作成するには、少なくともコレクション名を指定します。プロパティを指定しない場合、[`auto-schema`](../config-refs/collections.mdx#auto-schema) が自動でプロパティを作成します。 + +import InitialCaps from "/_includes/schemas/initial-capitalization.md"; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +:::tip Production ready collections + +- **データスキーマを手動で定義**: + [`auto-schema`](../config-refs/collections.mdx#auto-schema) 機能を使用せず、[コレクションのプロパティを手動で定義](#create-a-collection-and-define-properties)してください。 +- **コレクションを作り過ぎない**: + コレクションが多すぎると、メモリ使用量の増加やクエリ性能の低下など、スケーラビリティの問題が発生する可能性があります。代わりに、1 つのコレクションを複数のテナントに分割する [マルチテナンシー](/weaviate/manage-collections/multi-tenancy) の利用を検討してください。詳細は [スターターガイド: コレクションのスケーリング制限](/weaviate/starter-guides/managing-collections/collections-scaling-limits) を参照してください。 +::: + + + +## コレクションの作成とプロパティの定義 + +プロパティとは、コレクション内のデータフィールドです。各プロパティには名前とデータ型があります。 + +
+ + 追加情報 + + +プロパティを使用して、データ型、インデックス特性、トークナイゼーションなどの追加パラメーターを設定できます。 + +詳細は以下を参照してください。 + +- [リファレンス: 設定: スキーマ](/weaviate/config-refs/collections.mdx) +- + API リファレンス: REST: スキーマ + +- [利用可能なデータ型](../config-refs/datatypes.md) + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## ベクトライザー付きコレクションの作成 + +オブジェクトを作成したり ベクトル 検索クエリを実行したりする際に ベクトル 埋め込みを生成するため、コレクションに `vectorizer` を指定します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +:::info ベクトライザー設定 + +ベクトライザーおよび ベクトル インデックス設定の詳細は、[コレクションの管理: Vectorizer and vector index](./vector-config.mdx) をご覧ください。 + +::: + +## Auto-schema の無効化 + +デフォルトでは、Weaviate は存在しないコレクションやプロパティを自動で作成します。コレクションを手動で設定すると、設定をより細かく制御できます。 + +[`auto-schema`](../config-refs/collections.mdx#auto-schema) を無効化するには、システム設定ファイルで `AUTOSCHEMA_ENABLED: 'false'` を設定してください。 + +## コレクションが存在するかの確認 + +指定したコレクションが存在するかどうかを示す boolean 値を取得します。 + + + + + + + + + + +## 単一コレクション定義の取得 + +スキーマからコレクション定義を取得します。 + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ サンプル設定: Text objects + +この Text objects 向け設定では、以下を定義しています。 + +- コレクション名 ( `Article` ) +- ベクトライザー モジュール ( `text2vec-cohere` ) とモデル ( `embed-multilingual-v2.0` ) +- プロパティ セット ( `title` 、 `body` ) のデータ型は `text` + +```json +{ + "class": "Article", + "vectorizer": "text2vec-cohere", + "moduleConfig": { + "text2vec-cohere": { + "model": "embed-multilingual-v2.0" + } + }, + "properties": [ + { + "name": "title", + "dataType": ["text"] + }, + { + "name": "body", + "dataType": ["text"] + } + ] +} +``` + +
+ +
+ サンプル設定: Nested objects + +:::info `v1.22` で追加 +::: + +この Nested objects 向け設定では、以下を定義しています。 + +- コレクション名 ( `Person` ) +- ベクトライザー モジュール ( `text2vec-huggingface` ) +- プロパティ セット ( `last_name` 、 `address` ) + - `last_name` は `text` データ型 + - `address` は `object` データ型 +- `address` プロパティには 2 つのネストされたプロパティ ( `street` と `city` ) がある + +```json +{ + "class": "Person", + "vectorizer": "text2vec-huggingface", + "properties": [ + { + "dataType": ["text"], + "name": "last_name" + }, + { + "dataType": ["object"], + "name": "address", + "nestedProperties": [ + { "dataType": ["text"], "name": "street" }, + { "dataType": ["text"], "name": "city" } + ] + } + ] +} +``` + +
+ +
+ サンプル設定: Generative search + +この [検索拡張生成](../search/generative.md) 向け設定では、以下を定義しています。 + +- コレクション名 ( `Article` ) +- デフォルト ベクトライザー モジュール ( `text2vec-openai` ) +- 生成モジュール ( `generative-openai` ) +- プロパティ セット ( `title` 、 `chunk` 、 `chunk_no` 、 `url` ) +- `url` プロパティのトークナイズ オプション +- `url` プロパティの ベクトル 化オプション (skip ベクトル 化) + +```json +{ + "class": "Article", + "vectorizer": "text2vec-openai", + "vectorIndexConfig": { + "distance": "cosine" + }, + "moduleConfig": { + "generative-openai": {} + }, + "properties": [ + { + "name": "title", + "dataType": ["text"] + }, + { + "name": "chunk", + "dataType": ["text"] + }, + { + "name": "chunk_no", + "dataType": ["int"] + }, + { + "name": "url", + "dataType": ["text"], + "tokenization": "field", + "moduleConfig": { + "text2vec-openai": { + "skip": true + } + } + } + ] +} +``` + +
+ +
+ サンプル設定: Images + +この Image search 向け設定では、以下を定義しています。 + +- コレクション名 ( `Image` ) +- ベクトライザー モジュール ( `img2vec-neural` ) + - `image` プロパティで画像データを保存するようコレクションを設定 +- ベクトル インデックス距離指標 ( `cosine` ) +- プロパティ セット ( `image` ) で、 `image` プロパティを `blob` に設定 + +画像検索については、[Image search](../search/image.md) を参照してください。 + +```json +{ + "class": "Image", + "vectorizer": "img2vec-neural", + "vectorIndexConfig": { + "distance": "cosine" + }, + "moduleConfig": { + "img2vec-neural": { + "imageFields": ["image"] + } + }, + "properties": [ + { + "name": "image", + "dataType": ["blob"] + } + ] +} +``` + +
+ + + +## すべてのコレクション定義の読み取り + +データベースのスキーマを取得して、すべてのコレクション定義を取得します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## コレクション定義の更新 + +import RaftRFChangeWarning from "/_includes/1-25-replication-factor.mdx"; + + + +コレクション定義を更新して、[変更可能なコレクション設定](../config-refs/collections.mdx#mutability) を変更できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## コレクションの削除 + +import CautionSchemaDeleteClass from "/_includes/schema-delete-class.mdx"; + + + +## プロパティの追加 + +
+ + データインポート後のインデックス制限 + + +データをインポートする前にコレクションのプロパティを追加する場合、インデックスの制限はありません。

+ +新しいプロパティをデータ インポート後に追加すると、インデックスに影響があります。

+ +プロパティ インデックスはインポート時に構築されます。データをインポートした後に新しいプロパティを追加した場合、既存オブジェクトのインデックスは自動的に更新されず、新しいプロパティ インデックスに追加されません。つまり、インデックスには新しいオブジェクトしか含まれないため、クエリ結果が期待どおりにならない可能性があります。

+ +コレクション内のすべてのオブジェクトを含むインデックスを作成するには、次のいずれかを行ってください。 + +- 新規コレクション: オブジェクトをインポートする前に、コレクションのすべてのプロパティを追加します。 +- 既存コレクション: コレクションから既存データをエクスポートし、新しいプロパティを含めて再作成し、データを更新済みコレクションにインポートします。 + +現在、プロパティ追加後にデータを再インデックスできるようにする再インデックス API を開発中です。今後のリリースで利用可能になる予定です。 + +
+ +import CodeSchemaAddProperties from "/_includes/code/schema.things.properties.add.mdx"; + + + +## 転置インデックスパラメーターの設定 + +各コレクションでは、さまざまな [転置インデックスパラメーター](../config-refs/indexing/inverted-index.mdx#inverted-index-parameters) を設定できます。パラメーターにはコレクション レベルで設定するものと、プロパティ レベルで設定するものがあります。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 追加リソース + +- [コレクション管理: ベクトライザーとベクトルインデックス](./vector-config.mdx) +- [参照: コレクション定義](/weaviate/config-refs/collections.mdx) +- [コンセプト: データ構造](../concepts/data.md) +- + API リファレンス: REST: スキーマ + + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/cross-references.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/cross-references.mdx new file mode 100644 index 000000000..a058fa403 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/cross-references.mdx @@ -0,0 +1,631 @@ +--- +title: クロスリファレンス +sidebar_position: 7 +image: og/docs/howto.jpg +--- + +import CrossReferencePerformanceNote from '/_includes/cross-reference-performance-note.mdx'; + + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs-v3.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs.ts'; +import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.cross-refs.java'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.cross-refs_test.go'; +import SkipLink from '/src/components/SkipValidationLink' + + +クロスリファレンスを使用して、コレクション間に方向性のあるリレーションシップを確立します。 + +
+ + 追加情報 + + +注記: +- クロスリファレンスは、ソースまたはターゲットオブジェクトのオブジェクト ベクトルには影響しません。 +- マルチテナンシ コレクションでは、次のいずれかに対してクロスリファレンスを設定できます: + - マルチテナンシでないコレクション オブジェクト + - 同じテナントに属するマルチテナンシ コレクション オブジェクト + +
+ +## クロスリファレンス プロパティの定義 + +クロスリファレンスを追加する前に、その参照プロパティをコレクション定義に含めておきます。 + + + + + + + + + + + + + +## クロスリファレンス プロパティの追加 + +既存のコレクション定義にクロスリファレンス プロパティを追加することもできます。 + + + + + + + + + + + + + + + + + + +## クロスリファレンス付きオブジェクトの作成 + +オブジェクトを作成する際にクロスリファレンスを指定します。 + + + + + + + + + + + + + + + + + + + + + + +## 一方向クロスリファレンスの追加 + +ソースとターゲットの必須 id とプロパティを指定します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 双方向クロスリファレンスの追加 + +これは、両方向にリファレンスプロパティを追加し、オブジェクトペアごとに 2 つのクロスリファレンス( `from` A -> `to` B と `from` B -> `to` A)を追加する必要があります。 + +`JeopardyCategory` コレクションを作成します: + + + + + + + + + + + + + + + + + +`JeopardyQuestion` コレクションを作成し、 `JeopardyCategory` へのリファレンスプロパティを含めます: + + + + + + + + + + + + + + + + + +`JeopardyCategory` を修正し、 `JeopardyQuestion` へのリファレンスを追加します: + + + + + + + + + + + + + + + + + +そしてクロスリファレンスを追加します: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 複数 (一対多) のクロスリファレンスを追加 + +Weaviate では、1 つのソースオブジェクトから複数のクロスリファレンスを作成できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## クロスリファレンスの読み取り + +クロスリファレンスはオブジェクトの一部として読み取ることができます。 + + + + + + + + + + + + + + + +## クロスリファレンスの削除 + +クロスリファレンスを定義したときと同じパラメーターを使用してクロスリファレンスを削除します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + ターゲットオブジェクトが削除された場合はどうなりますか? + + +`to` オブジェクトが削除された場合はどうなりますか? +オブジェクトが削除されても、それへのクロスリファレンスはそのまま残ります。[インラインフラグメント構文を使用した Get クエリ](../search/basics.md#retrieve-cross-referenced-properties)は、既存のクロスリファレンスオブジェクトに含まれるフィールドのみを正しく取得しますが、[ID でオブジェクトを取得](../manage-objects/read.mdx#get-an-object-by-id)した場合は、参照先のオブジェクトが存在するかどうかに関係なく、すべてのクロスリファレンスが表示されます。 + +
+ +## クロスリファレンスの更新 + +クロスリファレンスのターゲットは更新できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 関連ページ + +- [Weaviate に接続](/weaviate/connections/index.mdx) +- リファレンス: REST - /v1/objects +- [クエリの一部としてクロスリファレンスを取得](../search/basics.md#retrieve-cross-referenced-properties) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/generative-reranker-models.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/generative-reranker-models.mdx new file mode 100644 index 000000000..f36a6dc57 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/generative-reranker-models.mdx @@ -0,0 +1,274 @@ +--- +title: 生成モデルとリランカー モデル +sidebar_position: 3 +image: og/docs/howto.jpg +--- + +import SkipLink from "/src/components/SkipValidationLink"; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.py"; +import PyCodeV3 from "!!raw-loader!/_includes/code/howto/manage-data.collections-v3.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.ts"; +import TSCodeLegacy from "!!raw-loader!/_includes/code/howto/manage-data.collections-v2.ts"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.classes.java"; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.classes_test.go"; + +:::tip Embedding models / Vectorizers + +コレクション用に埋め込みモデルを設定したり、ベクトル インデックス設定を微調整したりする方法については、[ベクトライザーとベクトル設定](./vector-config.mdx) ガイドをご覧ください。 + +::: + +## リランカー モデル インテグレーションの指定 + +[取得結果をリランキング](../search/rerank.md) するために、[`reranker`](../concepts/search/index.md#rerank) モデル インテグレーションを設定します。 + +:::info 関連ページ + +- [利用可能なリランカー モデル インテグレーション](../model-providers/index.md) + ::: + + + + + + + + + + + + + + + + + + + + + + + +## リランカー モデル インテグレーションの更新 + +:::info `v1.25.23` 、 `v1.26.8` 、および `v1.27.1` から利用可能 +`reranker` と `generative` の設定は `v1.25.23` 、 `v1.26.8` 、および `v1.27.1` から変更可能です。 +::: + +[取得結果をリランキング](../search/rerank.md) するために、[`reranker`](../concepts/search/index.md#rerank) モデル インテグレーションを更新します。 + + + + + + + + + + + + + + + + + + + + + + + + + +## 生成モデル統合の指定 + +コレクションに対して `generative` モデル統合を指定します (RAG 用)。 + +:::info 関連ページ + +- [利用可能な生成モデル統合](../model-providers/index.md) +::: + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 生成モデル統合の更新 + +:::info `v1.25.23`、`v1.26.8`、`v1.27.1` から利用可能 +`reranker` と `generative` の構成は `v1.25.23`、`v1.26.8`、`v1.27.1` から変更可能です。 +::: + +[`generative`](../concepts/search/index.md#retrieval-augmented-generation-rag) モデル統合を更新します。 + + + + + + + + + + + + + + + + + + + + + + + +import RuntimeGenerative from "/_includes/runtime-generative.mdx"; + + + +## 追加リソース + +- + API リファレンス: REST: スキーマ + +- [リファレンス: 設定: スキーマ](/weaviate/config-refs/collections.mdx) +- [概念: データ構造](../concepts/data.md) + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/active-tenants.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/active-tenants.jpg new file mode 100644 index 000000000..61c5da10a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/active-tenants.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/inactive-tenants.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/inactive-tenants.jpg new file mode 100644 index 000000000..f8dd3e4de Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/inactive-tenants.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/offloaded-tenants.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/offloaded-tenants.jpg new file mode 100644 index 000000000..5fdf66842 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/offloaded-tenants.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/storage-tiers.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/storage-tiers.jpg new file mode 100644 index 000000000..ee07908bb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/storage-tiers.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/weaviate-collections-simplified.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/weaviate-collections-simplified.png new file mode 100644 index 000000000..16d0d6fd3 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/img/weaviate-collections-simplified.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/index.mdx new file mode 100644 index 000000000..75ef25bbb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/index.mdx @@ -0,0 +1,159 @@ +--- +title: コレクションの管理 +sidebar_position: 0 +image: og/docs/howto.jpg +hide_table_of_contents: true +--- + +次のガイドでは、特定の Weaviate 機能に関する詳細な手順と概念を解説しています。基本的なコレクション操作、ベクトライザーの設定、モデルの統合、マルチテナンシーやマルチノード構成の実装、データ移行、クロスリファレンスの管理方法を学べます。 + +import CardsSection from "/src/components/CardsSection"; + +export const specificGuidesData = [ + { + title: "基本的なコレクション操作(CRUD)", + description: "コレクションを作成・参照・更新・削除する方法を学びます。", + link: "/weaviate/manage-collections/collection-operations", + icon: "fas fa-database", // Icon representing data management + }, + { + title: "ベクトライザーとベクトル設定", + description: + "ベクトライザー(埋め込みモデル)、ベクトルインデックスのパラメーター、および関連設定を構成します。", + link: "/weaviate/manage-collections/vector-config", + icon: "fas fa-project-diagram", // Icon representing vector relationships/structure + }, + { + title: "モデルプロバイダーの統合", + description: + "OpenAI、Hugging Face、Cohere など、さまざまなモデルプロバイダーと Weaviate を統合します。", + link: "/weaviate/manage-collections/generative-reranker-models", + icon: "fas fa-plug", // Icon representing integrations/plugins + }, + { + title: "マルチテナンシー", + description: + "1 つの Weaviate インスタンス内で異なるテナントのデータを分離します。", + link: "/weaviate/manage-collections/multi-tenancy", + icon: "fas fa-users", // Icon representing multiple users/tenants + }, + { + title: "マルチノード構成", + description: + "高可用性とスケーラビリティを実現するため、複数ノードにわたって Weaviate をセットアップ・構成します。", + link: "/weaviate/manage-collections/multi-node-setup", + icon: "fas fa-network-wired", // Icon representing clustering/networking + }, + { + title: "コレクションの移行", + description: + "データスキーマとオブジェクトを移行するための戦略と手順を学びます。", + link: "/weaviate/manage-collections/migrate", + icon: "fas fa-exchange-alt", // Icon representing migration/transfer + }, + { + title: "クロスリファレンス", + description: "オブジェクト間の関係を定義、管理、クエリします。", + link: "/weaviate/manage-collections/cross-references", + icon: "fas fa-link", // Icon representing links/relationships + }, +]; + +
+ +
+ +## コレクションの仕組み + +Weaviate のコレクションは、データ保存とベクトル検索を可能にする複数の主要コンポーネントと設定によって定義されます。 +主な要素は次のとおりです: + +import CollectionsSimplified from "/docs/weaviate/manage-collections/img/weaviate-collections-simplified.png"; +import Link from "@docusaurus/Link"; + +export const textColumnContent = ( +
    +
  • + オブジェクト: +
      +
    • + コレクションに保存される基本単位です。各オブジェクトはデータプロパティを持ち、その意味を表すベクトル埋め込みを含みます。(詳細は{" "} + + 'How-to: オブジェクト管理' ガイド + {" "} + をご覧ください)。 +
    • +
    +
  • +
  • + AI モデル統合: +
      +
    • + + + ベクトライザー(埋め込みモデル) + + + : オブジェクトのプロパティからベクトル埋め込みを生成し、セマンティック検索を可能にします。 +
    • +
    • + + + 生成モデル + + + : 取得したデータと生成 AI の機能を組み合わせて RAG(検索拡張生成)を実行するために使用します。 +
    • +
    • + + + リランカーモデル + + + : 検索クエリの初期結果を再順位付けして検索の関連度を高めます。 +
    • +
    +
  • +
  • + 設定項目:{" "} + {/* Changed heading from "Other settings" */} +
      +
    • + + + 転置インデックス + + + : キーワード検索を最適化し、テキスト オブジェクト プロパティをインデックス化して高速なルックアップを実現します。 +
    • +
    • + + + マルチテナンシー + + + : 同じコレクション インスタンス内で、複数の異なるテナント(ユーザーやグループ)のデータを安全に保存できるようにします。 +
    • +
    +
  • +
+); + + + {textColumnContent} + + + + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/migrate.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/migrate.mdx new file mode 100644 index 000000000..305c2140d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/migrate.mdx @@ -0,0 +1,400 @@ +--- +title: データ移行 +description: Weaviate 内でデータを移行し、データ操作を容易にする方法を学びます。 +sidebar_position: 6 +image: og/docs/howto.jpg +# tags: ['how-to', 'cursor'] +--- + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.migrate.data.v4.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.migrate.data.v3.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.migrate.data.ts'; + + +バックアップが利用できない場合に、手動でデータを移行するための例を示します。ここでは、以下のすべての組み合わせを扱います。 + +- シングルテナンシーのコレクション (Collection) +- マルチテナンシーのコレクション内のテナント (Tenant) + +
+ 追加情報 + + これらの例では、ポート番号の異なる 2 つの Weaviate インスタンスを使用しています。同じ手順は、別々のインスタンス間でも利用できます。 + + Weaviate におけるクロスリファレンスはプロパティです。そのため、オブジェクトの一部として [クロスリファレンスを取得](./cross-references.mdx#read-cross-references) できます。 + +
+ +
+ クロスリファレンスはどうなりますか? + +これらのスクリプトはクロスリファレンスも移行します。 +
+ +クロスリファレンスはプロパティであるため、カーソルベースのエクスポートに含まれます。 +リストア時には、参照先 (「to」オブジェクト) を先に復元し、その後でクロスリファレンスを含む (「from」オブジェクト) を復元してください。 + +
+ +## コレクション → コレクション + +#### Step 1: 送信先コレクションの作成 + +送信先インスタンスに、ソースインスタンスのコレクション (例: `WineReview`) と同じ名前のコレクションを作成します。 + + + + + + + + + + + + + +#### Step 2: データの移行 + +以下を移行します。 +- `client_src` インスタンス内の `source collection` のデータ +- `client_tgt` インスタンス内の `target collection` へ + + + + + + +

+ migrate_data_from_weaviate_to_weaviate 関数を呼び出してデータを移行します。 +

+

+ +
+ + + +
+ +## コレクション → テナント + +#### Step 1: 送信先コレクションの作成 + +送信先インスタンスに、ソースインスタンスのコレクション (例: `WineReview`) と同じ名前のコレクションを作成し、マルチテナンシーを有効にします。 + + + + + + + + + + + + + + + +#### Step 2: テナントの作成 + +データオブジェクトを追加する前に、ターゲットインスタンスにテナントを追加します。 + + + + + + + + + + + + + +#### Step 3: データの移行 + +以下を移行します: +- `client_src` インスタンス内の `source collection` データ +- `client_tgt` インスタンス内の `target collection` の `target tenant` データへ + + + + + + +

+ migrate_data_from_weaviate_to_weaviate 関数が呼び出され、データを移行します。 +

+

+ +
+ + + +
+ +## テナント → コレクション + +#### Step 1: ターゲットコレクションの作成 + +ターゲットインスタンスに、ソースインスタンスのコレクション (例: `WineReview`) と一致するコレクション (例: `WineReview`) を作成し、マルチテナンシーを有効にします。 + + + + + + + + + + + + + +#### Step 2: データの移行 + +以下を移行します: +- `client_src` インスタンス内の `source collection` の `source tenant` データ +- `client_tgt` インスタンス内の `target collection` へ + + + + + + +

+ migrate_data_from_weaviate_to_weaviate 関数が呼び出され、データを移行します。 +

+

+ +
+ + + +
+ + +## テナント → テナント + +#### ステップ 1: 対象コレクションを作成する + +対象インスタンスでコレクション (例: `WineReview`) を作成し、ソースインスタンスのコレクション (例: `WineReview`) と一致させ、マルチテナンシーを有効にします。 + + + + + + + + + + + + + + +#### ステップ 2: テナントを作成する + +データオブジェクトを追加する前に、対象インスタンスにテナントを追加します。 + + + + + + + + + + + + + +#### ステップ 3: データを移行する + +移行内容: +- `client_src` インスタンスの `source collection` にある `source tenant` のデータ +- を `client_tgt` インスタンスの `target collection` にある `target tenant` のデータへ + + + + + + +

+ migrate_data_from_weaviate_to_weaviate 関数が呼び出され、データを移行します。 +

+

+ +
+ + + +
+ +## 関連ページ + +- [Weaviate への接続](/weaviate/connections/index.mdx) +- [Cursor API](../manage-objects/read-all-objects.mdx) +- [マルチテナンシー操作](./multi-tenancy.mdx) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/multi-node-setup.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/multi-node-setup.mdx new file mode 100644 index 000000000..e2aaa4873 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/multi-node-setup.mdx @@ -0,0 +1,218 @@ +--- +title: マルチノード構成 +sidebar_position: 5 +image: og/docs/howto.jpg +--- + +import SkipLink from "/src/components/SkipValidationLink"; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.py"; +import PyCodeV3 from "!!raw-loader!/_includes/code/howto/manage-data.collections-v3.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.ts"; +import TSCodeLegacy from "!!raw-loader!/_includes/code/howto/manage-data.collections-v2.ts"; +import JavaReplicationCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.replication.java'; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.classes_test.go"; + +## レプリケーション設定 + +import RaftRFChangeWarning from "/_includes/1-25-replication-factor.mdx"; + + + +[非同期レプリケーション](/deploy/configuration/replication.md#async-replication-settings) や [削除解決戦略](../concepts/replication-architecture/consistency.md#deletion-resolution-strategies) などのレプリケーション設定を構成します。 + + + + + + + + + + + + + + + + + + + + + + + + +```bash +curl \ +-X POST \ +-H "Content-Type: application/json" \ +-d '{ + "class": "Article", + "properties": [ + { + "dataType": [ + "string" + ], + "description": "Title of the article", + "name": "title" + } + ], + "replicationConfig": { + "factor": 3, + "asyncEnabled": true, + "deletionStrategy": "TimeBasedResolution" + } +}' \ +http://localhost:8080/v1/schema +``` + + + + +
+ + 追加情報 + + +レプリケーションファクターを 1 より大きく設定するには、[マルチノード デプロイメント](/deploy/installation-guides/docker-installation.md#multi-node-configuration) を使用してください。 + +設定パラメーターの詳細については、次を参照してください: + +- [Replication](/weaviate/config-refs/collections.mdx#replication) + +
+ +## シャーディング設定 + +コレクションごとにシャーディングを構成します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 追加情報 + + +設定パラメーターの詳細については、次を参照してください: + +- [Sharding](/weaviate/config-refs/collections.mdx#sharding) + +
+ + + +## シャードの検査(コレクション) + +インデックス自体は複数のシャードで構成される場合があります。 + +import CodeSchemaShardsGet from "/_includes/code/howto/manage-data.shards.inspect.mdx"; + + + +## シャードステータスの更新 + +シャードのステータスは手動で更新できます。たとえば、他の変更を行った後で、シャードステータスを `READONLY` から `READY` に変更します。 + +import CodeSchemaShardsUpdate from "/_includes/code/howto/manage-data.shards.update.mdx"; + + + +## 追加リソース + +- API リファレンス: REST: スキーマ +- [リファレンス: 構成: スキーマ](/weaviate/config-refs/collections.mdx) +- [コンセプト: データ構造](../concepts/data.md) + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/multi-tenancy.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/multi-tenancy.mdx new file mode 100644 index 000000000..d75a43c31 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/multi-tenancy.mdx @@ -0,0 +1,665 @@ +--- +title: マルチテナンシーの操作 +sidebar_position: 4 +image: og/docs/configuration.jpg +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.py"; +import PyCodeV3 from "!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy-v3.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.ts"; +import TSCodeLegacy from "!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy-v2.ts"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.multi-tenancy.java"; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.multi-tenancy_test.go"; +import GoCodeAuto from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.create_auto-multitenancy.go"; +import CurlCode from "!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy-curl.sh"; +import SkipLink from "/src/components/SkipValidationLink"; + +マルチテナンシーはデータの分離を提供します。各テナントは個別のシャードに保存され、あるテナントに保存されたデータは他のテナントからは見えません。アプリケーションが多数のユーザーにサービスを提供する場合、マルチテナンシーによりユーザーデータを非公開に保ち、データベース操作を効率化できます。 + +
+ + マルチテナンシーの対応状況 + + +- `v1.20` でマルチテナンシーを追加 +- `v1.21` でテナントのアクティビティステータス設定を追加 +- `v1.25.0` でバッチインポート時の自動テナント作成を追加 +- `v1.25.2` で単一オブジェクト挿入時の自動テナント作成を追加 +- `v1.25.2` で自動テナントアクティベーションを追加 + +
+ +:::info `v1.26` でテナントステータスの名称変更 +`v1.26` では、`HOT` ステータスは `ACTIVE` に、`COLD` ステータスは `INACTIVE` に変更されました。 +::: + +## マルチテナンシーの有効化 + +デフォルトでは マルチテナンシー は無効です。マルチテナンシーを有効にするには、コレクション定義で `multiTenancyConfig` を設定します。 + + + + + + + + + + + + + + + + + + + + + + +## 新しいテナントを自動追加 + +import AutoTenant from "/_includes/auto-tenant.mdx"; + + + +### コレクションの作成 + + + + + + + + + + + + + + + + + + +### コレクションの更新 + +クライアントを使用して auto-tenant 作成設定を更新します。auto-tenant はバッチ挿入でのみ利用できます。 + + + + + + + + + + + + + +## 新しいテナントの手動追加 + +コレクションにテナントを追加するには、対象のコレクションと新しいテナントを指定します。必要に応じて、テナントのアクティブ状態を `ACTIVE`(利用可能、デフォルト)、`INACTIVE`(利用不可、ディスク上)、または `OFFLOADED`(利用不可、[クラウドへオフロード](../concepts/data.md#tenant-states))として指定できます。 + +以下の例では、`MultiTenancyCollection` コレクションに `tenantA` を追加しています。 + +
+ + 追加情報 + + +import TenantNameFormat from "/_includes/tenant-names.mdx"; + +テナントステータスは Weaviate `1.21` 以降で利用可能です。 + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +## テナントの一覧 + +既存のテナントをコレクション内で一覧表示します。 + +この例では、`MultiTenancyCollection` コレクションに含まれるテナントを一覧表示します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 名前でのテナント取得 + +コレクションから名前を指定してテナントを取得します。存在しないテナント名はレスポンスで無視される点に注意してください。 + +次の例では、`MultiTenancyCollection` コレクションから `tenantA` と `tenantB` を返します: + + + + + + + + + + + + +## 単一テナントの取得 + +コレクションから特定のテナントを取得します。 + +次の例では、`MultiTenancyCollection` コレクションからテナントを返します: + + + + + + + + + + + + +## テナントの削除 + +テナントをコレクションから削除するには、コレクション(例: `MultiTenancyCollection`)とテナント(`tenantB` と `tenantX`)を指定します。指定されたテナントがコレクションに含まれていない場合、その名前は無視されます。 + +:::caution テナント削除 = テナント データ削除 +テナントを削除すると、関連するすべてのオブジェクトも削除されます。 +::: + + + + + + + + + + + + + + + + + + + + + + + + + + + +## テナント状態の管理 + +`ACTIVE`、`INACTIVE`、`OFFLOADED` の間でテナントの状態を変更します。 + + + + + + + + + + + +:::info 詳細はこちら + +より実践的な例については [ハウツー: テナント状態を管理する](./tenant-states.mdx) を参照してください。また、**ホット**、**ウォーム**、**コールド** の各ストレージ階層を管理する方法については、[ガイド: リソースの管理](../starter-guides/managing-resources/index.md) もご覧ください。 + +::: + +## CRUD 操作 + +マルチテナンシーコレクションでは、各 CRUD 操作にテナント名(例:`tenantA`)を指定する必要があります。以下のオブジェクト作成例をご覧ください。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 検索クエリ + +マルチテナンシーコレクションでは、`Get` および `Aggregate` クエリを実行するたびにテナント名(例:`tenantA`)を指定する必要があります。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## クロスリファレンス + +import CrossReferencePerformanceNote from "/_includes/cross-reference-performance-note.mdx"; + + + +マルチテナンシー コレクション オブジェクトから、次のいずれかにクロスリファレンスを追加できます: + +- 非マルチテナンシー コレクション オブジェクト +- 同じテナントに属するオブジェクト + +クロスリファレンスを作成、更新、削除する際、マルチテナンシー コレクションではテナント名(例: `tenantA`)が必須です。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## バックアップ + +:::caution 非アクティブまたはオフロード済みテナントはバックアップに含まれません +[マルチテナント コレクション](../concepts/data.md#multi-tenancy)のバックアップには `active` テナントのみが含まれ、`inactive` や `offloaded` テナントは含まれません。すべてのデータをバックアップに含めるために、バックアップ作成前に [テナントをアクティブにする](#manage-tenant-states) ことを推奨します。 +::: + +## 関連ページ + +- [Weaviate への接続](/weaviate/connections/index.mdx) +- [How to: コレクションを管理する](../manage-collections/index.mdx) +- 参照: REST API: スキーマ +- [概念: データ構造: マルチテナンシー](../concepts/data.md#multi-tenancy) + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/tenant-states.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/tenant-states.mdx new file mode 100644 index 000000000..76d47a81d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/tenant-states.mdx @@ -0,0 +1,214 @@ +--- +title: テナント状態と温度の管理 +description: Weaviate でテナント状態を管理し、マルチテナンシーと安全なデータ分離を実現します。 +sidebar_position: 61 +image: og/docs/configuration.jpg +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.multi-tenancy.ts'; + +![Storage Tiers](./img/storage-tiers.jpg) + +ストレージ リソースはティアにグループ化されます。各ティアは異なるパフォーマンス特性とコストを持ちます。 + +| Tier | Location | Speed | Cost | +| :- | :- | :- | :- | +| Hot | RAM | 最速アクセス | 最も高価 | +| Warm | Disk | 中速 | 中価格 | +| Cold | Cloud Storage | 最も遅いアクセス | 最も安価 | + +Hot ティアと Cold ティアの価格差は大きく、クラウドストレージは RAM よりも桁違いに安価です。 + +マルチテナント コレクションでは、テナント状態( `Active` 、 `Inactive` 、 `Offloaded` )を変更してデータを異なるストレージ ティア間で移動できます。これにより、コスト、リソース可用性、即時利用性の間で細かなトレードオフが可能になります。 + +
+ ベクトル インデックスのリソース温度を管理 + +ベクトル インデックスの種類により、デフォルトのリソース種類が決まります。 + +* [`HNSW` index (default)](/academy/py/vector_index/hnsw) - ベクトル インデックスを RAM 上に保持する **Hot** リソースを使用します。 +* [`Flat` index](/academy/py/vector_index/flat) - ベクトル インデックスをディスク上に保持する **Warm** リソースを使用します。 +* [`Dynamic` index](/academy/py/vector_index/dynamic) - 初期状態では flat インデックス( **Warm** リソース)として開始し、設定された閾値を超えると HNSW インデックス( **Hot** リソース)へ切り替わります。 + +
+ +## Tenant States 概要 + +テナント状態には `Active` 、 `Inactive` 、 `Offloaded` の 3 種類があります。 + +| Tenant state | CRUD & Queries | Vector Index | Inverted Index | Object Data | Time to Activate | Description | +|------------------|----------------|--------------|----------------|-------------|------------------|------------| +| Active (default) | **Yes** | Hot/Warm | Warm | Warm | None | テナントは利用可能です | +| Inactive | **No** | Warm | Warm | Warm | Fast | テナントはローカルに保持されていますが利用できません | +| Offloaded | **No** | Cold | Cold | Cold | Slow | テナントはクラウドストレージに保持され、利用できません | + +:::tip Tenant state and consistency +テナント状態は最終的に整合性が取られます。 [詳細はこちら](/weaviate/concepts/replication-architecture/consistency#tenant-states-and-data-objects) +::: + +### Active + +`Active` テナントはクエリおよび CRUD 操作が可能です。 [ベクトル インデックスの種類](/weaviate/starter-guides/managing-resources#vector-index-types) に応じて **Hot** または **Warm** リソースを使用します。 + +テナントのオブジェクトデータと転置インデックスはディスク上に保存され、 `Warm` リソースを使用します。 + +Active Tenant resources + +### Inactive + +`Inactive` テナントはクエリおよび CRUD 操作ができません。 + +テナントのオブジェクトデータ、ベクトル インデックス、転置インデックスはディスク上に保存され、 `Warm` リソースを使用します。これは **Hot** リソースを使用する Active テナントと比較して Weaviate のメモリ要件を下げる効果があります。 + +テナントがローカルにあるため、Inactive テナントは迅速にアクティブ化できます。 + +Inactive Tenant resources + +### Offloaded + +import OffloadingLimitation from '/_includes/offloading-limitation.mdx'; + + + +`Offloaded` テナントはクエリおよび CRUD 操作ができません。 + +テナントのオブジェクトデータ、ベクトル インデックス、転置インデックスはクラウド上に保存され、 `Cold` リソースを使用します。テナントがリモートにあるため、Offloaded テナントをアクティブ化する際には遅延が発生します。 + +Offloaded Tenant resources + +## テナントをアクティブ化 + +ディスク上の `INACTIVE` テナントをアクティブ化する、またはクラウドから `OFFLOADED` テナントをオンロードしてアクティブ化するには、次を呼び出します。 + + + + + + + + + + + +## テナントを非アクティブ化 + +:::info v1.21.0 で追加 +::: + +`ACTIVE` テナントを非アクティブ化する、または `OFFLOADED` テナントをクラウドからオンロード(アクティブ化せずにローカルへ配置)するには、次を呼び出します。 + + + + + + + + + + + + + +## テナントのオフロード + +:::info Added in v1.26.0 +::: + +`ACTIVE` または `INACTIVE` のテナントをクラウドにオフロードするには、次を呼び出します: + + + + + + + + + + + +:::caution Offload モジュールが必要 +テナントのオフロードには Offload モジュールが必要です。 + +テナントオフロードを有効にする方法は、[modules ページ](../configuration/modules.md#tenant-offload-modules) をご覧ください +::: + +## テナントの自動アクティベート + +:::info Added in `v1.25.2` +::: + +検索、読み取り、更新、削除操作が実行された際に、`INACTIVE` または `OFFLOADED` のテナントを自動的にアクティブ化するには、次を有効にします。 + + + + + + + + + + + + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/vector-config.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/vector-config.mdx new file mode 100644 index 000000000..d5397154e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-collections/vector-config.mdx @@ -0,0 +1,599 @@ +--- +title: ベクトライザー と ベクトル インデックス の設定 +sidebar_label: Vectorizer and vector index +sidebar_position: 2 +image: og/docs/howto.jpg +--- + +import SkipLink from "/src/components/SkipValidationLink"; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import FilteredTextBlock from "@site/src/components/Documentation/FilteredTextBlock"; +import PyCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.py"; +import PyCodeV3 from "!!raw-loader!/_includes/code/howto/manage-data.collections-v3.py"; +import TSCode from "!!raw-loader!/_includes/code/howto/manage-data.collections.ts"; +import TSCodeLegacy from "!!raw-loader!/_includes/code/howto/manage-data.collections-v2.ts"; +import JavaCode from "!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.classes.java"; +import GoCode from "!!raw-loader!/_includes/code/howto/go/docs/manage-data.classes_test.go"; + +import VectorConfigSyntax from "/_includes/vector-config-syntax.mdx"; + + + +## ベクトライザーを指定する + +コレクションに対して `vectorizer` を指定します。 + +
+ 追加情報 + +コレクションレベルの設定は、デフォルト値および [環境変数](/deploy/configuration/env-vars/index.md) などの一般的な設定パラメーターよりも優先されます。 + +- [利用可能なモデル統合](../model-providers/index.md) +- [ベクトライザー設定リファレンス](/weaviate/config-refs/collections.mdx#vector-configuration) + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +## ベクトライザーの設定を指定する + +import VectorsAutoSchemaError from "/_includes/error-note-vectors-autoschema.mdx"; + + + +特定のコレクションでベクトライザーの動作(使用するモデルなど)を設定するには、ベクトライザーのパラメーターを指定します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 名前付き ベクトルの定義 + +:::info `v1.24` で追加 +::: + +各コレクションに複数の [名前付き ベクトル](../concepts/data.md#multiple-vector-embeddings-named-vectors) を定義できます。これにより、各オブジェクトを複数のベクトル埋め込みで表現でき、それぞれに独自のベクトル インデックスを持たせることが可能です。 + +そのため、各名前付き ベクトルの設定では、個別のベクトライザーとベクトル インデックス設定を指定できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 新しい名前付き ベクトルの追加 + +:::info `v1.31` で追加 +::: + +名前付き ベクトルは、すでに名前付き ベクトルを含むコレクション定義に追加できます。(名前付き ベクトルを持たないコレクションには追加できません。) + + + + + + + + + + +```java +// Java support coming soon +``` + + + + +```go +// Go support coming soon +``` + + + + +:::caution オブジェクトは自動的に再ベクトル化されません +コレクション定義に新しい名前付き ベクトルを追加しても、既存オブジェクトのベクトル化は実行されません。新規または更新済みのオブジェクトのみが、追加された名前付き ベクトル定義に対する埋め込みを取得します。 +::: + +## マルチ ベクトル埋め込みの定義 (例: ColBERT, ColPali) + +:::info `v1.29`, `v1.30` で追加 +::: + +マルチ ベクトル埋め込み(マルチ ベクトルとも呼ばれます)は、1 つのオブジェクトを複数のベクトル、つまり 2 次元行列で表現します。現在、マルチ ベクトルは名前付き ベクトル用の HNSW インデックスでのみ利用できます。マルチ ベクトルを使用するには、該当する名前付き ベクトルで有効化してください。 + + + + + + + + + + + + + +:::tip ベクトルを圧縮するために量子化とエンコーディングを使用する +マルチ ベクトル埋め込みは単一 ベクトル埋め込みよりも多くのメモリを消費します。[ベクトル量子化](../configuration/compression/index.md) と [エンコーディング](../configuration/compression/multi-vectors.md#muvera-encoding) を使用して圧縮し、メモリ使用量を削減できます。 +::: + + + +## ベクトル インデックス タイプの設定 + +ベクトル インデックス タイプは、コレクション作成時に `hnsw`、`flat`、`dynamic` から選択して設定できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Additional information + +- インデックス タイプと圧縮の詳細については、[概念: ベクトル インデックス](../concepts/indexing/vector-index.md) を参照してください。 + +
+ +## ベクトル インデックス パラメーターの設定 + +[圧縮](../configuration/compression/index.md) や [フィルター ストラテジ](../concepts/filtering.md#filter-strategy) などのベクトル インデックス パラメーターは、コレクション設定を通じて指定できます。いくつかのパラメーターは、コレクション作成後に[更新](collection-operations.mdx#update-a-collection-definition)することも可能です。 + +:::info Filter strategy parameter +Was added in `v1.27` +::: + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Additional information + +- インデックス タイプと圧縮の詳細については、[概念: ベクトル インデックス](../concepts/indexing/vector-index.md) を参照してください。 + +
+ + + +## プロパティレベルの設定 + +コレクション内の個々のプロパティを設定します。各プロパティは独自の設定を持つことができます。一般的な設定例を次に示します。 + +- プロパティをベクトル化する +- プロパティ名をベクトル化する +- [トークナイゼーションタイプ](../config-refs/collections.mdx#tokenization) を設定する + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 距離メトリックの指定 + +独自にベクトルを用意する場合は、`distance metric` を指定する必要があります。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 追加情報 + + +設定パラメーターの詳細については、次を参照してください。 + +- [距離](../config-refs/distances.md) +- [ベクトルインデックス](../config-refs/indexing/vector-index.mdx) + +
+ + +## 追加リソース + +- API リファレンス: REST: スキーマ +- [リファレンス: 設定: スキーマ](/weaviate/config-refs/collections.mdx) +- [コンセプト: データ構造](../concepts/data.md) + +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/create.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/create.mdx new file mode 100644 index 000000000..11b9a6001 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/create.mdx @@ -0,0 +1,490 @@ +--- +title: オブジェクトの作成 +sidebar_position: 10 +image: og/docs/howto.jpg +--- + +import SkipLink from '/src/components/SkipValidationLink' +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.create.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.create-v3.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.create.ts'; +import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.create-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.create.java'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.create_test.go'; + + +このページの例では、Weaviate で個々のオブジェクトを作成する方法を示します。 + +:::tip 複数オブジェクトにはバッチインポートを使用 +複数のオブジェクトをまとめて作成する場合は、[How-to: Batch Import](./import.mdx) を参照してください。 +::: + +## オブジェクトの作成 + +この例では、`JeopardyQuestion` コレクションにオブジェクトを作成します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 追加情報 + + +オブジェクトを作成するには、次の項目を指定します: + +- 追加したいオブジェクトデータ +- 対象のコレクション +- [マルチテナンシー](../concepts/data.md#multi-tenancy) が有効な場合は、[テナントを指定]( ../manage-collections/multi-tenancy.mdx) します + +デフォルトでは、[auto-schema](/weaviate/config-refs/collections.mdx#auto-schema) により、新しいコレクションの作成とプロパティの追加が行われます。 + +
+ +## 指定ベクトル付きオブジェクトの作成 + +オブジェクトを作成する際に、 ベクトル を指定できます。(複数の名前付き ベクトル を指定する方法については[下記](#create-an-object-with-named-vectors)を参照してください。) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 名前付き ベクトル を使用したオブジェクト作成 + +:::info `v1.24` で追加 +::: + +オブジェクトを作成する際、([コレクションで設定されている場合](../manage-collections/vector-config.mdx#define-named-vectors))名前付き ベクトル を指定できます。 + + + + + + + + + + + + + + + + + + + +## 指定した ID でオブジェクトを作成 + +オブジェクトを作成する際、[ID](../api/graphql/additional-properties.md#id) を指定できます。 + +:::info +ID を指定しない場合、Weaviate はランダムな [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier) を生成します。 +::: + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 決定論的 ID の生成 + +データオブジェクトに基づいて ID を生成できます。 + +:::info +オブジェクト ID はランダムに生成されません。同じ値からは常に同じ ID が生成されます。
重複した ID を指定すると Weaviate はエラーを返します。重複オブジェクトの挿入を避けるために、決定論的 ID を使用してください。 +::: + + + + + + + + + + + + + + + + + + + + +```java +// This feature is under development +``` + + + + + +```go +// This feature is under development +``` + + + + + +
+ + 追加情報 + +決定論的 ID を生成するには、次のメソッドを使用してください: + +- `generate_uuid5` (Python) +- `generateUuid5` (TypeScript) + +
+ + +## クロスリファレンス付きオブジェクトの作成 + +import CrossReferencePerformanceNote from '/_includes/cross-reference-performance-note.mdx'; + + + +import XrefPyCode from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs.py'; +import XrefPyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs-v3.py'; +import XrefTSCode from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs'; +import XrefTSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.cross-refs-v2'; + +他のオブジェクトへのクロスリファレンスを含むオブジェクトを作成できます。 + + + + + + + + + + + + + + + + + + + +:::tip Additional information +クロスリファレンスの詳細については、[How-to: Cross-references](../manage-collections/cross-references.mdx) を参照してください。 +::: + +## `geoCoordinates`付きオブジェクトの作成 + +import GeoLimitations from '/_includes/geo-limitations.mdx'; + + + +[`geoCoordinates`](/weaviate/config-refs/datatypes.md#geocoordinates) プロパティを指定する場合、`latitude` と `longitude` を浮動小数点の 10 進度で指定する必要があります。 + +import CreateWithGeo from '/_includes/code/howto/manage-data.create.with.geo.mdx'; + + + +## 作成前のオブジェクト検証 + +オブジェクトを作成する前に、コレクション定義に対して validate できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 複数ベクトル埋め込み(名前付きベクトル) + +import MultiVectorSupport from '/_includes/multi-vector-support.mdx'; + + + +## 関連ページ + +- [Weaviate への接続](/weaviate/connections/index.mdx) +- [方法: ( Batch ) アイテムをインポート](./import.mdx) +- 参照: REST - /v1/objects + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/delete.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/delete.mdx new file mode 100644 index 000000000..e5eed79bb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/delete.mdx @@ -0,0 +1,476 @@ +--- +title: オブジェクトの削除 +sidebar_position: 35 +image: og/docs/howto.jpg +--- + + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.delete.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.delete-v3.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.delete.ts'; +import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.delete-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.delete.java'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.delete_test.go'; +import SkipLink from '/src/components/SkipValidationLink' + + +Weaviate では、オブジェクトを ID または条件のセットで削除できます。 + + +import RestObjectsCRUDClassnameNote from '/_includes/rest-objects-crud-classname-note.md'; + +
+ 追加情報 + + - オブジェクトを削除するには、コレクション名と識別条件(例: オブジェクト ID やフィルター)を指定する必要があります。 + - [マルチテナンシー](../concepts/data.md#multi-tenancy) コレクションの場合、オブジェクトを削除する際にテナント名も指定する必要があります。方法の詳細については、[データ管理: マルチテナンシー操作]( ../manage-collections/multi-tenancy.mdx) を参照してください。 +
+ + + +
+ + +## ID でのオブジェクト削除 + +ID で削除するには、コレクション名とオブジェクト ID を指定します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 複数オブジェクトの削除 + +特定の条件に一致するオブジェクトを削除するには、コレクションと [`where` フィルター](../search/similarity.md) を指定します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 追加情報 + +- 1 回のクエリで削除できるオブジェクト数には、設定可能な最大値 ([QUERY_MAXIMUM_RESULTS](/deploy/configuration/env-vars/index.md#general)) があり、デフォルトでは 10,000 件です。上限を超えて削除する場合は、クエリを再実行してください。 + +
+ + +### ContainsAny / ContainsAll + +特定の条件でオブジェクトを削除する際には、`ContainsAny` / `ContainsAll` フィルターを使用します。 + + + + + + + + + + + + + + + + +```js +await client.batch + .objectsBatchDeleter() + .withClassName('EphemeralObject') + .withWhere({ + path: ['name'], + // highlight-start + operator: 'ContainsAny', + valueTextArray: ['asia', 'europe'], // Note the array syntax + // highlight-end + }) + // highlight-end + .do(); +``` + + + + + +```java +client.batch().objectsBatchDeleter() + .withClassName("EphemeralObject") + .withWhere(WhereFilter.builder() + .path("name") + // highlight-start + .operator(Operator.ContainsAny) + .valueText("asia", "europe") // Note the array syntax + // highlight-end + .build()) + .run(); +``` + + + + +```go + response, err := client.Batch().ObjectsBatchDeleter(). + WithClassName("EphemeralObject"). + WithOutput("minimal"). + WithWhere(filters.Where(). + WithPath([]string{"name"}). + // highlight-start + WithOperator(filters.ContainsAny). + WithValueText("asia", "europe")). // Note the array syntax + // highlight-end + Do(ctx) +``` + + + + +
+ 追加情報 + +この機能は Weaviate `v1.21` で追加されました。 + +
+ +## id で複数オブジェクトの削除 + +複数のオブジェクトをその id 値で削除するには、`id` ベースの条件を持つフィルター(例: `ContainsAny`)を使用します。 + +
+ 制限事項 + +1 回のクエリで削除できるオブジェクト数には上限(`QUERY_MAXIMUM_RESULTS`)があります。これは、予期しないメモリ急増やクライアント側のタイムアウト、ネットワーク中断が発生しやすい長時間実行リクエストから保護するためです。 + +オブジェクトは取得される場合と同じ順序、つまり UUID の順序で削除されます。上限を超える数を削除したい場合は、オブジェクトが一致しなくなるまで同じクエリを複数回実行してください。 + +既定の `QUERY_MAXIMUM_RESULTS` 値は 10,000 です。この値は、たとえば [環境変数](/deploy/configuration/env-vars/index.md) で変更可能です。 + +
+ + + + + + + + + + + + + + + + +```js +await client.batch + .objectsBatchDeleter() + .withClassName('EphemeralObject') + .withWhere({ + path: ['id'], + // highlight-start + operator: 'ContainsAny', + valueTextArray: ['12c88739-7a4e-49fd-bf53-d6a829ba0261', '3022b8be-a6dd-4ef4-b213-821f65cee53b', '30de68c1-dd53-4bed-86ea-915f34faea63'], // Note the array syntax + // highlight-end + }) + // highlight-end + .do(); +``` + + + + + +```java +client.batch().objectsBatchDeleter() + .withClassName("EphemeralObject") + .withWhere(WhereFilter.builder() + .path("id") + // highlight-start + .operator(Operator.ContainsAny) + .valueText("12c88739-7a4e-49fd-bf53-d6a829ba0261", "3022b8be-a6dd-4ef4-b213-821f65cee53b", "30de68c1-dd53-4bed-86ea-915f34faea63") // Note the array syntax + // highlight-end + .build()) + .run(); +``` + + + + +```go + response, err := client.Batch().ObjectsBatchDeleter(). + WithClassName("EphemeralObject"). + WithOutput("minimal"). + WithWhere(filters.Where(). + WithPath([]string{"id"}). + // highlight-start + WithOperator(filters.ContainsAny). + WithValueText("12c88739-7a4e-49fd-bf53-d6a829ba0261", "3022b8be-a6dd-4ef4-b213-821f65cee53b", "30de68c1-dd53-4bed-86ea-915f34faea63")). // Note the array syntax + // highlight-end + Do(ctx) +``` + + + + +## すべてのオブジェクトの削除 + +オブジェクトは Weaviate 内のコレクションに属している必要があります。そのため、[コレクションを削除](../manage-collections/collection-operations.mdx#delete-a-collection)すると、そこに含まれるすべてのオブジェクトも削除されます。 + +## 追加パラメーター + +- `dryRun` を使用すると、実際に削除を行わずに何件のオブジェクトが削除対象になるかを確認できます。 +- `output` に `'verbose'` を設定すると、各削除について詳細( ID と削除ステータス)を確認できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ レスポンス例 + +以下のようなレスポンスが返されます: + + + +
+ + + + + +## 関連ページ + +- [Weaviate に接続する](/weaviate/connections/index.mdx) +- リファレンス: REST - /v1/objects + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/import.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/import.mdx new file mode 100644 index 000000000..c26bef87a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/import.mdx @@ -0,0 +1,558 @@ +--- +title: バッチインポート +sidebar_position: 15 +image: og/docs/howto.jpg +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.import.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.import-v3.py'; +import PySuppCode from '!!raw-loader!/_includes/code/howto/sample-data.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.import.ts'; +import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.import-v2.ts'; +import TsSuppCode from '!!raw-loader!/_includes/code/howto/sample-data.ts'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.import.java'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.import_test.go'; +import SkipLink from '/src/components/SkipValidationLink' + +[バッチ インポート](../tutorials/import.md#to-batch-or-not-to-batch)は、複数のデータオブジェクトとクロス リファレンスを効率的に追加する方法です。 + +
+ 追加情報 + +バルクインポートジョブを作成するには、次の手順に従います。 + +1. バッチオブジェクトを初期化します。 +1. バッチオブジェクトに項目を追加します。 +1. 最後のバッチが送信(フラッシュ)されることを確認します。 + +
+ +## 基本インポート + +次の例では、`MyCollection` コレクションにオブジェクトを追加します。 + + + + + +### エラー処理 + +バッチ インポート中に失敗したオブジェクトやリファレンスは保存され、`batch.failed_objects` と `batch.failed_references` から取得できます。 +さらに、失敗したオブジェクトとリファレンスの累計は、コンテキストマネージャ内で `batch.number_errors` から取得できます。 +このカウンターを利用して、失敗したオブジェクトやリファレンスを調査するためにインポート処理を停止できます。 + +Python クライアントのエラー処理についての詳細は、[リファレンスページ](/weaviate/client-libraries/python)をご覧ください。 + + + + + + + + + + + + + + + + + + + + + + + + +## gRPC API の使用 + +:::info `v1.23` で追加されました。 +::: + +[gRPC API](../api/index.mdx) は REST API より高速です。インポート速度を向上させるために gRPC API をご利用ください。 + + + + +Python クライアントはデフォルトで gRPC を使用します。 + +
レガシー Python クライアントは gRPC をサポートしていません。 + +
+ + +TypeScript クライアント v3 はデフォルトで gRPC を使用します。 + +
レガシー TypeScript クライアントは gRPC をサポートしていません。 + +
+ + +Java クライアントで gRPC API を使用するには、クライアント接続コードに `setGRPCHost` フィールドを追加してください。暗号化接続を使用する場合は `setGRPCSecured` を更新します。

+ +```java +Config config = new Config("http", "localhost:8080"); +config.setGRPCSecured(false); +config.setGRPCHost("localhost:50051"); +``` +
+ + +Go クライアントで gRPC API を使用するには、クライアント接続コードに `GrpcConfig` フィールドを追加してください。暗号化接続を使用する場合は `Secured` を更新します。

+ +```java +cfg := weaviate.Config{ + Host: fmt.Sprintf("localhost:%v", "8080"), + Scheme: "http", + // highlight-start + GrpcConfig: &grpc.Config{ + Host: "localhost:50051", + Secured: false, + }, + // highlight-end +} + +client, err := weaviate.NewClient(cfg) +if err != nil { + require.Nil(t, err) + } +``` +
+ + +[Spark コネクター](https://github.com/weaviate/spark-connector) で gRPC API を使用するには、クライアント接続コードに `grpc:host` フィールドを追加してください。暗号化接続を使用する場合は `grpc:secured` を更新します。

+ +```java + df.write + .format("io.weaviate.spark.Weaviate") + .option("scheme", "http") + .option("host", "localhost:8080") + // highlight-start + .option("grpc:host", "localhost:50051") + .option("grpc:secured", "false") + // highlight-start + .option("className", className) + .mode("append") + .save() +``` + +
+
+ + + +## ID 値の指定 + +Weaviate は各オブジェクトに対して UUID を生成します。オブジェクト ID は一意である必要があります。オブジェクト ID を自分で設定する場合は、重複 ID を防ぐために次の決定論的 UUID メソッドのいずれかを使用してください: + +- `generate_uuid5` (Python) +- `generateUuid5` (TypeScript) + + + + + + + + + + + + + + + + + + + + + + + + + + + +## ベクトルの指定 + +`vector` プロパティを使用して、各オブジェクトにベクトルを指定します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 名前付き ベクトル の指定 + +:::info `v1.24` で追加 +::: + +オブジェクトを作成する際、([コレクションで設定されている場合](../manage-collections/vector-config.mdx#define-named-vectors))名前付き ベクトル を指定できます。 + + + + + + + + + + + + + + + + + + + + +## 参照付きインポート + +クロスリファレンスを介して、あるオブジェクトから別のオブジェクトへリンクをまとめて作成できます。 + + + + + + + + + + + + + +## Python 固有の考慮事項 + +Python クライアントには、インポート速度を最適化するための組み込みバッチ処理メソッドがあります。詳細はクライアントドキュメントをご覧ください。 + + +- [Python クライアント `v4`](../client-libraries/python/index.mdx) + +### 非同期 Python クライアントとバッチ処理 + +現在、[非同期 Python クライアントはバッチ処理をサポートしていません](../client-libraries/python/async.md#bulk-data-insertion)。バッチ処理を使用する場合は、同期 Python クライアントをご利用ください。 + +## 大きなファイルからのストリーミング処理 + +データセットが大きい場合、メモリ不足を避けるためにインポートをストリーミングすることを検討してください。 + +サンプルコードを試すには、サンプルデータをダウンロードし、サンプル入力ファイルを作成します。 + +
+ サンプルデータを取得する + + + + + + + + + + +
+ +
+ JSON ファイルをストリーミングするサンプルコード + + + + + + + + + + + + + +
+ + +
+ CSV ファイルをストリーミングするサンプルコード + + + + + + + + + + + + + +
+ + + +## バッチ ベクトル化 + +:::info `v1.25` で追加されました。 +::: + +import BatchVectorizationOverview from '/_includes/code/client-libraries/batch-import.mdx'; + + + +## モデルプロバイダーの設定 + +各モデルプロバイダーごとに、1 分あたりのリクエスト数や 1 分あたりのトークン数など、バッチ ベクトル化の設定を行えます。以下の例では、 Cohere と OpenAI の統合に対してレート制限を設定し、両方の API キーを指定しています。 + +プロバイダーごとに利用できる設定項目が異なる点にご注意ください。 + + + + + + + +## 追加の考慮事項 + +データのインポートは多くのリソースを消費します。大量のデータをインポートする際は、次の点を考慮してください。 + +### 非同期インポート + +:::caution Experimental +`v1.22` から利用可能です。これは試験的な機能です。ご注意ください。 +::: + +インポート速度を最大化するには、[非同期インデックス作成](/weaviate/config-refs/indexing/vector-index.mdx#asynchronous-indexing)を有効化してください。 + +非同期インデックス作成を有効にするには、 Weaviate の設定ファイルで `ASYNC_INDEXING` 環境変数を `true` に設定します。 + +```yaml +weaviate: + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ... + environment: + ASYNC_INDEXING: 'true' + ... +``` + +### 新しいテナントの自動追加 + +import AutoTenant from '/_includes/auto-tenant.mdx'; + + + +詳細は [auto-tenant](/weaviate/manage-collections/multi-tenancy#automatically-add-new-tenants) をご覧ください。 + + +## 関連ページ + +- [Weaviate に接続する](/weaviate/connections/index.mdx) +- [ハウツー: オブジェクトを作成する](./create.mdx) +- 参照: REST - /v1/batch +- [設定: インデックス](/weaviate/config-refs/indexing/vector-index.mdx#asynchronous-indexing) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/index.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/index.mdx new file mode 100644 index 000000000..007dfeba3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/index.mdx @@ -0,0 +1,66 @@ +--- +title: オブジェクトの管理 +sidebar_position: 0 +image: og/docs/howto.jpg +hide_table_of_contents: true +# tags: ['how to', 'manage data', 'crud'] +--- + + Weaviate オブジェクトに対する基本的な CRUD (Create, Read, Update, Delete) 操作を学びます。 +このガイドでは、単一オブジェクトの作成、バッチインポート、特定オブジェクトの読み取り、すべてのオブジェクトの取得、既存オブジェクトの更新、そしてコレクション内のオブジェクトの削除について、詳細な手順を提供します。 + +import CardsSection from "/src/components/CardsSection"; + +export const objectCrudData = [ + { + title: "オブジェクトの作成", + description: "個々のデータオブジェクトを Weaviate コレクションに追加します。", + link: "/weaviate/manage-objects/create", + icon: "fas fa-plus-circle", + }, + { + title: "バッチインポート", + description: + "複数のデータオブジェクトをバッチで効率的にコレクションに追加します。", + link: "/weaviate/manage-objects/import", + icon: "fas fa-file-import", + }, + { + title: "オブジェクトの読み取り", + description: + "ID や ベクトル で指定したデータオブジェクトをコレクションから取得します。", + link: "/weaviate/manage-objects/read", + icon: "fas fa-eye", + }, + { + title: "すべてのオブジェクトの読み取り", + description: + "ページネーションを用いて、コレクションから複数またはすべてのオブジェクトを取得します。", + link: "/weaviate/manage-objects/read-all-objects", + icon: "fas fa-list", + }, + { + title: "オブジェクトの更新", + description: + "コレクション内の既存データオブジェクトを変更します (フルまたは部分更新)。", + link: "/weaviate/manage-objects/update", + icon: "fas fa-edit", + }, + { + title: "オブジェクトの削除", + description: "コレクションから特定のデータオブジェクトを削除します。", + link: "/weaviate/manage-objects/delete", + icon: "fas fa-trash-alt", + }, +]; + +
+ +
+ +## 質問とフィードバック + +import DocsFeedback from "/_includes/docs-feedback.mdx"; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/read-all-objects.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/read-all-objects.mdx new file mode 100644 index 000000000..658dbaa03 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/read-all-objects.mdx @@ -0,0 +1,192 @@ +--- +title: すべてのオブジェクトを読み込む +sidebar_position: 25 +image: og/docs/howto.jpg +# tags: ['how-to', 'cursor'] +--- + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.read-all-objects.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.read-all-objects-v3.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.read-all-objects.ts'; +import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.read-all-objects-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.read-all-objects.java'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.read-all-objects_test.go'; + +Weaviate は、すべてのデータを反復処理するために必要な API を提供します。これは、データ(および ベクトル エンベディング)を別の場所へ手動でコピー/移行したい場合に役立ちます。 + +これには `after` 演算子、別名 [cursor API](../api/graphql/additional-operators.md#cursor-with-after) を使用します。 + +:::info Iterator +新しい API クライアント(現在は Python Client v4 が対応)では、この機能が `Iterator` としてカプセル化されています。 +::: + +## オブジェクトのプロパティと ID を読み込む + +次のコードは、すべてのオブジェクトを走査し、各オブジェクトのプロパティと ID を取得します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## ベクトルを含むすべてのオブジェクトを読み込む + +ベクトル を含むすべてのデータを読み込みます。([named vectors](../config-refs/collections.mdx#named-vectors) を使用している場合にも適用されます。) + + + + + + + + + + + + + + + + + + + + + + +## 全オブジェクトの読み取り - マルチ テナント コレクション + +すべてのテナントを順に処理し、それぞれのデータを読み取ります。 + +:::tip Multi-tenancy +[multi-tenancy](../concepts/data.md#multi-tenancy) が有効になっているクラスでは、オブジェクトを読み取る場合や作成する場合にテナント名を指定する必要があります。詳細は [データ管理: マルチ テナンシー操作]( ../manage-collections/multi-tenancy.mdx) をご覧ください。 +::: + + + + + + + + + + + + + + + + + + + + +## 関連ページ + +- [Weaviate への接続](/weaviate/connections/index.mdx) +- [How-to: オブジェクトの読み取り](./read.mdx) +- [リファレンス: GraphQL - 追加演算子](../api/graphql/additional-operators.md#cursor-with-after) +- [データ管理: マルチ テナンシー操作]( ../manage-collections/multi-tenancy.mdx) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/read.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/read.mdx new file mode 100644 index 000000000..e48b14cea --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/read.mdx @@ -0,0 +1,214 @@ +--- +title: オブジェクトの読み取り +sidebar_position: 20 +image: og/docs/howto.jpg +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.read.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.read-v3.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.read.ts'; +import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.read-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.read.java'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.read_test.go'; +import SkipLink from '/src/components/SkipValidationLink' + + +データベースをクエリする代わりに、個々のオブジェクトを取得するには ID を使用できます。 + +import RestObjectsCRUDClassnameNote from '/_includes/rest-objects-crud-classname-note.md'; + +
+ 追加情報 + +
+ +## ID でオブジェクトを取得 + + ID を指定してオブジェクトを取得します。指定した ID が存在しない場合、Weaviate は 404 エラーを返します。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## オブジェクトの ベクトル を取得 + +オブジェクトの ベクトル は、返却内容として指定することで取得できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## 名前付き ベクトルの取得 + +名前付き ベクトルを使用している場合、ベクトル名を指定することで 1 つ以上を取得できます。 + + + + + + + + + + + + + + + + + + + + +## オブジェクトの存在確認 + +特定の `id` を持つオブジェクトが存在するかどうかを取得せずに効率的に確認するには、 `HEAD` リクエストを `/v1/objects/` REST エンドポイント に送信するか、以下のクライアントコードを使用します。 + +import CheckObjectExistence from '/_includes/code/howto/manage-data.read.check.existence.mdx'; + + + +## 関連ページ + +- [Weaviate への接続](/weaviate/connections/index.mdx) +- [ハウツー: 検索](../search/index.mdx) +- [ハウツー: すべてのオブジェクトを読み取る](./read-all-objects.mdx) +- 参照: REST - /v1/objects + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/update.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/update.mdx new file mode 100644 index 000000000..1f87fe141 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/manage-objects/update.mdx @@ -0,0 +1,281 @@ +--- +title: オブジェクトの更新 +sidebar_position: 30 +image: og/docs/howto.jpg +--- + + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyCode from '!!raw-loader!/_includes/code/howto/manage-data.update.py'; +import PyCodeV3 from '!!raw-loader!/_includes/code/howto/manage-data.update-v3.py'; +import TSCode from '!!raw-loader!/_includes/code/howto/manage-data.update.ts'; +import TSCodeLegacy from '!!raw-loader!/_includes/code/howto/manage-data.update-v2.ts'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/manage-data.update.java'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/manage-data.update_test.go'; +import RestObjectsCRUDClassnameNote from '/_includes/rest-objects-crud-classname-note.md'; +import SkipLink from '/src/components/SkipValidationLink' + +Weaviate ではオブジェクトを部分的または完全に更新できます。 + +
+ 追加情報 + + - 部分更新は、内部的には `PATCH` リクエストを `/v1/objects` REST API エンドポイントに送信 して実行されます。 + - 完全更新は、内部的には `PUT` リクエストを `/v1/objects` REST API エンドポイントに送信 して実行されます。 + - `vector` プロパティを含む更新では、`text` プロパティがすべて [スキップ](../manage-collections/vector-config.mdx#property-level-settings) されていない限り、ベクトル埋め込みが再計算されます。 + - オブジェクトを更新するには、コレクション名、ID、更新するプロパティを指定する必要があります。 + - [マルチテナンシー](../concepts/data.md#multi-tenancy) コレクションの場合は、テナント名も指定する必要があります。詳細は [データ管理: マルチテナンシー操作](../manage-collections/multi-tenancy.mdx) を参照してください。 +
+ + + +
+ +## オブジェクトプロパティの更新 + +この操作では、指定したプロパティの値をまるごと置き換え、指定していないプロパティはそのまま残します。コレクション名、オブジェクト ID、および更新するプロパティを指定してください。 + +以前にベクトル化されたプロパティの値を更新した場合、Weaviate はオブジェクトを自動的に再ベクトル化します。これにより更新されたオブジェクトも再インデックスされます。 + +ただし、新しいプロパティをコレクション定義に追加した場合、Weaviate は新規オブジェクトのみをベクトル化します。新しいプロパティが定義されたときに既存オブジェクトを再ベクトル化および再インデックスすることはなく、既存プロパティが更新されたときのみ行います。 + + + + + + + + + + + + + + + + + + + + + + +## オブジェクト ベクトルの更新 + +オブジェクト ベクトルもプロパティと同様に更新できます。[名前付きベクトル](../config-refs/collections.mdx#named-vectors) を使用する場合は、[オブジェクト作成](./create.mdx#create-an-object-with-named-vectors) と同様に、データを辞書(マップ)形式で指定してください。 + + + + + + + + + + + + + + + + > Coming soon (vote for the [機能リクエスト](https://github.com/weaviate/typescript-client/issues/64)) + + + + + + > 近日公開 + + + + + + > 近日公開 + + + + + + + +## オブジェクト全体の置換 + +コレクション名、 id 、新しいオブジェクトを指定してオブジェクト全体を置換できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + + +## プロパティの削除 + +コレクション定義におけるプロパティの削除や更新は[まだサポートされていません](https://github.com/weaviate/weaviate/issues/2848)。 + +オブジェクトレベルでは、該当プロパティを削除したコピーと置き換えるか、テキストプロパティの場合は値を `""` に設定することで対応できます。 + + + + + + + + + + + + + + + + + + + + + + + + + + +## 関連ページ + +- [Weaviate への接続](/weaviate/connections/index.mdx) +- リファレンス: REST - /v1/objects + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_category_.json new file mode 100644 index 000000000..2250672e3 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Model provider integrations", + "position": 40 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/google-api-key-note.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/google-api-key-note.md new file mode 100644 index 000000000..2b0963c2b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/google-api-key-note.md @@ -0,0 +1,10 @@ +
+ API キー ヘッダー + +`v1.27.7`、`v1.26.12`、`v1.25.27` 以降では、 Vertex AI ユーザー向けには `X-Goog-Vertex-Api-Key`、 Gemini API 向けには `X-Goog-Studio-Api-Key` ヘッダーがサポートされています。最も高い互換性を得るため、これらのヘッダーの使用を推奨します。 +
+ +`X-Google-Vertex-Api-Key`、`X-Google-Studio-Api-Key`、`X-Google-Api-Key`、`X-PaLM-Api-Key` は非推奨となります。 + +
+ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag.png new file mode 100644 index 000000000..e39e7df08 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag_grouped.png new file mode 100644 index 000000000..7b153f7be Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag_single.png new file mode 100644 index 000000000..81f95addd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anthropic_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag.png new file mode 100644 index 000000000..d6aaeb088 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag_grouped.png new file mode 100644 index 000000000..c800661f2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag_single.png new file mode 100644 index 000000000..8e6582577 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_anyscale_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_embedding.png new file mode 100644 index 000000000..0bce5d91f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_embedding_search.png new file mode 100644 index 000000000..a7e91afc2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag.png new file mode 100644 index 000000000..95ba2a90d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag_grouped.png new file mode 100644 index 000000000..ab06c0ea9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag_single.png new file mode 100644 index 000000000..9e79207df Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_aws_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_embedding.png new file mode 100644 index 000000000..df7452a39 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_embedding_search.png new file mode 100644 index 000000000..de91b5ad6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag.png new file mode 100644 index 000000000..19ee75edd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag_grouped.png new file mode 100644 index 000000000..542d7f00d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag_single.png new file mode 100644 index 000000000..0d0611103 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_reranker.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_reranker.png new file mode 100644 index 000000000..bdd0d217b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_cohere_reranker.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_embedding.png new file mode 100644 index 000000000..eddd4f4e9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_embedding_search.png new file mode 100644 index 000000000..180e03072 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag.png new file mode 100644 index 000000000..439aa039c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag_grouped.png new file mode 100644 index 000000000..99aa84e8b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag_single.png new file mode 100644 index 000000000..db5dca5fc Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_databricks_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag.png new file mode 100644 index 000000000..8b9929063 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag_grouped.png new file mode 100644 index 000000000..1689c5644 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag_single.png new file mode 100644 index 000000000..5bdbbfdfe Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_friendliai_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_embedding.png new file mode 100644 index 000000000..c01af7719 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_embedding_search.png new file mode 100644 index 000000000..9ea7bc641 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag.png new file mode 100644 index 000000000..4b21ab7b9 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag_grouped.png new file mode 100644 index 000000000..fd1439362 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag_single.png new file mode 100644 index 000000000..708b388b8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_google_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_gpt4all_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_gpt4all_embedding.png new file mode 100644 index 000000000..80f68921d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_gpt4all_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_gpt4all_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_gpt4all_embedding_search.png new file mode 100644 index 000000000..bdec74c95 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_gpt4all_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_huggingface_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_huggingface_embedding.png new file mode 100644 index 000000000..7af9255d7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_huggingface_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_huggingface_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_huggingface_embedding_search.png new file mode 100644 index 000000000..4e6496b4b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_huggingface_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_imagebind_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_imagebind_embedding.png new file mode 100644 index 000000000..48186ffa7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_imagebind_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_imagebind_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_imagebind_embedding_search.png new file mode 100644 index 000000000..f192b632e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_imagebind_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_embedding.png new file mode 100644 index 000000000..98e4e1c71 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_embedding_search.png new file mode 100644 index 000000000..070b22536 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_reranker.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_reranker.png new file mode 100644 index 000000000..f870101c7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_jinaai_reranker.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_embedding.png new file mode 100644 index 000000000..b993e6fa6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_embedding_search.png new file mode 100644 index 000000000..012c88705 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag.png new file mode 100644 index 000000000..e1c0d359d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag_grouped.png new file mode 100644 index 000000000..bafdb62d7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag_single.png new file mode 100644 index 000000000..18aa5408c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_kubeai_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_embedding.png new file mode 100644 index 000000000..aa6dd1a58 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_embedding_search.png new file mode 100644 index 000000000..9e5f384c7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag.png new file mode 100644 index 000000000..fa88d2c63 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag_grouped.png new file mode 100644 index 000000000..7c7df0bc6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag_single.png new file mode 100644 index 000000000..9db6306be Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_mistral_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_model2vec_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_model2vec_embedding.png new file mode 100644 index 000000000..17f2793bf Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_model2vec_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_model2vec_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_model2vec_embedding_search.png new file mode 100644 index 000000000..35b894b2a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_model2vec_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_embedding.png new file mode 100644 index 000000000..1d372382c Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_embedding_search.png new file mode 100644 index 000000000..89ea77aa7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag.png new file mode 100644 index 000000000..175949f00 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag_grouped.png new file mode 100644 index 000000000..50e57e988 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag_single.png new file mode 100644 index 000000000..21fb4eaa6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_reranker.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_reranker.png new file mode 100644 index 000000000..7496b7956 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_nvidia_reranker.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_embedding.png new file mode 100644 index 000000000..c3b6224cb Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_embedding_search.png new file mode 100644 index 000000000..c1d6434f6 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag.png new file mode 100644 index 000000000..35b7c1147 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag_grouped.png new file mode 100644 index 000000000..879c0e167 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag_single.png new file mode 100644 index 000000000..857101c4a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_octoai_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_embedding.png new file mode 100644 index 000000000..594ed53ec Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_embedding_search.png new file mode 100644 index 000000000..77cca648d Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag.png new file mode 100644 index 000000000..761d42e50 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag_grouped.png new file mode 100644 index 000000000..7f9ab415b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag_single.png new file mode 100644 index 000000000..7c450ea32 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_ollama_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_embedding.png new file mode 100644 index 000000000..5b6ab7222 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_embedding_search.png new file mode 100644 index 000000000..469953307 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag.png new file mode 100644 index 000000000..cf04a14a8 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag_grouped.png new file mode 100644 index 000000000..e32145e9e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag_single.png new file mode 100644 index 000000000..76515649a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_azure_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_embedding.png new file mode 100644 index 000000000..723a25a21 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_embedding_search.png new file mode 100644 index 000000000..a58d97f0f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag.png new file mode 100644 index 000000000..6379a44a7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag_grouped.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag_grouped.png new file mode 100644 index 000000000..bad8a7b0f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag_grouped.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag_single.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag_single.png new file mode 100644 index 000000000..17549614a Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_openai_rag_single.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_selfhosted_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_selfhosted_embedding.png new file mode 100644 index 000000000..a87305d8e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_selfhosted_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_embedding.png new file mode 100644 index 000000000..7af9255d7 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_embedding_search.png new file mode 100644 index 000000000..4e6496b4b Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_reranker.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_reranker.png new file mode 100644 index 000000000..ed95f22e2 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_transformers_reranker.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_embedding.png new file mode 100644 index 000000000..60718bdf5 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_embedding_search.png new file mode 100644 index 000000000..429303314 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_reranker.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_reranker.png new file mode 100644 index 000000000..3764c7c09 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_voyageai_reranker.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_wes_embedding.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_wes_embedding.png new file mode 100644 index 000000000..3aacecfcd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_wes_embedding.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_wes_embedding_search.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_wes_embedding_search.png new file mode 100644 index 000000000..f2682c999 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_wes_embedding_search.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_xai_rag.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_xai_rag.png new file mode 100644 index 000000000..753608447 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/integration_xai_rag.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/ollama/api-endpoint.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/ollama/api-endpoint.mdx new file mode 100644 index 000000000..a5d16629f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/ollama/api-endpoint.mdx @@ -0,0 +1,4 @@ +Weaviate サーバーは Ollama API エンドポイントに到達できる必要があります。Weaviate が Docker コンテナ内で実行され、Ollama がローカルで実行されている場合は、`host.docker.internal` を使用して、コンテナ内の `localhost` からホストマシン上の `localhost` へ Weaviate をリダイレクトしてください。 + +Weaviate インスタンスと Ollama インスタンスが別の方法でホストされている場合は、API エンドポイントのパラメーターを調整し、ご自身の Ollama インスタンスを指すようにしてください。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.local.py b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.local.py new file mode 100644 index 000000000..4d9f6cf55 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.local.py @@ -0,0 +1,9 @@ +# START-ANY +import weaviate + +client = weaviate.connect_to_local() + +# Work with Weaviate + +client.close() +# END-ANY diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.local.ts b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.local.ts new file mode 100644 index 000000000..9f40fe912 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.local.ts @@ -0,0 +1,10 @@ +// START-ANY +import weaviate from 'weaviate-client' + +const client = await weaviate.connectToLocal() + +// Work with Weaviate + +client.close() +// END-ANY + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.py b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.py new file mode 100644 index 000000000..c6a03fc55 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.py @@ -0,0 +1,168 @@ +# START-ANY +import weaviate +from weaviate.classes.init import Auth +import os + +# END-ANY + +weaviate_url = os.getenv("WEAVIATE_URL") +weaviate_key = os.getenv("WEAVIATE_API_KEY") + +# START AnthropicInstantiation +# Recommended: save sensitive data as environment variables +anthropic_key = os.getenv("ANTHROPIC_APIKEY") +# END AnthropicInstantiation +# START AnyscaleInstantiation +# Recommended: save sensitive data as environment variables +anyscale_key = os.getenv("ANYSCALE_APIKEY") +# END AnyscaleInstantiation +# START AWSInstantiation +# Recommended: save sensitive data as environment variables +aws_access_key = os.getenv("AWS_ACCESS_KEY") +aws_secret_key = os.getenv("AWS_SECRET_KEY") +# END AWSInstantiation +# START CohereInstantiation +# Recommended: save sensitive data as environment variables +cohere_key = os.getenv("COHERE_APIKEY") +# END CohereInstantiation +# START DatabricksInstantiation +# Recommended: save sensitive data as environment variables +databricks_token = os.getenv("DATABRICKS_TOKEN") +# END DatabricksInstantiation +# START FriendliInstantiation +# Recommended: save sensitive data as environment variables +friendli_key = os.getenv("FRIENDLI_TOKEN") +# END FriendliInstantiation +# START FriendliDedicatedInstantiation +# Recommended: save sensitive data as environment variables +friendli_key = os.getenv("FRIENDLI_TOKEN") +# END FriendliDedicatedInstantiation +# START GoogleInstantiation # START GoogleVertexInstantiation +# Recommended: save sensitive data as environment variables +vertex_key = os.getenv("VERTEX_APIKEY") +# START GoogleInstantiation # END GoogleVertexInstantiation +studio_key = os.getenv("STUDIO_APIKEY") +# END GoogleInstantiation +# START HuggingFaceInstantiation +# Recommended: save sensitive data as environment variables +huggingface_key = os.getenv("HUGGINGFACE_APIKEY") +# END HuggingFaceInstantiation +# START JinaAIInstantiation +# Recommended: save sensitive data as environment variables +jinaai_key = os.getenv("JINAAI_APIKEY") +# END JinaAIInstantiation +# START MistralInstantiation +# Recommended: save sensitive data as environment variables +mistral_key = os.getenv("MISTRAL_APIKEY") +# END MistralInstantiation +# START NVIDIAInstantiation +# Recommended: save sensitive data as environment variables +nvidia_key = os.getenv("NVIDIA_APIKEY") +# END NVIDIAInstantiation +# START OctoAIInstantiation +# Recommended: save sensitive data as environment variables +octoai_key = os.getenv("OCTOAI_APIKEY") +# END OctoAIInstantiation +# START OpenAIInstantiation +# Recommended: save sensitive data as environment variables +openai_key = os.getenv("OPENAI_APIKEY") +# END OpenAIInstantiation +# START AzureOpenAIInstantiation +# Recommended: save sensitive data as environment variables +azure_key = os.getenv("AZURE_APIKEY") +# END AzureOpenAIInstantiation +# START VoyageAIInstantiation +# Recommended: save sensitive data as environment variables +voyageai_key = os.getenv("VOYAGEAI_APIKEY") +# END VoyageAIInstantiation +# START XaiInstantiation +# Recommended: save sensitive data as environment variables +xai_key = os.getenv("XAI_APIKEY") +# END XaiInstantiation + + +# START-ANY +# highlight-start +headers = { +# END-ANY + +# START AnthropicInstantiation + "X-Anthropic-Api-Key": anthropic_key, + "X-Anthropic-Baseurl": "https://api.anthropic.com", # Optional; for providing a custom base URL +# END AnthropicInstantiation +# START AnyscaleInstantiation + "X-Anyscale-Api-Key": anyscale_key, +# END AnyscaleInstantiation +# START AWSInstantiation + "X-AWS-Access-Key": aws_access_key, + "X-AWS-Secret-Key": aws_secret_key, +# END AWSInstantiation +# START CohereInstantiation + "X-Cohere-Api-Key": cohere_key, +# END CohereInstantiation +# START DatabricksInstantiation + "X-Databricks-Token": databricks_token, +# END DatabricksInstantiation +# START FriendliInstantiation + "X-Friendli-Api-Key": friendli_key, +# END FriendliInstantiation +# START FriendliDedicatedInstantiation + "X-Friendli-Api-Key": friendli_key, + "X-Friendli-Baseurl": "https://inference.friendli.ai/dedicated", +# END FriendliDedicatedInstantiation +# START GoogleInstantiation # START GoogleVertexInstantiation + "X-Goog-Vertex-Api-Key": vertex_key, +# START GoogleInstantiation # END GoogleVertexInstantiation + "X-Goog-Studio-Api-Key": studio_key, +# END GoogleInstantiation +# START HuggingFaceInstantiation + "X-HuggingFace-Api-Key": huggingface_key, +# END HuggingFaceInstantiation +# START JinaAIInstantiation + "X-JinaAI-Api-Key": jinaai_key, +# END JinaAIInstantiation +# START MistralInstantiation + "X-Mistral-Api-Key": mistral_key, +# END MistralInstantiation +# START NVIDIAInstantiation + "X-NVIDIA-Api-Key": nvidia_key, +# END NVIDIAInstantiation +# START OctoAIInstantiation + "X-OctoAI-Api-Key": octoai_key, +# END OctoAIInstantiation +# START OpenAIInstantiation + "X-OpenAI-Api-Key": openai_key, +# END OpenAIInstantiation +# START AzureOpenAIInstantiation + "X-Azure-Api-Key": azure_key, +# END AzureOpenAIInstantiation +# START VoyageAIInstantiation + "X-VoyageAI-Api-Key": voyageai_key, +# END VoyageAIInstantiation +# START XaiInstantiation + "X-Xai-Api-Key": xai_key, +# END XaiInstantiation + +# START-ANY +} +# highlight-end +# END-ANY + +# START-ANY + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, # `weaviate_url`: your Weaviate URL + auth_credentials=Auth.api_key(weaviate_key), # `weaviate_key`: your Weaviate API key + # highlight-start + headers=headers + # highlight-end +) +# END-ANY + + +# START-ANY + +# Work with Weaviate + +client.close() +# END-ANY diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.ts b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.ts new file mode 100644 index 000000000..959656e8c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.ts @@ -0,0 +1,132 @@ +// START-ANY +import weaviate from 'weaviate-client' + +// END-ANY + +// START AnthropicInstantiation +const anthropicApiKey = process.env.ANTHROPIC_APIKEY || ''; // Replace with your inference API key +// END AnthropicInstantiation +// START AnyscaleInstantiation +const anyscaleApiKey = process.env.ANYSCALE_APIKEY || ''; // Replace with your inference API key +// END AnyscaleInstantiation +// START AWSInstantiation +const aws_access_key = process.env.AWS_ACCESS_KEY || ''; // Replace with your AWS access key +const aws_secret_key = process.env.AWS_SECRET_KEY || ''; // Replace with your AWS secret key +// END AWSInstantiation +// START CohereInstantiation +const cohereApiKey = process.env.COHERE_APIKEY || ''; // Replace with your inference API key +// END CohereInstantiation +// START DatabricksInstantiation +const databricksToken = process.env.DATABRICKS_TOKEN || ''; // Replace with your inference API key +// END DatabricksInstantiation +// START FriendliInstantiation +const friendliApiKey = process.env.FRIENDLI_TOKEN || ''; // Replace with your inference API key +// END FriendliInstantiation +// START GoogleInstantiation // START GoogleVertexInstantiation +const vertexApiKey = process.env.VERTEX_APIKEY || ''; // Replace with your inference API key +// START GoogleInstantiation // END GoogleVertexInstantiation +const studioApiKey = process.env.STUDIO_APIKEY || ''; // Replace with your inference API key +// END GoogleInstantiation +// START HuggingFaceInstantiation +const huggingFaceApiKey = process.env.HUGGINGFACE_APIKEY || ''; // Replace with your inference API key +// END HuggingFaceInstantiation +// START JinaAIInstantiation +const jinaaiApiKey = process.env.JINAAI_APIKEY || ''; // Replace with your inference API key +// END JinaAIInstantiation +// START MistralInstantiation +const mistralApiKey = process.env.MISTRAL_APIKEY || ''; // Replace with your inference API key +// END MistralInstantiation +// START NVIDIAInstantiation +const nvidiaApiKey = process.env.NVIDIA_APIKEY || ''; // Replace with your inference API key +// END NVIDIAInstantiation +// START OctoAIInstantiation +const octoaiApiKey = process.env.OCTOAI_APIKEY || ''; // Replace with your inference API key +// END OctoAIInstantiation +// START OpenAIInstantiation +const openaiApiKey = process.env.OPENAI_APIKEY || ''; // Replace with your inference API key +// END OpenAIInstantiation +// START AzureOpenAIInstantiation +const azureApiKey = process.env.AZURE_APIKEY || ''; // Replace with your inference API key +// END AzureOpenAIInstantiation +// START VoyageAIInstantiation +const voyageaiApiKey = process.env.VOYAGEAI_APIKEY || ''; // Replace with your inference API key +// END VoyageAIInstantiation +// START Xainstantiation +const xaiApiKey = process.env.XAI_APIKEY || ''; // Replace with your inference API key +// END XaiInstantiation + +// START-ANY + +const client = await weaviate.connectToWeaviateCloud( + 'WEAVIATE_INSTANCE_URL', // Replace with your instance URL + { + authCredentials: new weaviate.ApiKey('WEAVIATE_INSTANCE_APIKEY'), + // highlight-start + headers: { + // END-ANY + // START AnthropicInstantiation + 'X-Anthropic-Api-Key': anthropicApiKey, + 'X-Anthropic-Baseurl': 'https://api.anthropic.com', // Optional; for providing a custom base URL + // END AnthropicInstantiation + // START AnyscaleInstantiation + 'X-Anyscale-Api-Key': anyscaleApiKey, + // END AnyscaleInstantiation + // START AWSInstantiation + 'X-AWS-Access-Key': aws_access_key, + 'X-AWS-Secret-Key': aws_secret_key, + // END AWSInstantiation + // START CohereInstantiation + 'X-Cohere-Api-Key': cohereApiKey, + // END CohereInstantiation + // START DatabricksInstantiation + 'X-Databricks-Token': databricksToken, + // END DatabricksInstantiation + // START FriendliInstantiation // START FriendliDedicatedInstantiation + 'X-Friendli-Api-Key': friendliApiKey, + // END FriendliInstantiation // END FriendliDedicatedInstantiation + // START FriendliDedicatedInstantiation + 'X-Friendli-Baseurl': 'https://inference.friendli.ai/dedicated', + // END FriendliDedicatedInstantiation + // START GoogleInstantiation // START GoogleVertexInstantiation + 'X-Vertex-Api-Key': vertexApiKey, + // START GoogleInstantiation // END GoogleVertexInstantiation + 'X-Studio-Api-Key': studioApiKey, + // END GoogleInstantiation + // START JinaAIInstantiation + 'X-JinaAI-Api-Key': jinaaiApiKey, + // END JinaAIInstantiation + // START HuggingFaceInstantiation + 'X-HuggingFace-Api-Key': huggingFaceApiKey, + // END HuggingFaceInstantiation + // START MistralInstantiation + 'X-Mistral-Api-Key': mistralApiKey, + // END MistralInstantiation + // START NVIDIAInstantiation + 'X-NVIDIA-Api-Key': nvidiaApiKey, + // END NVIDIAInstantiation + // START OctoAIInstantiation + 'X-OctoAI-Api-Key': octoaiApiKey, + // END OctoAIInstantiation + // START OpenAIInstantiation + 'X-OpenAI-Api-Key': openaiApiKey, + // END OpenAIInstantiation + // START AzureOpenAIInstantiation + 'X-Azure-Api-Key': azureApiKey, + // END AzureOpenAIInstantiation + // START VoyageAIInstantiation + 'X-VoyageAI-Api-Key': voyageaiApiKey, + // END VoyageAIInstantiation + // START XaiInstantiation + 'X-Xai-Api-Key': xaiApiKey, + // END XaiInstantiation + // START-ANY + } + // highlight-end + } +) + +// Work with Weaviate + +client.close() +// END-ANY + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.weaviate.py b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.weaviate.py new file mode 100644 index 000000000..9fef94ca1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.weaviate.py @@ -0,0 +1,20 @@ +# START WeaviateInstantiation +import weaviate +from weaviate.classes.init import Auth +import os + +# Best practice: store your credentials in environment variables +weaviate_url = os.getenv("WEAVIATE_URL") +weaviate_key = os.getenv("WEAVIATE_API_KEY") + +client = weaviate.connect_to_weaviate_cloud( + cluster_url=weaviate_url, # Weaviate URL: "REST Endpoint" in Weaviate Cloud console + auth_credentials=Auth.api_key(weaviate_key), # Weaviate API key: "ADMIN" API key in Weaviate Cloud console +) + +print(client.is_ready()) # Should print: `True` + +# Work with Weaviate + +client.close() +# END WeaviateInstantiation diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.weaviate.ts b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.weaviate.ts new file mode 100644 index 000000000..e7d9e1c91 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.connect.weaviate.ts @@ -0,0 +1,19 @@ +// START WeaviateInstantiation +import weaviate from 'weaviate-client' + +// Best practice: store your credentials in environment variables +const weaviateUrl = process.env.WEAVIATE_URL as string; // Weaviate URL: "REST Endpoint" in Weaviate Cloud console +const weaviateApiKey = process.env.WEAVIATE_API_KEY as string; // Weaviate API key: "ADMIN" API key in Weaviate Cloud console + +const client = await weaviate.connectToWeaviateCloud( + weaviateUrl, + { + authCredentials: new weaviate.ApiKey(weaviateApiKey), + } +) + +// Work with Weaviate + +client.close() +// END WeaviateInstantiation + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.generative.py b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.generative.py new file mode 100644 index 000000000..427684b47 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.generative.py @@ -0,0 +1,1328 @@ +import os +from weaviate.classes.config import Configure + +# ================================ +# ===== INSTANTIATION-COMMON ===== +# ================================ + +import weaviate + +def import_data(): + collection = client.collections.create( + "DemoCollection", + vector_config=Configure.Vectors.text2vec_openai(), + ) + + source_objects = [ + {"title": "The Shawshank Redemption"}, + {"title": "The Godfather"}, + {"title": "The Dark Knight"}, + {"title": "Jingle All the Way"}, + {"title": "A Christmas Carol"}, + ] + + with collection.batch.fixed_size(batch_size=200) as batch: + for src_obj in source_objects: + weaviate_obj = { + "title": src_obj["title"], + } + batch.add_object( + properties=weaviate_obj, + ) + + if len(collection.batch.failed_objects) > 0: + print(f"Failed to import {len(collection.batch.failed_objects)} objects") + for failed in collection.batch.failed_objects: + print(f"e.g. Failed to import object with error: {failed.message}") + +client = weaviate.connect_to_local( + headers={ + "X-OpenAI-Api-Key": os.environ["OPENAI_APIKEY"], + "X-Cohere-Api-Key": os.environ["COHERE_APIKEY"], + "X-Anthropic-Api-Key": os.environ["ANTHROPIC_APIKEY"], + } +) + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeAnthropic +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.anthropic() + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeAnthropic + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeAnthropicCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.anthropic( + model="claude-3-opus-20240229" + ) + # highlight-end + # Additional parameters not shown +) +# END GenerativeAnthropicCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeAnthropic +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.anthropic( + # # These parameters are optional + # base_url="https://api.anthropic.com", + # model="claude-3-opus-20240229", + # max_tokens=512, + # temperature=0.7, + # stop_sequences=["\n\n"], + # top_p=0.9, + # top_k=5, + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeAnthropic + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionAnthropic +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.anthropic( + # # These parameters are optional + # base_url="https://api.anthropic.com", + # model="claude-3-opus-20240229", + # max_tokens=512, + # temperature=0.7, + # stop_sequences=["\n\n"], + # top_p=0.9, + # top_k=5, + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionAnthropic + +# START WorkingWithImagesAnthropic +import base64 +import requests +from weaviate.classes.generate import GenerativeConfig, GenerativeParameters + +src_img_path = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +base64_image = base64.b64encode(requests.get(src_img_path).content).decode('utf-8') + +prompt = GenerativeParameters.grouped_task( + # highlight-start + prompt="Which movie is closest to the image in terms of atmosphere", + images=[base64_image], # A list of base64 encoded strings of the image bytes + # image_properties=["img"], # Properties containing images in Weaviate + # highlight-end +) + +jeopardy = client.collections.use("DemoCollection") +response = jeopardy.generate.near_text( + query="Movies", + limit=5, + # highlight-start + grouped_task=prompt, + # highlight-end + generative_provider=GenerativeConfig.anthropic( + max_tokens=1000 + ), +) + +# Print the source property and the generated response +for o in response.objects: + print(f"Title property: {o.properties['title']}") +print(f"Grouped task result: {response.generative.text}") +# END WorkingWithImagesAnthropic + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeAnyscale +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.anyscale() + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeAnyscale + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeAnyscaleCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.anyscale( + model="mistralai/Mixtral-8x7B-Instruct-v0.1" + ) + # highlight-end + # Additional parameters not shown +) +# END GenerativeAnyscaleCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeAnyscale +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.anyscale( + # # These parameters are optional + # model="meta-llama/Llama-2-70b-chat-hf", + # temperature=0.7, + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeAnyscale + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionAnyscale +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.anyscale( + # # These parameters are optional + # base_url="https://api.anthropic.com", + # model="meta-llama/Llama-2-70b-chat-hf", + # temperature=0.7, + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionAnyscale + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeAWSBedrock +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.aws( + region="us-east-1", + service="bedrock", + model="cohere.command-r-plus-v1:0" + ) + # highlight-end +) +# END BasicGenerativeAWSBedrock + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeAWSSagemaker +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.aws( + region="us-east-1", + service="sagemaker", + endpoint="" + ) + # highlight-end +) +# END BasicGenerativeAWSSagemaker + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionAWS +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.aws( + region="us-east-1", + service="bedrock", # You can also use sagemaker + model="cohere.command-r-plus-v1:0" + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionAWS + +# START WorkingWithImagesAWS +import base64 +import requests +from weaviate.classes.generate import GenerativeConfig, GenerativeParameters + +src_img_path = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +base64_image = base64.b64encode(requests.get(src_img_path).content).decode('utf-8') + +prompt = GenerativeParameters.grouped_task( + # highlight-start + prompt="Which movie is closest to the image in terms of atmosphere", + images=[base64_image], # A list of base64 encoded strings of the image bytes + # image_properties=["img"], # Properties containing images in Weaviate + # highlight-end +) + +jeopardy = client.collections.use("DemoCollection") +response = jeopardy.generate.near_text( + query="Movies", + limit=5, + # highlight-start + grouped_task=prompt, + # highlight-end + generative_provider=GenerativeConfig.aws( + region="us-east-1", + service="bedrock", # You can also use sagemaker + model="cohere.command-r-plus-v1:0" + ), +) + +# Print the source property and the generated response +for o in response.objects: + print(f"Title property: {o.properties['title']}") +print(f"Grouped task result: {response.generative.text}") +# END WorkingWithImagesAWS + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeCohere +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.cohere() + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeCohere + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeCohereCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.cohere( + model="command-r-plus" + ) + # highlight-end + # Additional parameters not shown +) +# END GenerativeCohereCustomModel + +# clean up +client.collections.delete("DemoCollection") + + +# START FullGenerativeCohere +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.cohere( + # # These parameters are optional + # model="command-r", + # temperature=0.7, + # max_tokens=500, + # k=5, + # stop_sequences=["\n\n"], + # return_likelihoods="GENERATION" + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeCohere + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionCohere +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.cohere( + # # These parameters are optional + # model="command-r", + # temperature=0.7, + # max_tokens=500, + # k=5, + # stop_sequences=["\n\n"], + # return_likelihoods="GENERATION" + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionCohere + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeDatabricks +from weaviate.classes.config import Configure + +databricks_generative_endpoint = os.getenv("DATABRICKS_GENERATIVE_ENDPOINT") +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.databricks(endpoint=databricks_generative_endpoint) + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeDatabricks + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeDatabricks +from weaviate.classes.config import Configure + +databricks_generative_endpoint = os.getenv("DATABRICKS_GENERATIVE_ENDPOINT") +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.databricks( + endpoint=databricks_generative_endpoint + # # These parameters are optional + # max_tokens=500, + # temperature=0.7, + # top_p=0.7, + # top_k=0.1 + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeDatabricks + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionDatabricks +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.databricks( + # # These parameters are optional + # max_tokens=500, + # temperature=0.7, + # top_p=0.7, + # top_k=0.1 + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionDatabricks + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeFriendliAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.friendliai() + # Additional parameters not shown +) +# END BasicGenerativeFriendliAI + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeFriendliAICustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.friendliai( + model="meta-llama-3.1-70b-instruct", + ) + # highlight-end + # Additional parameters not shown +) +# END GenerativeFriendliAICustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeFriendliAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.friendliai( + # # These parameters are optional + # model="meta-llama-3.1-70b-instruct", + # max_tokens=500, + # temperature=0.7, + # base_url="https://inference.friendli.ai" + ) +) +# END FullGenerativeFriendliAI + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionFriendliAI +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.friendliai( + # # These parameters are optional + # model="meta-llama-3.1-70b-instruct", + # max_tokens=500, + # temperature=0.7, + # base_url="https://inference.friendli.ai" + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionFriendliAI + +# clean up +client.collections.delete("DemoCollection") + +# START DedicatedGenerativeFriendliAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.friendliai( + model = "YOUR_ENDPOINT_ID", + ) +) +# END DedicatedGenerativeFriendliAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeGoogleVertex +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.google( + project_id="", # Required for Vertex AI + model_id="gemini-1.0-pro" + ) + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeGoogleVertex + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeGoogleStudio +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.google( + model_id="gemini-pro" + ) + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeGoogleStudio + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeGoogle +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.google( + # project_id="", # Required for Vertex AI + # model_id="", + # api_endpoint="", + # temperature=0.7, + # top_k=5, + # top_p=0.9, + # vectorize_collection_name=False, + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeGoogle + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionGoogle +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.google( + # # These parameters are optional + # project_id="", # Required for Vertex AI + # model_id="", + # api_endpoint="", + # temperature=0.7, + # top_k=5, + # top_p=0.9, + # vectorize_collection_name=False, + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionGoogle + +# START WorkingWithImagesGoogle +import base64 +import requests +from weaviate.classes.generate import GenerativeConfig, GenerativeParameters + +src_img_path = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +base64_image = base64.b64encode(requests.get(src_img_path).content).decode('utf-8') + +prompt = GenerativeParameters.grouped_task( + # highlight-start + prompt="Which movie is closest to the image in terms of atmosphere", + images=[base64_image], # A list of base64 encoded strings of the image bytes + # image_properties=["img"], # Properties containing images in Weaviate + # highlight-end +) + +jeopardy = client.collections.use("DemoCollection") +response = jeopardy.generate.near_text( + query="Movies", + limit=5, + # highlight-start + grouped_task=prompt, + # highlight-end + generative_provider=GenerativeConfig.google( + max_tokens=1000 + ), +) + +# Print the source property and the generated response +for o in response.objects: + print(f"Title property: {o.properties['title']}") +print(f"Grouped task result: {response.generative.text}") +# END WorkingWithImagesGoogle + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeMistral +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.mistral() + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeMistral + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeMistralCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.mistral( + model="mistral-large-latest" + ) + # highlight-end + # Additional parameters not shown +) +# END GenerativeMistralCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeMistral +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.mistral( + # # These parameters are optional + # model="mistral-large", + # temperature=0.7, + # max_tokens=500, + ) + # highlight-end +) +# END FullGenerativeMistral + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionMistral +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.mistral( + # # These parameters are optional + # model="mistral-large", + # temperature=0.7, + # max_tokens=500, + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionMistral + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeNVIDIA +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.nvidia() + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeNVIDIA + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeNVIDIACustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.nvidia( + model="nvidia/llama-3.1-nemotron-70b-instruct" + ) + # Additional parameters not shown +) +# END GenerativeNVIDIACustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeNVIDIA +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.nvidia( + # # These parameters are optional + # base_url="https://integrate.api.nvidia.com/v1", + # model="meta/llama-3.3-70b-instruct", + # temperature=0.7, + # max_tokens=1024 + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeNVIDIA + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionNVIDIA +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.nvidia( + # # These parameters are optional + # base_url="https://integrate.api.nvidia.com/v1", + # model="meta/llama-3.3-70b-instruct", + # temperature=0.7, + # max_tokens=1024 + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionNVIDIA + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeOctoAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.octoai() + # Additional parameters not shown +) +# END BasicGenerativeOctoAI + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeOctoAICustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.octoai( + model="meta-llama-3-70b-instruct" + ) + # Additional parameters not shown +) +# END GenerativeOctoAICustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeOctoAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.octoai( + # # These parameters are optional + model = "meta-llama-3-70b-instruct", + max_tokens = 500, + temperature = 0.7, + base_url = "https://text.octoai.run" + ) +) +# END FullGenerativeOctoAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.openai() + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeOpenAI + +# clean up +client.collections.delete("DemoCollection") + +# START GenerativeOpenAICustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.openai( + model="gpt-4-1106-preview" + ) + # highlight-end + # Additional parameters not shown +) +# END GenerativeOpenAICustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.openai( + # # These parameters are optional + # model="gpt-4", + # frequency_penalty=0, + # max_tokens=500, + # presence_penalty=0, + # temperature=0.7, + # top_p=0.7, + # base_url="" + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeOpenAI + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionOpenAI +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.openai( + # # These parameters are optional + # model="gpt-4", + # frequency_penalty=0, + # max_tokens=500, + # presence_penalty=0, + # temperature=0.7, + # top_p=0.7, + # base_url="" + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionOpenAI + +# START WorkingWithImagesOpenAI +import base64 +import requests +from weaviate.classes.generate import GenerativeConfig, GenerativeParameters + +src_img_path = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +base64_image = base64.b64encode(requests.get(src_img_path).content).decode('utf-8') + +prompt = GenerativeParameters.grouped_task( + # highlight-start + prompt="Which movie is closest to the image in terms of atmosphere", + images=[base64_image], # A list of base64 encoded strings of the image bytes + # image_properties=["img"], # Properties containing images in Weaviate + # highlight-end +) + +jeopardy = client.collections.use("DemoCollection") +response = jeopardy.generate.near_text( + query="Movies", + limit=5, + # highlight-start + grouped_task=prompt, + # highlight-end + generative_provider=GenerativeConfig.openai( + max_tokens=1000 + ), +) + +# Print the source property and the generated response +for o in response.objects: + print(f"Title property: {o.properties['title']}") +print(f"Grouped task result: {response.generative.text}") +# END WorkingWithImagesOpenAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicGenerativeAzureOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.azure_openai( + resource_name="", + deployment_id="", + ) + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeAzureOpenAI + +# START BasicGenerativexAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.xai() + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativexAI + +# START GenerativexAICustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + generative_config=Configure.Generative.xai( + model="grok-2-latest" + ) + # Additional parameters not shown +) +# END GenerativexAICustomModel + +# START FullGenerativexAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.xai( + # # These parameters are optional + # base_url="https://api.x.ai/v1" + # model="grok-2-latest", + # max_tokens=500, + # temperature=0.7, + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativexAI + +# clean up +client.collections.delete("DemoCollection") + +# START RuntimeModelSelectionxAI +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.xai( + # # These parameters are optional + # base_url="https://api.x.ai/v1" + # model="grok-2-latest", + # max_tokens=500, + # temperature=0.7, + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionxAI + +# START FullGenerativeKubeAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.openai( + # Setting the model and base_url is required + model="gpt-3.5-turbo", + base_url="http://kubeai/openai", # Your private KubeAI API endpoint + # These parameters are optional + # frequency_penalty=0, + # max_tokens=500, + # presence_penalty=0, + # temperature=0.7, + # top_p=0.7, + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeKubeAI + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionKubeAI +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.openai( + # Setting the model and base_url is required + model="gpt-3.5-turbo", + base_url="http://kubeai/openai", # Your private KubeAI API endpoint + # These parameters are optional + # frequency_penalty=0, + # max_tokens=500, + # presence_penalty=0, + # temperature=0.7, + # top_p=0.7, + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionKubeAI + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeAzureOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.azure_openai( + resource_name="", + deployment_id="", + # # These parameters are optional + # frequency_penalty=0, + # max_tokens=500, + # presence_penalty=0, + # temperature=0.7, + # top_p=0.7, + # base_url="" + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeAzureOpenAI + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionAzureOpenAI +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.azure_openai( + resource_name="", + deployment_id="", + # # These parameters are optional + # frequency_penalty=0, + # max_tokens=500, + # presence_penalty=0, + # temperature=0.7, + # top_p=0.7, + # base_url="" + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionAzureOpenAI + +# START BasicGenerativeOllama +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.ollama( + api_endpoint="http://host.docker.internal:11434", # If using Docker, use this to contact your local Ollama instance + model="llama3" # The model to use, e.g. "phi3", or "mistral", "command-r-plus", "gemma" + ) + # highlight-end + # Additional parameters not shown +) +# END BasicGenerativeOllama + +# clean up +client.collections.delete("DemoCollection") + +# START FullGenerativeOllama +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + generative_config=Configure.Generative.ollama( + api_endpoint="http://host.docker.internal:11434", # If using Docker, use this to contact your local Ollama instance + model="llama3" # The model to use, e.g. "phi3", or "mistral", "command-r-plus", "gemma" + ) + # highlight-end + # Additional parameters not shown +) +# END FullGenerativeOllama + +# clean up +client.collections.delete("DemoCollection") +import_data() + +# START RuntimeModelSelectionOllama +from weaviate.classes.config import Configure +from weaviate.classes.generate import GenerativeConfig + +collection = client.collections.use("DemoCollection") +response = collection.generate.near_text( + query="A holiday film", + limit=2, + grouped_task="Write a tweet promoting these two movies", + # highlight-start + generative_provider=GenerativeConfig.ollama( + api_endpoint="http://host.docker.internal:11434", # If using Docker, use this to contact your local Ollama instance + model="llama3" # The model to use, e.g. "phi3", or "mistral", "command-r-plus", "gemma" + ), + # Additional parameters not shown + # highlight-end +) +# END RuntimeModelSelectionOllama + +# START WorkingWithImagesOllama +import base64 +import requests +from weaviate.classes.generate import GenerativeConfig, GenerativeParameters + +src_img_path = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +base64_image = base64.b64encode(requests.get(src_img_path).content).decode('utf-8') + +prompt = GenerativeParameters.grouped_task( + # highlight-start + prompt="Which movie is closest to the image in terms of atmosphere", + images=[base64_image], # A list of base64 encoded strings of the image bytes + # image_properties=["img"], # Properties containing images in Weaviate + # highlight-end +) + +jeopardy = client.collections.use("DemoCollection") +response = jeopardy.generate.near_text( + query="Movies", + limit=5, + # highlight-start + grouped_task=prompt, + # highlight-end + generative_provider=GenerativeConfig.ollama(), +) + +# Print the source property and the generated response +for o in response.objects: + print(f"Title property: {o.properties['title']}") +print(f"Grouped task result: {response.generative.text}") +# END WorkingWithImagesOllama + +client.collections.delete("DemoCollection") +import_data() + +# START SinglePromptExample +collection = client.collections.use("DemoCollection") + +response = collection.generate.near_text( + query="A holiday film", # The model provider integration will automatically vectorize the query + # highlight-start + single_prompt="Translate this into French: {title}", + limit=2 + # highlight-end +) + +for obj in response.objects: + print(obj.properties["title"]) + print(f"Generated output: {obj.generated}") # Note that the generated output is per object +# END SinglePromptExample + +# START GroupedTaskExample +collection = client.collections.use("DemoCollection") + +response = collection.generate.near_text( + query="A holiday film", # The model provider integration will automatically vectorize the query + # highlight-start + grouped_task="Write a fun tweet to promote readers to check out these films.", + limit=2 + # highlight-end +) + +print(f"Generated output: {response.generative.text}") # Note that the generated output is per query +for obj in response.objects: + print(obj.properties["title"]) +# END GroupedTaskExample + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.generative.ts b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.generative.ts new file mode 100644 index 000000000..16789a17d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.generative.ts @@ -0,0 +1,1171 @@ +import assert from 'assert'; + +// ================================ +// ===== INSTANTIATION-COMMON ===== +// ================================ +import weaviate from 'weaviate-client'; + +// START RuntimeModelSelectionAnthropic // START WorkingWithImagesAnthropic // START WorkingWithImagesAWS // START WorkingWithImagesGoogle // START WorkingWithImagesOpenAI // START RuntimeModelSelectionAnyscale // START RuntimeModelSelectionMistral // START RuntimeModelSelectionOpenAI // START RuntimeModelSelectionAWS // START RuntimeModelSelectionCohere // START RuntimeModelSelectionDatabricks // START RuntimeModelSelectionFriendliAI // START RuntimeModelSelectionGoogle // START RuntimeModelSelectionNVIDIA // START RuntimeModelSelectionKubeAI // START RuntimeModelSelectionAzureOpenAI // START RuntimeModelSelectionOllama // START RuntimeModelSelectionxAI +import { generativeParameters } from 'weaviate-client'; + +// END RuntimeModelSelectionAnthropic // END WorkingWithImagesAnthropic // END WorkingWithImagesAWS // END WorkingWithImagesGoogle // END WorkingWithImagesOpenAI // END RuntimeModelSelectionAnyscale // END RuntimeModelSelectionMistral // END RuntimeModelSelectionOpenAI // END RuntimeModelSelectionAWS // END RuntimeModelSelectionCohere // END RuntimeModelSelectionDatabricks // END RuntimeModelSelectionFriendliAI // END RuntimeModelSelectionGoogle // END RuntimeModelSelectionNVIDIA // END RuntimeModelSelectionKubeAI // END RuntimeModelSelectionAzureOpenAI // END RuntimeModelSelectionOllama // END RuntimeModelSelectionxAI + +// START WorkingWithImagesAnthropic // START WorkingWithImagesAWS // START WorkingWithImagesGoogle // START WorkingWithImagesOpenAI +function arrayBufferToBase64(buffer: ArrayBuffer): string { + const bytes = new Uint8Array(buffer); + let binary = ''; + const chunkSize = 1024; // Process in chunks to avoid call stack issues + + for (let i = 0; i < bytes.length; i += chunkSize) { + const chunk = bytes.slice(i, Math.min(i + chunkSize, bytes.length)); + binary += String.fromCharCode.apply(null, Array.from(chunk)); + } + + return btoa(binary); +} + +// END WorkingWithImagesAnthropic // END WorkingWithImagesAWS // END WorkingWithImagesGoogle // END WorkingWithImagesOpenAI + +async function main() { + + const client = await weaviate.connectToLocal({ + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY as string, + 'X-Cohere-Api-Key': process.env.COHERE_APIKEY as string, + }, + }); + + // Clean up + await client.collections.delete('DemoCollection'); + +// START BasicGenerativeAnthropic +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.anthropic(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeAnthropic + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeAnthropicCustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.anthropic({ + model: 'claude-3-opus-20240229' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeAnthropicCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeAnthropic +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.anthropic({ + // These parameters are optional + // baseURL: 'https://api.anthropic.com', + // model: 'claude-3-opus-20240229', + // maxTokens: 512, + // temperature: 0.7, + // stopSequences: ['\n\n'], + // topP: 0.9, + // topK: 5, + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeAnthropic + +// Clean up +await client.collections.delete('DemoCollection'); + + +// START RuntimeModelSelectionAnthropic // START RuntimeModelSelectionxAI // START WorkingWithImagesAnthropic // START WorkingWithImagesAWS // START WorkingWithImagesGoogle // START WorkingWithImagesOpenAI // START RuntimeModelSelectionAnyscale // START RuntimeModelSelectionMistral // START RuntimeModelSelectionOpenAI // START RuntimeModelSelectionAWS // START RuntimeModelSelectionCohere // START RuntimeModelSelectionDatabricks // START RuntimeModelSelectionFriendliAI // START RuntimeModelSelectionGoogle // START RuntimeModelSelectionNVIDIA // START RuntimeModelSelectionKubeAI // START RuntimeModelSelectionAzureOpenAI // START RuntimeModelSelectionOllama // START SinglePromptExample // START GroupedTaskExample +let response; +const myCollection = client.collections.use("DemoCollection"); + +// END RuntimeModelSelectionAnthropic // END RuntimeModelSelectionxAI // END WorkingWithImagesAnthropic // END WorkingWithImagesAWS // END WorkingWithImagesGoogle // END WorkingWithImagesOpenAI // END RuntimeModelSelectionAnyscale // END RuntimeModelSelectionMistral // END RuntimeModelSelectionOpenAI // END RuntimeModelSelectionAWS // END RuntimeModelSelectionCohere // END RuntimeModelSelectionDatabricks // END RuntimeModelSelectionFriendliAI // END RuntimeModelSelectionGoogle // END RuntimeModelSelectionNVIDIA // END RuntimeModelSelectionKubeAI // END RuntimeModelSelectionAzureOpenAI // END RuntimeModelSelectionOllama // END SinglePromptExample // END GroupedTaskExample + + +// START RuntimeModelSelectionAnthropic +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.anthropic({ + // These parameters are optional + // baseURL: "https://api.anthropic.com", + // model: "claude-3-opus-20240229", + // maxTokens: 512, + // temperature: 0.7, + // stopSequences: ["\n\n"], + // topP: 0.9, + // topK: 5, + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +); +// END RuntimeModelSelectionAnthropic +(async () => { +// START WorkingWithImagesAnthropic +const srcImgPath = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +const responseImg = await fetch(srcImgPath); +const image = await responseImg.arrayBuffer(); + +const base64String = arrayBufferToBase64(image); + +const prompt = { + // highlight-start + prompt: "Which movie is closest to the image in terms of atmosphere", + images: [base64String], // A list of base64 encoded strings of the image bytes + // imageProperties: ["img"], // Properties containing images in Weaviate + // highlight-end +} + +response = await myCollection.generate.nearText("Movies", { + // highlight-start + groupedTask: prompt, + // highlight-end + config: generativeParameters.anthropic({ + maxTokens: 1000 + }), +}, { + limit: 5, +}) + +// Print the source property and the generated response +for (const item of response.objects) { + console.log("Title property:", item.properties['title']) +} + +console.log("Grouped task result:", response.generative?.text) +// END WorkingWithImagesAnthropic +})(); +// START BasicGenerativeAnyscale +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.anyscale(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeAnyscale + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeAnyscaleCustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.anyscale({ + model: 'mistralai/Mixtral-8x7B-Instruct-v0.1' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeAnyscaleCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeAnyscale +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.anyscale({ + // These parameters are optional + // model: 'meta-llama/Llama-2-70b-chat-hf', + // temperature: 0.7, + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeAnyscale + +// START RuntimeModelSelectionAnyscale +response = myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.anthropic({ + // These parameters are optional + // baseURL: "https://api.anthropic.com", + // model: "claude-3-opus-20240229", + // maxTokens: 512, + // temperature: 0.7, + // stopSequences: ["\n\n"], + // topP: 0.9, + // topK: 5, + }), + // highlight-end + +}, { + limit: 2, +} + // Additional parameters not shown +) + +// END RuntimeModelSelectionAnyscale + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeAWSBedrock +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.aws({ + region: 'us-east-1', + service: 'bedrock', + model: 'cohere.command-r-plus-v1:0', + }), + // highlight-end +}) +// END BasicGenerativeAWSBedrock + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeAWSSagemaker +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.aws({ + region: 'us-east-1', + service: 'sagemaker', + endpoint: '' + }), + // highlight-end +}) +// END BasicGenerativeAWSSagemaker + +// START RuntimeModelSelectionAWS +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.aws({ + region: 'us-east-1', + service: 'bedrock', // You can also use sagemaker + model: 'cohere.command-r-plus-v1:0', + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +); +// END RuntimeModelSelectionAWS + +(async () => { +// START WorkingWithImagesAWS +const srcImgPath = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +const responseImg = await fetch(srcImgPath); +const image = await responseImg.arrayBuffer(); + +const base64String = arrayBufferToBase64(image); + +const prompt = { + // highlight-start + prompt: "Which movie is closest to the image in terms of atmosphere", + images: [base64String], // A list of base64 encoded strings of the image bytes + // imageProperties: ["img"], // Properties containing images in Weaviate + // highlight-end +} + +response = await myCollection.generate.nearText("Movies", { + // highlight-start + groupedTask: prompt, + // highlight-end + config: generativeParameters.aws({ + region: 'us-east-1', + service: 'bedrock', // You can also use sagemaker + model: 'cohere.command-r-plus-v1:0', + }), +}, { + limit: 5, +}) + +// Print the source property and the generated response +for (const item of response.objects) { + console.log("Title property:", item.properties['title']) +} + +console.log("Grouped task result:", response.generative?.text) +// END WorkingWithImagesAWS +})(); + +// Clean up + await client.collections.delete('DemoCollection'); + +// START BasicGenerativeCohere +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.cohere(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeCohere + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeCohereCustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.cohere({ + model: 'command-r-plus' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeCohereCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + + +// START FullGenerativeCohere +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.cohere({ + // These parameters are optional + model: 'command-r', + // temperature: 0.7, + // maxTokens: 500, + // k: 5, + // stopSequences: ['\n\n'], + // returnLikelihoods: 'GENERATION' + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeCohere + +// START RuntimeModelSelectionCohere +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.cohere({ + // These parameters are optional + // model: 'command-r', + // temperature: 0.7, + // maxTokens: 500, + // k: 5, + // stopSequences: ['\n\n'], + // returnLikelihoods: 'GENERATION' // coming soon + + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionCohere + + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeDatabricks // START FullGenerativeDatabricks +const databricksGenerativeEndpoint = process.env.DATABRICKS_VECTORIZER_ENDPOINT || ''; // If saved as an environment variable +// START BasicGenerativeDatabricks // END FullGenerativeDatabricks + +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.databricks({ + endpoint: databricksGenerativeEndpoint, // Required for Databricks + }), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeDatabricks + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeDatabricks +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.databricks({ + endpoint: databricksGenerativeEndpoint, // Required for Databricks + // These parameters are optional + // maxTokens: 500, + // temperature: 0.7, + // topP: 0.7, + // topK: 0.1 + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeDatabricks + +// START RuntimeModelSelectionDatabricks +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.databricks({ + // These parameters are optional + // maxTokens: 500, + // temperature: 0, + // topP: 0.7, + // topK: 0.1, + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionDatabricks + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeFriendliAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.friendliai(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeFriendliAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeFriendliAICustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.friendliai({ + model: 'meta-llama-3.1-70b-instruct' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeFriendliAICustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeFriendliAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.friendliai({ + model: 'meta-llama-3.1-70b-instruct', + maxTokens: 500, + temperature: 0.7, + baseURL: 'https://inference.friendli.ai' + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeFriendliAI + +// START RuntimeModelSelectionFriendliAI +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.friendliai({ + // These parameters are optional + // model: 'meta-llama-3.1-70b-instruct', + // maxTokens: 500, + // temperature: 0.7, + // baseURL: 'https://inference.friendli.ai' + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionFriendliAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START DedicatedGenerativeFriendliAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.friendliai({ + model: 'YOUR_ENDPOINT_ID', + }), + // highlight-end + // Additional parameters not shown +}); +// END DedicatedGenerativeFriendliAI + +// Clean up +await client.collections.delete('DemoCollection'); + + +// START BasicGenerativeGoogleVertex +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.google({ + projectId: '', // Required for Vertex AI + modelId: 'gemini-1.0-pro' + }), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeGoogleVertex + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeGoogleStudio +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.google({ + modelId: 'gemini-pro', + }), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeGoogleStudio + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeGoogle +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.google({ + projectId: '', // Required for Vertex AI + modelId: '', + apiEndpoint: '', + temperature: 0.7, + topK: 5, + topP: 0.9, + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeGoogle + +// START RuntimeModelSelectionGoogle +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.google({ + // These parameters are optional + // projectId: '', // Required for Vertex AI + // modelId: '', + // apiEndpoint: '', + // temperature: 0.7, + // topK: 5, + // topP: 0.9, + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +); +// END RuntimeModelSelectionGoogle + +(async () => { +// START WorkingWithImagesGoogle +const srcImgPath = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +const responseImg = await fetch(srcImgPath); +const image = await responseImg.arrayBuffer(); + +const base64String = arrayBufferToBase64(image); + +const prompt = { + // highlight-start + prompt: "Which movie is closest to the image in terms of atmosphere", + images: [base64String], // A list of base64 encoded strings of the image bytes + // imageProperties: ["img"], // Properties containing images in Weaviate + // highlight-end +} + +response = await myCollection.generate.nearText("Movies", { + // highlight-start + groupedTask: prompt, + // highlight-end + config: generativeParameters.google({ + maxTokens: 1000, + }), +}, { + limit: 5, +}) + +// Print the source property and the generated response +for (const item of response.objects) { + console.log("Title property:", item.properties['title']) +} + +console.log("Grouped task result:", response.generative?.text) +// END WorkingWithImagesGoogle +})(); +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeMistral +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.mistral(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeMistral + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeMistralCustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.mistral({ + model: 'mistral-large-latest' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeMistralCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeMistral +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.mistral({ + // These parameters are optional + // model: 'mistral-large', + // temperature: 0.7, + // maxTokens: 500 + }), + // highlight-end +}); +// END FullGenerativeMistral + +// START RuntimeModelSelectionMistral +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.mistral({ + // These parameters are optional + // model: 'mistral-large', + // temperature: 0.7, + // maxTokens: 0.7, + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionMistral + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeNVIDIA +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.nvidia(), + // highlight-end + // Additional parameters not shown +});// END BasicGenerativeNVIDIA + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeNVIDIACustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.nvidia({ + model: 'nvidia/llama-3.1-nemotron-70b-instruct' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeNVIDIACustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeNVIDIA +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.nvidia({ + // These parameters are optional + // model: 'nvidia/llama-3.1-nemotron-70b-instruct' + // baseURL: "https://integrate.api.nvidia.com/v1", + // temperature: 0.7, + // maxTokens: 1024 + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeNVIDIA + + +// START RuntimeModelSelectionNVIDIA +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.nvidia({ + // These parameters are optional + // baseURL: "https://integrate.api.nvidia.com/v1", + // model: 'nvidia/llama-3.1-nemotron-70b-instruct', + // temperature: 0.7, + // maxTokens: 1000, + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionNVIDIA + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeOctoAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.octoai(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeOctoAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeOctoAICustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.octoai({ + model: 'meta-llama-3-70b-instruct' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeOctoAICustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeOctoAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.octoai({ + model: 'meta-llama-3-70b-instruct', + maxTokens: 500, + temperature: 0.7, + baseURL: 'https://text.octoai.run' + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeOctoAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeOpenAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.openAI(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeOpenAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativeOpenAICustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.openAI({ + model: 'gpt-4-1106-preview', + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativeOpenAICustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeOpenAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.openAI({ + // These parameters are optional + // model: 'gpt-4', + // frequencyPenalty: 0, + // maxTokens: 500, + // presencePenalty: 0, + // temperature: 0.7, + // topP: 0.7, + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeOpenAI + +// START RuntimeModelSelectionOpenAI +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.openAI({ + // These parameters are optional + // model: 'gpt-4', + // frequencyPenalty: 0, + // maxTokens: 500, + // presencePenalty: 0, + // temperature: 0.7, + // topP: 0.7, + // baseURL: "", + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +); +// END RuntimeModelSelectionOpenAI + +(async () => { +// START WorkingWithImagesOpenAI +const srcImgPath = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Winter_forest_silver.jpg/960px-Winter_forest_silver.jpg" +const responseImg = await fetch(srcImgPath); +const image = await responseImg.arrayBuffer(); + +const base64String = arrayBufferToBase64(image); + +const prompt = { + // highlight-start + prompt: "Which movie is closest to the image in terms of atmosphere", + images: [base64String], // A list of base64 encoded strings of the image bytes + // imageProperties: ["img"], // Properties containing images in Weaviate + // highlight-end +} + +response = await myCollection.generate.nearText("Movies", { + // highlight-start + groupedTask: prompt, + // highlight-end + config: generativeParameters.openAI({ + maxTokens: 1000, + }), +}, { + limit: 5, +}) + +// Print the source property and the generated response +for (const item of response.objects) { + console.log("Title property:", item.properties['title']) +} + +console.log("Grouped task result:", response.generative?.text) +// END WorkingWithImagesOpenAI +})(); +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeKubeAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.openAI({ + // Setting the model and base_url is required + model: 'gpt-3.5-turbo', + baseURL: 'http://kubeai/openai', + // These parameters are optional + // frequencyPenalty: 0, + // maxTokens: 500, + // presencePenalty: 0, + // temperature: 0.7, + // topP: 0.7, + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeKubeAI + +// START RuntimeModelSelectionKubeAI +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.openAI({ + // Setting the model and baseURL is required + model: 'gpt-3.5-turbo', + baseURL: 'http://kubeai/openai', + // These parameters are optional + // frequencyPenalty: 0, + // maxTokens: 500, + // presencePenalty: 0, + // temperature: 0.7, + // topP: 0.7, + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionKubeAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeAzureOpenAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.azureOpenAI({ + resourceName: '', + deploymentId: '', + }), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeAzureOpenAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeAzureOpenAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.azureOpenAI({ + resourceName: '', + deploymentId: '', + // These parameters are optional + // frequencyPenalty: 0, + // maxTokens: 500, + // presencePenalty: 0, + // temperature: 0.7, + // topP: 0.7, + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeAzureOpenAI + +// START RuntimeModelSelectionAzureOpenAI +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.azureOpenAI({ + resourceName: '', + deploymentId: '', + // These parameters are optional + // frequencyPenalty: 0, + // maxTokens: 500, + // presencePenalty: 0, + // temperature: 0.7, + // topP: 0.7, + // baseURL: "", + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionAzureOpenAI +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativeOllama +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.ollama({ + apiEndpoint: 'http://host.docker.internal:11434', // If using Docker, use this to contact your local Ollama instance + model: 'llama3', // The model to use, e.g. 'phi3', or 'mistral', 'command-r-plus', 'gemma' + }), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativeOllama + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativeOllama +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.ollama({ + apiEndpoint: 'http://host.docker.internal:11434', // If using Docker, use this to contact your local Ollama instance + model: 'llama3', // The model to use, e.g. 'phi3', or 'mistral', 'command-r-plus', 'gemma' + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativeOllama + +// START RuntimeModelSelectionOllama +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.ollama({ + apiEndpoint: 'http://host.docker.internal:11434', // If using Docker, use this to contact your local Ollama instance + model: 'llama3', // The model to use, e.g. 'phi3', or 'mistral', 'command-r-plus', 'gemma' + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +) +// END RuntimeModelSelectionOllama + + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicGenerativexAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.xai(), + // highlight-end + // Additional parameters not shown +}); +// END BasicGenerativexAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START GenerativexAICustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.xai({ + model: 'grok-2-latest' + }), + // highlight-end + // Additional parameters not shown +}); +// END GenerativexAICustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullGenerativexAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + generative: weaviate.configure.generative.xai({ + // // These parameters are optional + // baseURL: 'https://api.x.ai/v1', + // model: 'grok-2-latest', + // maxTokens: 512, + // temperature: 0.7, + }), + // highlight-end + // Additional parameters not shown +}); +// END FullGenerativexAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START RuntimeModelSelectionxAI +response = await myCollection.generate.nearText("A holiday film", { + // highlight-start + groupedTask: "Write a tweet promoting these two movies", + config: generativeParameters.xai({ + // These parameters are optional + // baseURL: 'https://api.x.ai/v1', + // model: 'grok-2-latest', + // maxTokens: 512, + // temperature: 0.7, + }), + // highlight-end +}, { + limit: 2, +} + // Additional parameters not shown +); + +// END RuntimeModelSelectionxAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START SinglePromptExample // START GroupedTaskExample +let myCollection = client.collections.use('DemoCollection'); + +// START SinglePromptExample // END GroupedTaskExample +const singlePromptResults = await myCollection.generate.nearText('A holiday film', { + // highlight-start + singlePrompt: `Translate this into French: {title}`, + // highlight-end +}, { + limit: 2, +}); + +for (const obj of singlePromptResults.objects) { + console.log(obj.properties['title']); + console.log(`Generated output: ${obj.generative?.text}`); // Note that the generated output is per object +} +// END SinglePromptExample + +// START GroupedTaskExample +const groupedTaskResults = await myCollection.generate.nearText('A holiday film', { + // highlight-start + groupedTask: `Write a fun tweet to promote readers to check out these films.`, + // highlight-end +}, { + limit: 2, +}); + +console.log(`Generated output: ${groupedTaskResults.generative?.text}`); // Note that the generated output is per query +for (const obj of groupedTaskResults.objects) { + console.log(obj.properties['title']); +} +// END GroupedTaskExample + +client.close(); + +} +void main() \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.reranker.py b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.reranker.py new file mode 100644 index 000000000..e8faa923b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.reranker.py @@ -0,0 +1,191 @@ +import os + +# ================================ +# ===== INSTANTIATION-COMMON ===== +# ================================ + +import weaviate + +client = weaviate.connect_to_local( + headers={ + "X-OpenAI-Api-Key": os.environ["OPENAI_APIKEY"], + "X-Cohere-Api-Key": os.environ["COHERE_APIKEY"], + } +) + +# START RerankerTransformersBasic +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.transformers() + # highlight-end + # Additional parameters not shown +) +# END RerankerTransformersBasic + +# Clean up +client.collections.delete("DemoCollection") + +# START RerankerCohereBasic +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.cohere() + # highlight-end + # Additional parameters not shown +) +# END RerankerCohereBasic + +# Clean up +client.collections.delete("DemoCollection") + +# START RerankerCohereCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.cohere( + model="rerank-english-v3.0" + ) + # highlight-end + # Additional parameters not shown +) +# END RerankerCohereCustomModel + +# Clean up +client.collections.delete("DemoCollection") + +# START RerankerJinaAIBasic +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.jinaai() + # highlight-end + # Additional parameters not shown +) +# END RerankerJinaAIBasic + +# Clean up +client.collections.delete("DemoCollection") + +# START RerankerJinaAICustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.jinaai( + model="jina-reranker-v2-base-multilingual" + ) + # highlight-end + # Additional parameters not shown +) +# END RerankerJinaAICustomModel + +# Clean up +client.collections.delete("DemoCollection") + +# START RerankerNVIDIABasic +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.nvidia() + # highlight-end + # Additional parameters not shown +) +# END RerankerNVIDIABasic + +# Clean up +client.collections.delete("DemoCollection") + +# START RerankerNVIDIACustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.nvidia( + model="nvidia/llama-3.2-nv-rerankqa-1b-v2", + base_url="https://integrate.api.nvidia.com/v1", + ) + # highlight-end + # Additional parameters not shown +) +# END RerankerNVIDIACustomModel + +# Clean up +client.collections.delete("DemoCollection") + +# START RerankerVoyageAI +client.collections.create( + "DemoCollection", + # highlight-start + reranker_config=Configure.Reranker.voyageai( + # # This parameter is optional + # model="rerank-lite-1" + ) + # highlight-end + # Additional parameters not shown +) +# END RerankerVoyageAI + +source_objects = [ + {"title": "The Shawshank Redemption"}, + {"title": "The Godfather"}, + {"title": "The Dark Knight"}, + {"title": "Jingle All the Way"}, + {"title": "A Christmas Carol"}, +] + +collection = client.collections.use("DemoCollection") + +with collection.batch.fixed_size(batch_size=200) as batch: + for src_obj in source_objects: + weaviate_obj = { + "title": src_obj["title"], + } + + # highlight-start + # The model provider integration will automatically vectorize the object + batch.add_object( + properties=weaviate_obj, + # vector=vector # Optional, if you want to manually provide the vector + ) + # highlight-end + +# Check for failed objects +if len(collection.batch.failed_objects) > 0: + print(f"Failed to import {len(collection.batch.failed_objects)} objects") + for failed in collection.batch.failed_objects: + print(f"e.g. Failed to import object with error: {failed.message}") + +# START RerankerQueryExample +from weaviate.classes.query import Rerank + +collection = client.collections.use("DemoCollection") + +# highlight-start +response = collection.query.near_text( + query="A holiday film", # The model provider integration will automatically vectorize the query + limit=2, + rerank=Rerank( + prop="title", # The property to rerank on + query="A melodic holiday film" # If not provided, the original query will be used + ) +) +# highlight-end + +for obj in response.objects: + print(obj.properties["title"]) +# END RerankerQueryExample + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.reranker.ts b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.reranker.ts new file mode 100644 index 000000000..0a2cc29b0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.reranker.ts @@ -0,0 +1,117 @@ +import assert from 'assert'; + +// ================================ +// ===== INSTANTIATION-COMMON ===== +// ================================ +import weaviate from 'weaviate-client'; + +const client = await weaviate.connectToLocal({ + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY || '', + 'X-Cohere-Api-Key': process.env.COHERE_APIKEY || '', + }, +}); + +// START RerankerTransformersBasic +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.transformers(), + // highlight-end +}); +// END RerankerTransformersBasic + +// START RerankerCohereBasic +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.cohere(), + // highlight-end +}); +// END RerankerCohereBasic + +// START RerankerCohereCustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.cohere({ + model: 'rerank-english-v3.0', + }), + // highlight-end +}); +// END RerankerCohereCustomModel + +// START RerankerJinaAIBasic +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.jinaai(), + // highlight-end +}); +// END RerankerJinaAIBasic + +// START RerankerJinaAICustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.jinaai({ + model: 'jina-reranker-v2-base-multilingual', + }), + // highlight-end +}); +// END RerankerJinaAICustomModel + +// START RerankerNVIDIABasic +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.nvidia(), + // highlight-end +}); +// END RerankerNVIDIABasic + +// START RerankerNVIDIACustomModel +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.nvidia({ + model: "nvidia/llama-3.2-nv-rerankqa-1b-v2", + baseURL: "https://integrate.api.nvidia.com/v1" + }), + // highlight-end +}); +// END RerankerNVIDIACustomModel + +// START RerankerVoyageAI +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + reranker: weaviate.configure.reranker.voyageAI({ + model: 'rerank-lite-1', + }), + // highlight-end +}); +// END RerankerVoyageAI + +// START RerankerQueryExample +let myCollection = client.collections.use('DemoCollection'); + +const results = await myCollection.query.nearText( + ['A holiday film'], + // highlight-start + { + limit: 2, + rerank: { + property: 'title', // The property to rerank on + query: 'A melodic holiday film' // If not provided, the original query will be used + } + } + // highlight-end +); + +for (const obj of results.objects) { + console.log(obj.properties['title']); +} +// END RerankerQueryExample + +client.close(); diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.vectorizer.py b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.vectorizer.py new file mode 100644 index 000000000..5a8308a56 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.vectorizer.py @@ -0,0 +1,1768 @@ +import os + +# ================================ +# ===== INSTANTIATION-COMMON ===== +# ================================ + +import weaviate + +client = weaviate.connect_to_local( + headers={ + "X-OpenAI-Api-Key": os.environ["OPENAI_APIKEY"], + "X-Cohere-Api-Key": os.environ["COHERE_APIKEY"], + } +) + +# START BasicVectorizerAWSBedrock +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_aws( + name="title_vector", + region="us-east-1", + source_properties=["title"], + service="bedrock", + model="titan-embed-text-v2:0", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerAWSBedrock + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerAWSSagemaker +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_aws( + name="title_vector", + region="us-east-1", + source_properties=["title"], + service="sagemaker", + endpoint="", # e.g., "tei-xxx" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerAWSSagemaker + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerAWS +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_aws( + name="title_vector", + region="us-east-1", + source_properties=["title"], + service="bedrock", # `bedrock` or `sagemaker` + model="titan-embed-text-v2:0", # If using `bedrock`, this is required + # endpoint="", # If using `sagemaker`, this is required + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerAWS + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerCohere +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_cohere( + name="title_vector", + source_properties=["title"] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerCohere + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerCohereCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_cohere( + name="title_vector", + source_properties=["title"], + model="embed-multilingual-light-v3.0" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END VectorizerCohereCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerCohere +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_cohere( + name="title_vector", + source_properties=["title"], + # Further options + # model="embed-multilingual-v3.0", + # truncate="END", # "NONE", "START" or "END" + # base_url="" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerCohere + +# clean up +client.collections.delete("DemoCollection") + +# START BasicMMVectorizerCohere +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_cohere( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicMMVectorizerCohere + +# clean up +client.collections.delete("DemoCollection") + +# START MMVectorizerCohereCustomModel +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_cohere( + name="title_vector", + model="embed-multilingual-v3.0", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END MMVectorizerCohereCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullMMVectorizerCohere +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_cohere( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + # Further options + # model="embed-multilingual-v3.0", + # truncate="END", # "NONE", "START" or "END" + # base_url="" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullMMVectorizerCohere + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerGoogleVertex +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_palm( + name="title_vector", + source_properties=["title"], + project_id="", + # (Optional) To manually set the model ID + model_id="gemini-embedding-001" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerGoogleVertex + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerGoogleStudio +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_palm( + name="title_vector", + source_properties=["title"], + project_id="", + # (Optional) To manually set the model ID + model_id="gemini-embedding-001" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerGoogleStudio + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerGoogle +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_palm( + name="title_vector", + source_properties=["title"], + project_id="", # Required for Vertex AI + # # Further options + # model_id="", + # api_endpoint="", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerGoogle + +# clean up +client.collections.delete("DemoCollection") + +# START BasicMMVectorizerGoogleVertex +from weaviate.classes.config import Property, DataType, Configure, Multi2VecField + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_palm( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields, video_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + # video_fields=[], + project_id="", # Required for Vertex AI + location="", # Required for Vertex AI + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicMMVectorizerGoogleVertex + +# clean up +client.collections.delete("DemoCollection") + +# START FullMMVectorizerGoogleVertex +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="description", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_palm( + name="title_vector", + project_id="", # Required for Vertex AI + location="us-central1", + # model_id="", + # dimensions=512, + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + # video_fields=[] + # video_interval_seconds=20 + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullMMVectorizerGoogleVertex + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerHuggingFace +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_huggingface( + name="title_vector", + source_properties=["title"], + model="sentence-transformers/all-MiniLM-L6-v2", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerHuggingFace + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerHuggingFace +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_huggingface( + name="title_vector", + source_properties=["title"], + # NOTE: Use only one of (`model`), (`passage_model` and `query_model`), or (`endpoint_url`) + model="sentence-transformers/all-MiniLM-L6-v2", + # passage_model="sentence-transformers/facebook-dpr-ctx_encoder-single-nq-base", # Required if using `query_model` + # query_model="sentence-transformers/facebook-dpr-question_encoder-single-nq-base", # Required if using `passage_model` + # endpoint_url="", + # + # wait_for_model=True, + # use_cache=True, + # use_gpu=True, + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerHuggingFace + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerJinaAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_jinaai( + name="title_vector", + source_properties=["title"] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerJinaAI + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerJinaCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_jinaai( + name="title_vector", + source_properties=["title"], + model="jina-embeddings-v3", + ) + ], + # highlight-end +) +# END VectorizerJinaCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerJinaAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_jinaai( + name="title_vector", + source_properties=["title"], + # Further options + # model="jina-embeddings-v3", + # dimensions=512, # e.g. 1024, 256, 64 (only applicable for some models) + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerJinaAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicMMVectorizerJinaAI +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_jinaai( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicMMVectorizerJinaAI + +# clean up +client.collections.delete("DemoCollection") + +# START MMVectorizerJinaCustomModel +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_jinaai( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + model="jina-clip-v2", + ) + ], + # highlight-end +) +# END MMVectorizerJinaCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullMMVectorizerJinaAI +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_jinaai( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + # Further options + # model="jina-clip-v2", + # dimensions=512, # Only applicable for some models (e.g. `jina-clip-v2`) + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullMMVectorizerJinaAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicColBERTVectorizerJinaAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.MultiVectors.text2vec_jinaai( + name="title_vector", + source_properties=["title"] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicColBERTVectorizerJinaAI + +# clean up +client.collections.delete("DemoCollection") + +# START ColBERTVectorizerJinaCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.MultiVectors.text2vec_jinaai( + name="title_vector", + source_properties=["title"], + model="jina-colbert-v2", + ) + ], + # highlight-end +) +# END ColBERTVectorizerJinaCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullColBERTVectorizerJinaAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.MultiVectors.text2vec_jinaai( + name="title_vector", + source_properties=["title"], + # Further options + # model="jina-colbert-v2", + # dimensions=64, # e.g. 128, 64 (only applicable for some models) + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullColBERTVectorizerJinaAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerMistral +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_mistral( + name="title_vector", + source_properties=["title"], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerMistral + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerMistral +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_mistral( + name="title_vector", + source_properties=["title"], + model="mistral-embed" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerMistral + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerNVIDIA +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_nvidia( + name="title_vector", + source_properties=["title"], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerNVIDIA + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerNVIDIACustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_nvidia( + name="title_vector", + source_properties=["title"], + model="nvidia/nv-embed-v1" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END VectorizerNVIDIACustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerNVIDIA +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_nvidia( + name="title_vector", + source_properties=["title"], + model="nvidia/nv-embed-v1", + base_url="https://integrate.api.nvidia.com/v1", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerNVIDIA + +# clean up +client.collections.delete("DemoCollection") + +# START BasicMMVectorizerNVIDIA +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_nvidia( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicMMVectorizerNVIDIA + +# clean up +client.collections.delete("DemoCollection") + +# START MMVectorizerNVIDIACustomModel +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_nvidia( + name="title_vector", + model="nvidia/nvclip", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END MMVectorizerNVIDIACustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullMMVectorizerNVIDIA +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_nvidia( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + # Further options + # model="nvidia/nvclip", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullMMVectorizerNVIDIA + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerOctoAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + vector_config=[ + Configure.Vectors.text2vec_octoai( + name="title_vector", + source_properties=["title"] + ) + ], + # Additional parameters not shown +) +# END BasicVectorizerOctoAI + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerOctoAICustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + vector_config=[ + Configure.Vectors.text2vec_octoai( + name="title_vector", + source_properties=["title"], + model="thenlper/gte-large" + ) + ], + # Additional parameters not shown +) +# END VectorizerOctoAICustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerOctoAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + vector_config=[ + Configure.Vectors.text2vec_octoai( + name="title_vector", + source_properties=["title"], + # # Further options + # model="thenlper/gte-large", + # vectorize_collection_name=True + # base_url="https://text.octoai.run", + ) + ], +) +# END FullVectorizerOctoAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_openai( + name="title_vector", + source_properties=["title"] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerOpenAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerDatabricks +import os +from weaviate.classes.config import Configure + +databricks_vectorizer_endpoint = os.getenv("DATABRICKS_VECTORIZER_ENDPOINT") # If saved as an environment variable + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_databricks( + endpoint=databricks_vectorizer_endpoint, # Required for Databricks + name="title_vector", + source_properties=["title"], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerDatabricks + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerOpenAICustomModelV3 +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_openai( + name="title_vector", + source_properties=["title"], + # If using `text-embedding-3` model family + model="text-embedding-3-large", + dimensions=1024 + ) + ], + # highlight-end + # Additional parameters not shown +) +# END VectorizerOpenAICustomModelV3 + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerOpenAICustomModelLegacy +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_openai( + name="title_vector", + source_properties=["title"], + # If using older model family e.g. `ada` + model="ada", + model_version="002", + type_="text" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END VectorizerOpenAICustomModelLegacy + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_openai( + name="title_vector", + source_properties=["title"], + # # Further options + # model="text-embedding-3-large", + # model_version="002", # Parameter only applicable for `ada` model family and older + # dimensions=1024, # Parameter only applicable for `v3` model family and newer + # type="text", + # base_url="", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerOpenAI + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerKubeAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_openai( + name="title_vector", + source_properties=["title"], + # Further options + model="text-embedding-ada-002", + base_url="http://kubeai/openai", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerKubeAI + +# clean up +client.collections.delete("DemoCollection") + + +# START BasicVectorizerAzureOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_azure_openai( + name="title_vector", + source_properties=["title"], + resource_name="", + deployment_id="" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerAzureOpenAI + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerAzureOpenAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_azure_openai( + name="title_vector", + source_properties=["title"], + resource_name="", + deployment_id="", + # # Further options + # base_url="", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerAzureOpenAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerVoyageAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_voyageai( + name="title_vector", + source_properties=["title"] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerVoyageAI + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerVoyageAICustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_voyageai( + name="title_vector", + source_properties=["title"], + model="voyage-3-lite" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END VectorizerVoyageAICustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerVoyageAI +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_voyageai( + name="title_vector", + source_properties=["title"], + # Further options + # model="voyage-large-2" + # base_url="", + # truncate=True, + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerVoyageAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicMMVectorizerVoyageAI +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_voyageai( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicMMVectorizerVoyageAI + +# clean up +client.collections.delete("DemoCollection") + +# START MMVectorizerVoyageAICustomModel +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_voyageai( + name="title_vector", + model="voyage-multimodal-3", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END MMVectorizerVoyageAICustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START FullMMVectorizerVoyageAI +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + vector_config=[ + Configure.Vectors.multi2vec_voyageai( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + # Further options + # model="voyage-multimodal-3", + # truncation="true", # or "false", + # output_encoding="base64", # or "null" + # base_url="" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullMMVectorizerVoyageAI + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerWeaviate +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_weaviate( + name="title_vector", + source_properties=["title"] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerWeaviate + +# clean up +client.collections.delete("DemoCollection") + +# START VectorizerWeaviateCustomModel +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_weaviate( + name="title_vector", + source_properties=["title"], + model="Snowflake/snowflake-arctic-embed-l-v2.0" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END VectorizerWeaviateCustomModel + +# clean up +client.collections.delete("DemoCollection") + +# START SnowflakeArcticEmbedMV15 +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_weaviate( + name="title_vector", + source_properties=["title"], + model="Snowflake/snowflake-arctic-embed-m-v1.5", + # Further options + # dimensions=256 + # base_url="", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END SnowflakeArcticEmbedMV15 + +# clean up +client.collections.delete("DemoCollection") + +# START SnowflakeArcticEmbedLV20 +from weaviate.classes.config import Configure, Property, DataType + +client.collections.create( + "DemoCollection", + # highlight-start + properties=[ + Property(name="title", data_type=DataType.TEXT), + ], + vector_config=[ + Configure.Vectors.text2vec_weaviate( + name="title_vector", + source_properties=["title"], + model="Snowflake/snowflake-arctic-embed-l-v2.0", + # Further options + # dimensions=256 + # base_url="", + ) + ], + # highlight-end + # Additional parameters not shown +) +# END SnowflakeArcticEmbedLV20 + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerTransformers +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_transformers( + name="title_vector", + source_properties=["title"] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerTransformers + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerTransformers +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_transformers( + name="title_vector", + source_properties=["title"], + # Further options + pooling_strategy="masked_mean", + inference_url="", # For when using multiple inference containers + # passage_inference_url="", # For when using DPR models + # query_inference_url="", # For when using DPR models + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerTransformers + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerOllama +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_ollama( + name="title_vector", + source_properties=["title"], + api_endpoint="http://host.docker.internal:11434", # If using Docker, use this to contact your local Ollama instance + model="snowflake-arctic-embed", # The model to use, e.g. "nomic-embed-text" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerOllama + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerOllama +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_ollama( + name="title_vector", + source_properties=["title"], + # Further options + api_endpoint="http://host.docker.internal:11434", # If using Docker, use this to contact your local Ollama instance + model="snowflake-arctic-embed", # The model to use, e.g. "nomic-embed-text" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerOllama + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerGPT4All +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_gpt4all( + name="title_vector", + source_properties=["title"], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerGPT4All + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerGPT4All +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_gpt4all( + name="title_vector", + source_properties=["title"], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerGPT4All + +# clean up +client.collections.delete("DemoCollection") + +# START BasicVectorizerModel2Vec +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_model2vec( + name="title_vector", + source_properties=["title"], + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicVectorizerModel2Vec + +# clean up +client.collections.delete("DemoCollection") + +# START FullVectorizerModel2Vec +from weaviate.classes.config import Configure + +client.collections.create( + "DemoCollection", + # highlight-start + vector_config=[ + Configure.Vectors.text2vec_model2vec( + name="title_vector", + source_properties=["title"], + inference_url="", # Default - configuration defined through container, e.g. Docker compose file + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullVectorizerModel2Vec + +# clean up +client.collections.delete("DemoCollection") + +# START BasicMMVectorizerCLIP +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + # highlight-start + vector_config=[ + Configure.Vectors.multi2vec_clip( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields, video_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicMMVectorizerCLIP + +# clean up +client.collections.delete("DemoCollection") + +# START FullMMVectorizerCLIP +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + # highlight-start + vector_config=[ + Configure.Vectors.multi2vec_clip( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields, video_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + # inference_url="" + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullMMVectorizerCLIP + +# clean up +client.collections.delete("DemoCollection") + +# START BasicMMVectorizerBind +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + ], + # highlight-start + vector_config=[ + Configure.Vectors.multi2vec_bind( + name="title_vector", + # Define the fields to be used for the vectorization - using image_fields, text_fields, video_fields + image_fields=[ + Multi2VecField(name="poster", weight=0.9) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ] + ) + ], + # highlight-end + # Additional parameters not shown +) +# END BasicMMVectorizerBind + +# clean up +client.collections.delete("DemoCollection") + +# START FullMMVectorizerBind +from weaviate.classes.config import Configure, DataType, Multi2VecField, Property + +client.collections.create( + "DemoCollection", + properties=[ + Property(name="title", data_type=DataType.TEXT), + Property(name="poster", data_type=DataType.BLOB), + Property(name="sound", data_type=DataType.BLOB), + Property(name="video", data_type=DataType.BLOB), + ], + # highlight-start + vector_config=[ + Configure.Vectors.multi2vec_bind( + name="title_vector", + # Define the fields to be used for the vectorization + image_fields=[ + Multi2VecField(name="poster", weight=0.7) + ], + text_fields=[ + Multi2VecField(name="title", weight=0.1) + ], + audio_fields=[ + Multi2VecField(name="sound", weight=0.1) + ], + video_fields=[ + Multi2VecField(name="video", weight=0.1) + ], + # depth, IMU and thermal fields are also available + ) + ], + # highlight-end + # Additional parameters not shown +) +# END FullMMVectorizerBind + +# clean up +client.collections.delete("DemoCollection") + +# START BatchImportExample +source_objects = [ + {"title": "The Shawshank Redemption", "description": "A wrongfully imprisoned man forms an inspiring friendship while finding hope and redemption in the darkest of places."}, + {"title": "The Godfather", "description": "A powerful mafia family struggles to balance loyalty, power, and betrayal in this iconic crime saga."}, + {"title": "The Dark Knight", "description": "Batman faces his greatest challenge as he battles the chaos unleashed by the Joker in Gotham City."}, + {"title": "Jingle All the Way", "description": "A desperate father goes to hilarious lengths to secure the season's hottest toy for his son on Christmas Eve."}, + {"title": "A Christmas Carol", "description": "A miserly old man is transformed after being visited by three ghosts on Christmas Eve in this timeless tale of redemption."} +] + +collection = client.collections.use("DemoCollection") + +with collection.batch.fixed_size(batch_size=200) as batch: + for src_obj in source_objects: + # highlight-start + # The model provider integration will automatically vectorize the object + batch.add_object( + properties={ + "title": src_obj["title"], + "description": src_obj["description"], + }, + # vector=vector # Optionally provide a pre-obtained vector + ) + # highlight-end + if batch.number_errors > 10: + print("Batch import stopped due to excessive errors.") + break + +failed_objects = collection.batch.failed_objects +if failed_objects: + print(f"Number of failed imports: {len(failed_objects)}") + print(f"First failed object: {failed_objects[0]}") +# END BatchImportExample + +# START NearImageExample +def url_to_base64(url): + import requests + import base64 + + image_response = requests.get(url) + content = image_response.content + return base64.b64encode(content).decode("utf-8") + + +# END NearImageExample + + +src_img_path = "https://github.com/weaviate-tutorials/edu-datasets/blob/main/img/International_Space_Station_after_undocking_of_STS-132.jpg?raw=true" + +for i in range(len(source_objects)): + source_objects[i]["poster_path"] = src_img_path + +# START MMBatchImportExample +collection = client.collections.use("DemoCollection") + +with collection.batch.fixed_size(batch_size=200) as batch: + for src_obj in source_objects: + poster_b64 = url_to_base64(src_obj["poster_path"]) + weaviate_obj = { + "title": src_obj["title"], + "poster": poster_b64 # Add the image in base64 encoding + } + + # highlight-start + # The model provider integration will automatically vectorize the object + batch.add_object( + properties=weaviate_obj, + # vector=vector # Optionally provide a pre-obtained vector + ) + # highlight-end +# END MMBatchImportExample + +# START NearTextExample +collection = client.collections.use("DemoCollection") + +# highlight-start +response = collection.query.near_text( + query="A holiday film", # The model provider integration will automatically vectorize the query + limit=2 +) +# highlight-end + +for obj in response.objects: + print(obj.properties["title"]) +# END NearTextExample + + +# START HybridExample +collection = client.collections.use("DemoCollection") + +# highlight-start +response = collection.query.hybrid( + query="A holiday film", # The model provider integration will automatically vectorize the query + limit=2 +) +# highlight-end + +for obj in response.objects: + print(obj.properties["title"]) +# END HybridExample + + +# START NearImageExample +collection = client.collections.use("DemoCollection") + +# highlight-start +query_b64 = url_to_base64(src_img_path) + +response = collection.query.near_image( + near_image=query_b64, + limit=2, + return_properties=["title", "release_date", "tmdb_id", "poster"] # To include the poster property in the response (`blob` properties are not returned by default) +) +# highlight-end + +for obj in response.objects: + print(obj.properties["title"]) +# END NearImageExample + +client.close() diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.vectorizer.ts b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.vectorizer.ts new file mode 100644 index 000000000..7ce4ca20c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/_includes/provider.vectorizer.ts @@ -0,0 +1,1917 @@ +import assert from 'assert'; + +// ================================ +// ===== INSTANTIATION-COMMON ===== +// ================================ +import weaviate from 'weaviate-client'; + +async function main() { + + +const client = await weaviate.connectToLocal({ + headers: { + 'X-OpenAI-Api-Key': process.env.OPENAI_APIKEY || '', + 'X-Cohere-Api-Key': process.env.COHERE_APIKEY || '', + }, +}); + +// START BasicVectorizerAWSBedrock +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecAWS({ + name: 'title_vector', + sourceProperties: ['title'], + region: 'us-east-1', + service: 'bedrock', // default service + model: 'amazon.titan-embed-text-v1', + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerAWSBedrock + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerAWSSagemaker +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecAWS({ + name: 'title_vector', + sourceProperties: ['title'], + region: 'us-east-1', + service: 'sagemaker', + model: '', + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerAWSSagemaker + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerAWS +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecAWS({ + name: 'title_vector', + sourceProperties: ['title'], + region: 'us-east-1', + service: 'bedrock', + model: 'cohere.embed-multilingual-v3', // If using Bedrock + // endpoint: '', // If using SageMaker + // vectorizeClassName: true, + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerAWS + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerCohere +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecCohere({ + name: 'title_vector', + sourceProperties: ['title'], + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerCohere + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerCohereCustomModel +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + vectorizers: [ + weaviate.configure.vectors.text2VecCohere({ + name: 'title_vector', + sourceProperties: ['title'], + // highlight-start + model: 'embed-multilingual-light-v3.0' + // highlight-end + }), + ], + // Additional parameters not shown +}); +// END VectorizerCohereCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerCohere +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecCohere({ + name: 'title_vector', + sourceProperties: ['title'], + // Further options + // model: 'embed-multilingual-v3.0', + // truncate: 'END', + // baseURL: '', + // vectorizeClassName: true, + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerCohere + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicMMVectorizerCohere +await client.collections.create({ + name: "DemoCollection", + // highlight-start + properties: [ + { + name: 'title', + dataType: weaviate.configure.dataType.TEXT, + }, + { + name: 'poster', + dataType: weaviate.configure.dataType.BLOB, + }, + ], + vectorizers: [ + weaviate.configure.vectors.multi2VecCohere({ + name: "title_vector", + // Define the fields to be used for the vectorization - using imageFields, textFields + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }] + })], + // highlight-end + // Additional parameters not shown +}) +// END BasicMMVectorizerCohere + +// Clean up +await client.collections.delete('DemoCollection'); + +// START MMVectorizerCohereCustomModel +await client.collections.create({ + name: "DemoCollection", + // highlight-start + properties: [ + { + name: 'title', + dataType: weaviate.configure.dataType.TEXT, + }, + { + name: 'poster', + dataType: weaviate.configure.dataType.BLOB, + }, + ], + vectorizers: [ + weaviate.configure.vectors.multi2VecCohere({ + name: "title_vector", + model: "embed-multilingual-v3.0", + // Define the fields to be used for the vectorization - using imageFields, textFields + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }] + })], + // highlight-end + // Additional parameters not shown +}) +// END MMVectorizerCohereCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullMMVectorizerCohere +await client.collections.create({ + name: "DemoCollection", + // highlight-start + properties: [ + { + name: 'title', + dataType: weaviate.configure.dataType.TEXT, + }, + { + name: 'poster', + dataType: weaviate.configure.dataType.BLOB, + }, + ], + vectorizers: [ + weaviate.configure.vectors.multi2VecCohere({ + name: "title_vector", + // Define the fields to be used for the vectorization - using imageFields, textFields + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + // Further options + // model: "embed-multilingual-v3.0", + // truncate: "END", // "NONE", "START" or "END" + // baseURL: "" + })], + // highlight-end + // Additional parameters not shown +}) +// END FullMMVectorizerCohere + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerDatabricks +const databricksVectorizerEndpoint = process.env.DATABRICKS_VECTORIZER_ENDPOINT || ''; // If saved as an environment variable + +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecDatabricks({ + endpoint: databricksVectorizerEndpoint, // Required for Databricks + name: 'title_vector', + sourceProperties: ['title'], + }) + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerDatabricks + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerGoogleVertex +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecGoogle({ + name: 'title_vector', + sourceProperties: ['title'], + projectId: '', + // (Optional) To manually set the model ID + modelId: 'gemini-embedding-001' + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerGoogleVertex + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerGoogleStudio +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecGoogle({ + name: 'title_vector', + sourceProperties: ['title'], + // (Optional) To manually set the model ID + modelId: 'gemini-embedding-001' + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerGoogleStudio + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerGoogleStudio +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecGoogle({ + name: 'title_vector', + sourceProperties: ['title'], + projectId: '', // Required for Vertex AI + // modelId: '', + // apiEndpoint: '', + // vectorizeClassName: false, + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerGoogleStudio + +// START BasicMMVectorizerGoogleVertex +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecGoogle({ + name: 'title_vector', + location: '', + projectId: '', + imageFields: [ + { + name: 'poster', + weight: 0.9, + }, + ], + textFields: [ + { + name: 'title', + weight: 0.1, + }, + ], + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicMMVectorizerGoogleVertex + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullMMVectorizerGoogleVertex +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'description', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecGoogle({ + name: 'title_vector', + projectId: '', + modelId: '', + location: '', + dimensions: 512, + imageFields: [ + { + name: 'poster', + weight: 0.9, + }, + ], + textFields: [ + { + name: 'title', + weight: 0.1, + }, + ], + // videoFields: [] + // video_interval_seconds: 20 + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullMMVectorizerGoogleVertex + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerHuggingFace +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecHuggingFace({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'sentence-transformers/all-MiniLM-L6-v2', + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerHuggingFace + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerHuggingFace +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecHuggingFace({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'sentence-transformers/all-MiniLM-L6-v2', + // endpointURL: , + // passageModel: 'sentence-transformers/facebook-dpr-ctx_encoder-single-nq-base', // Required if using `query_model` + // queryModel: 'sentence-transformers/facebook-dpr-question_encoder-single-nq-base', // Required if using `passage_model` + // waitForModel: true, + // useCache: true, + // useGPU: true, + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerHuggingFace + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerJinaAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecJinaAI({ + name: 'title_vector', + sourceProperties: ['title'], + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerJinaAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerJinaCustomModel +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecJinaAI({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'jina-embeddings-v3' + }), + ], + // highlight-end +}); +// END VectorizerJinaCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerJinaAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecJinaAI({ + name: 'title_vector', + sourceProperties: ['title'], + // model: 'jina-embeddings-v3-small-en' + // dimensions: 512, // e.g. 1024, 256, 64 Support for this parameter is coming soon (Only applicable for some models) + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerJinaAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicMMVectorizerJinaAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecJinaAI({ + name: 'title_vector', + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }] + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicMMVectorizerJinaAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START MMVectorizerJinaCustomModel +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecJinaAI({ + name: 'title_vector', + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + model: "jina-clip-v2" + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END MMVectorizerJinaCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullMMVectorizerJinaAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecJinaAI({ + name: 'title_vector', + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + // Further options + // model:"jina-clip-v2", + + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullMMVectorizerJinaAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicColBERTVectorizerJinaAI +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.multiVectors.text2VecJinaAI({ + name: 'title_vector', + sourceProperties: ['title'], + }) + ] +}) +// END BasicColBERTVectorizerJinaAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START ColBERTVectorizerJinaCustomModel +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.multiVectors.text2VecJinaAI({ + name: 'title_vector', + sourceProperties: ['title'], + model: "jina-colbert-v2", + }) + ] +}) +// END ColBERTVectorizerJinaCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullColBERTVectorizerJinaAI +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.multiVectors.text2VecJinaAI({ + name: 'title_vector', + sourceProperties: ['title'], + // Further options + // model: "jina-colbert-v2", + // dimensions: 64, // e.g. 128, 64 (only applicable for some models) + }) + ] +}) +// END FullColBERTVectorizerJinaAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerMistral +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecMistral({ + name: 'title_vector', + sourceProperties: ['title'], + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerMistral + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerMistral +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecMistral({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'mistral-embed' + }, + ), + ], + // highlight-end + // Additional parameters not shown +});// END FullVectorizerMistral + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerNVIDIA +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.vectors.text2VecNvidia({ + name: 'title_vector', + sourceProperties: ['title'], + }) + ], + // Additional parameters not shown +}) +// END BasicVectorizerNVIDIA + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerNVIDIACustomModel +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.vectors.text2VecNvidia({ + name: 'title_vector', + sourceProperties: ['title'], + model: "nvidia/nv-embed-v1" + }) + ], + // Additional parameters not shown +}) +// END VectorizerNVIDIACustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerNVIDIA +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.vectors.text2VecNvidia({ + name: 'title_vector', + sourceProperties: ['title'], + model: "nvidia/nv-embed-v1", + baseURL: "https://integrate.api.nvidia.com/v1" + }) + ], + // Additional parameters not shown +}) +// END FullVectorizerNVIDIA + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicMMVectorizerNVIDIA +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.vectors.multi2VecNvidia({ + name: 'title_vector', + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + }) + ], + // Additional parameters not shown +}) +// END BasicMMVectorizerNVIDIA + +// Clean up +await client.collections.delete('DemoCollection'); + +// START MMVectorizerNVIDIACustomModel +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.vectors.multi2VecNvidia({ + name: 'title_vector', + model: "nvidia/nv-embed-v1", + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + }) + ], + // Additional parameters not shown +}) +// END MMVectorizerNVIDIACustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullMMVectorizerNVIDIA +await client.collections.create({ + name: 'DemoCollection', + vectorizers: [ + weaviate.configure.vectors.multi2VecNvidia({ + name: 'title_vector', + model: "nvidia/nv-embed-v1", + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + // Further options + }) + ], + // Additional parameters not shown +}) +// END FullMMVectorizerNVIDIA + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerOctoAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOctoAI({ + name: 'title_vector', + sourceProperties: ['title'], + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); // END BasicVectorizerOctoAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerOctoAICustomModel +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOctoAI({ + name: 'title_vector', + sourceProperties: ['title'], + model: "thenlper/gte-large", + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END VectorizerOctoAICustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerOctoAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOctoAI({ + name: 'title_vector', + sourceProperties: ['title'], + // model: "thenlper/gte-large", + // vectorizeCollectionName: true, + // baseURL: "https://text.octoai.run", + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerOctoAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerOpenAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOpenAI({ + name: 'title_vector', + sourceProperties: ['title'], + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerOpenAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerOpenAICustomModelV3 +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOpenAI({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'text-embedding-3-large', + dimensions: 1024 + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END VectorizerOpenAICustomModelV3 + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerOpenAICustomModelLegacy +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOpenAI({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'ada', + modelVersion: '002', + type: 'text' + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END VectorizerOpenAICustomModelLegacy + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerOpenAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOpenAI( + { + name: 'title_vector', + sourceProperties: ['title'], + // Further options + model: 'text-embedding-3-large', + // modelVersion: "002", // Parameter only applicable for `ada` model family and older + // dimensions: 1024, // Parameter only applicable for `v3` model family and newer + // type: 'text', + // baseURL: '', + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerOpenAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerKubeAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOpenAI( + { + name: 'title_vector', + sourceProperties: ['title'], + model: 'text-embedding-ada-002', + baseURL: 'http://kubeai/openai', + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerKubeAI + +// Clean up +await client.collections.delete('DemoCollection'); + + +// START BasicVectorizerAzureOpenAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecAzureOpenAI({ + name: 'title_vector', + sourceProperties: ['title'], + resourceName: '', + deploymentId: '', + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerAzureOpenAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerAzureOpenAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecAzureOpenAI({ + name: 'title_vector', + sourceProperties: ['title'], + resourceName: '', + deploymentId: '', + // Further options + // baseURL: '' + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerAzureOpenAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerVoyageAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecVoyageAI({ + name: 'title_vector', + sourceProperties: ['title'], + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerVoyageAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerVoyageAICustomModel +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecVoyageAI({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'voyage-3-lite', + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END VectorizerVoyageAICustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerVoyageAI +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecVoyageAI({ + name: 'title_vector', + sourceProperties: ['title'], + // Further options + // model: 'voyage-large-2', + // baseURL: '', + // truncate: true + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerVoyageAI + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicMMVectorizerVoyageAI +await client.collections.create({ + name: "DemoCollection", + // highlight-start + properties: [ + { + name: 'title', + dataType: weaviate.configure.dataType.TEXT, + }, + { + name: 'poster', + dataType: weaviate.configure.dataType.BLOB, + }, + ], + vectorizers: [ + weaviate.configure.vectors.multi2VecVoyageAI({ + name: "title_vector", + // Define the fields to be used for the vectorization - using imageFields, textFields + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }] + })], + // highlight-end + // Additional parameters not shown +})// END BasicMMVectorizerVoyageAI + + +// Clean up +await client.collections.delete('DemoCollection'); + +// START MMVectorizerVoyageAICustomModel +await client.collections.create({ + name: "DemoCollection", + // highlight-start + properties: [ + { + name: 'title', + dataType: weaviate.configure.dataType.TEXT, + }, + { + name: 'poster', + dataType: weaviate.configure.dataType.BLOB, + }, + ], + vectorizers: [ + weaviate.configure.vectors.multi2VecVoyageAI({ + name: "title_vector", + // Define the fields to be used for the vectorization - using imageFields, textFields + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + model: "voyage-multimodal-3", + })], + // highlight-end + // Additional parameters not shown +}) +// END MMVectorizerVoyageAICustomModel + + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullMMVectorizerVoyageAI +await client.collections.create({ + name: "DemoCollection", + // highlight-start + properties: [ + { + name: 'title', + dataType: weaviate.configure.dataType.TEXT, + }, + { + name: 'poster', + dataType: weaviate.configure.dataType.BLOB, + }, + ], + vectorizers: [ + weaviate.configure.vectors.multi2VecVoyageAI({ + name: "title_vector", + // Define the fields to be used for the vectorization - using imageFields, textFields + imageFields: [{ + name: "poster", + weight: 0.9 + }], + textFields: [{ + name: "title", + weight: 0.1 + }], + // Further options + model: "voyage-multimodal-3", + truncate: true, // or false + // outputEncoding: "base64" // or "null" + // baseURL: "" + })], + // highlight-end + // Additional parameters not shown +})// END FullMMVectorizerVoyageAI + + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerWeaviate +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecWeaviate({ + name: 'title_vector', + sourceProperties: ['title'], + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerWeaviate + +// Clean up +await client.collections.delete('DemoCollection'); + +// START VectorizerWeaviateCustomModel +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecWeaviate({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'Snowflake/snowflake-arctic-embed-l-v2.0', + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END VectorizerWeaviateCustomModel + +// Clean up +await client.collections.delete('DemoCollection'); + +// START SnowflakeArcticEmbedMV15 +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecWeaviate({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'Snowflake/snowflake-arctic-embed-m-v1.5', + // Further options + // dimensions: 256, + // baseURL: '', + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END SnowflakeArcticEmbedMV15 + +// Clean up +await client.collections.delete('DemoCollection'); + +// START SnowflakeArcticEmbedLV20 +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecWeaviate({ + name: 'title_vector', + sourceProperties: ['title'], + model: 'Snowflake/snowflake-arctic-embed-l-v2.0', + // Further options + // dimensions: 256, + // baseURL: '', + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END SnowflakeArcticEmbedLV20 + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerTransformers +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecTransformers({ + name: 'title_vector', + sourceProperties: ['title'], + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicVectorizerTransformers + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerTransformers +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + ], + vectorizers: [ + weaviate.configure.vectors.text2VecTransformers({ + name: 'title_vector', + sourceProperties: ['title'], + // Further options + // poolingStrategy: 'masked_mean', + // inferenceUrl: '', // For when using multiple inference containers + // passageInferenceUrl: ``, // For when using DPR models + // queryInferenceUrl: ``, // For when using DPR models + }, + ), + ], + // highlight-end + // Additional parameters not shown +}); +// END FullVectorizerTransformers + +// START BasicVectorizerOllama +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecOllama({ + name: 'title_vector', + sourceProperties: ['title'], + apiEndpoint: 'http://host.docker.internal:11434', // If using Docker, use this to contact your local Ollama instance + model: 'snowflake-arctic-embed', // The model to use, e.g. "nomic-embed-text" + }), + ], + // highlight-end + // END BasicVectorizerOllama + properties: [ + { name: 'title', dataType: 'text' } + ], + // START BasicVectorizerOllama + // Additional parameters not shown +}); +// END BasicVectorizerOllama + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BasicVectorizerGPT4All +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecGPT4All({ + name: 'title_vector', + sourceProperties: ['title'], + }), + ], + // highlight-end + // END BasicVectorizerGPT4All + properties: [ + { name: 'title', dataType: 'text' } + ], + // START BasicVectorizerGPT4All + // Additional parameters not shown +}); +// END BasicVectorizerGPT4All + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerGPT4All +await client.collections.create({ + name: 'DemoCollection', + // highlight-start + vectorizers: [ + weaviate.configure.vectors.text2VecGPT4All({ + name: 'title_vector', + sourceProperties: ['title'], + }), + ], + // highlight-end + // END FullVectorizerGPT4All + properties: [ + { name: 'title', dataType: 'text' } + ], + // START FullVectorizerGPT4All + // Additional parameters not shown +}); +// END FullVectorizerGPT4All + +// START BasicVectorizerModel2Vec +// Coming soon +// END BasicVectorizerModel2Vec + +// Clean up +await client.collections.delete('DemoCollection'); + +// START FullVectorizerModel2Vec +// Coming soon +// END FullVectorizerModel2Vec + +// START BasicMMVectorizerCLIP +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecClip({ + name: 'title_vector', + imageFields: [ + { + name: 'poster', + weight: 0.9, + }, + ], + textFields: [ + { + name: 'title', + weight: 0.1, + }, + ], + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicMMVectorizerCLIP + +// START FullMMVectorizerCLIP +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecClip({ + name: 'title_vector', + imageFields: [ + { + name: 'poster', + weight: 0.9, + }, + ], + textFields: [ + { + name: 'title', + weight: 0.1, + }, + ], + // inferenceUrl: '' + }), + ], + // highlight-end +}); +// END FullMMVectorizerCLIP + +// START BasicMMVectorizerBind +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecClip({ + name: 'title_vector', + imageFields: [ + { + name: 'poster', + weight: 0.9, + }, + ], + textFields: [ + { + name: 'title', + weight: 0.1, + }, + ], + }), + ], + // highlight-end + // Additional parameters not shown +}); +// END BasicMMVectorizerBind + +// START FullMMVectorizerBind +await client.collections.create({ + name: 'DemoCollection', + properties: [ + { + name: 'title', + dataType: 'text' as const, + }, + { + name: 'poster', + dataType: 'blob' as const, + }, + { + name: 'sound', + dataType: 'blob' as const, + }, + { + name: 'video', + dataType: 'blob' as const, + }, + ], + // highlight-start + vectorizers: [ + weaviate.configure.vectors.multi2VecBind({ + name: 'title_vector', + imageFields: [ + { + name: 'poster', + weight: 0.7, + }, + ], + textFields: [ + { + name: 'title', + weight: 0.1, + }, + ], + audioFields: [ + { + name: 'sound', + weight: 0.1, + }, + ], + videoFields: [ + { + name: 'video', + weight: 0.1, + }, + ], + // depth, IMU and thermal fields are also available + }), + ], + // highlight-end +}); +// END FullMMVectorizerBind + +// Clean up +await client.collections.delete('DemoCollection'); + +// START BatchImportExample +let srcObjects = [ + { title: "The Shawshank Redemption", description: "A wrongfully imprisoned man forms an inspiring friendship while finding hope and redemption in the darkest of places." }, + { title: "The Godfather", description: "A powerful mafia family struggles to balance loyalty, power, and betrayal in this iconic crime saga." }, + { title: "The Dark Knight", description: "Batman faces his greatest challenge as he battles the chaos unleashed by the Joker in Gotham City." }, + { title: "Jingle All the Way", description: "A desperate father goes to hilarious lengths to secure the season's hottest toy for his son on Christmas Eve." }, + { title: "A Christmas Carol", description: "A miserly old man is transformed after being visited by three ghosts on Christmas Eve in this timeless tale of redemption." } +]; + +// END BatchImportExample + +// START BatchImportExample // START NearTextExample // START HybridExample // START MMBatchImportExample +const collectionName = 'DemoCollection' +const myCollection = client.collections.use(collectionName) + +// END BatchImportExample // END NearTextExample // END HybridExample // END MMBatchImportExample + +// START BatchImportExample +let dataObjects = new Array(); + +for (let srcObject of srcObjects) { + dataObjects.push({ + title: srcObject.title, + description: srcObject.description, + }); +} + +const response = await myCollection.data.insertMany(dataObjects); + +console.log(response); +// END BatchImportExample + +let mmSrcObjects = [ + { title: "The Shawshank Redemption", description: "", poster: "" }, + { title: "The Godfather", description: "", poster: "" }, + { title: "The Dark Knight", description: "", poster: "" }, + { title: "Jingle All the Way", description: "", poster: "" }, + { title: "A Christmas Carol", description: "", poster: "" }, +]; + +// START MMBatchImportExample +let multiModalObjects = new Array(); + +for (let mmSrcObject of mmSrcObjects) { + multiModalObjects.push({ + title: mmSrcObject.title, + poster: mmSrcObject.poster, // Add the image in base64 encoding + }); +} + +// The model provider integration will automatically vectorize the object +const mmInsertResponse = await myCollection.data.insertMany(dataObjects); + +console.log(mmInsertResponse); +// END MMBatchImportExample + +// START NearTextExample +let result; + +result = await myCollection.query.nearText( + 'A holiday film', // The model provider integration will automatically vectorize the query + { + limit: 2, + } +) + +console.log(JSON.stringify(result.objects, null, 2)); +// END NearTextExample + + +// START HybridExample +result = await myCollection.query.hybrid( + 'A holiday film', // The model provider integration will automatically vectorize the query + { + limit: 2, + } +) + +console.log(JSON.stringify(result.objects, null, 2)); +// END HybridExample + +// START NearImageExample +const base64String = 'SOME_BASE_64_REPRESENTATION'; + +result = await myCollection.query.nearImage( + base64String, // The model provider integration will automatically vectorize the query + { + limit: 2, + } +) + +console.log(JSON.stringify(result.objects, null, 2)); +// END NearImageExample + +client.close(); + +} + +void main(); diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/_category_.json new file mode 100644 index 000000000..6c523c71d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Anthropic", + "position": 203 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/generative.md new file mode 100644 index 000000000..05181cc47 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/generative.md @@ -0,0 +1,332 @@ +--- +title: 生成 AI +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_anthropic.jpg +# tags: ['model providers', 'anthropic', 'generative', 'rag'] +--- + +# Weaviate での Anthropic 生成 AI + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate の Anthropic API との統合により、モデルの機能を Weaviate から直接利用できます。 + +Anthropic の生成 AI モデルを使用するには、[Weaviate コレクションを設定](#configure-collection)してください。Weaviate は、指定したモデルとお持ちの Anthropic API キーを用いて 検索拡張生成 (RAG) を実行します。 + +具体的には、 Weaviate が検索を行い、最も関連性の高いオブジェクトを取得し、それらを Anthropic の生成モデルに渡して出力を生成します。 + +![RAG 統合のイラスト](../_includes/integration_anthropic_rag.png) + +## 要件 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスには、Anthropic 生成 AI 連携モジュール (`generative-anthropic`) を設定しておく必要があります。 + +
+ Weaviate Cloud (WCD) のユーザー向け + +Weaviate Cloud (WCD) のサーバーレスインスタンスでは、この連携はデフォルトで有効になっています。 + +
+ +
+ セルフホスト版ユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスター メタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 認証情報 + +この連携を利用するには、有効な Anthropic API キーを Weaviate に提供する必要があります。API キーを取得するには、[Anthropic](https://www.anthropic.com/api) にサインアップしてください。 + +次のいずれかの方法で Weaviate に API キーを渡してください。 + +- Weaviate が参照できる環境変数 `ANTHROPIC_APIKEY` を設定する +- 以下の例のように、実行時に API キーを渡す + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +Anthropic の生成モデルを使用するには、次のように [Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)します。 + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、 Weaviate で使用する [利用可能なモデル](#available-models) を指定できます。 + + + + + + + + + + + + +Weaviate で使用する [利用可能なモデル](#available-models) を[指定](#generative-parameters)できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +### 生成パラメーター + +以下の生成パラメーターを設定して、モデルの挙動をカスタマイズします。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[Anthropic API ドキュメント](https://www.anthropic.com/docs) を参照してください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることも可能です。 + + + + + + + + + + +## ヘッダー パラメーター + +追加のヘッダーをリクエストに含めることで、実行時に API キーや任意のパラメーターを指定できます。利用可能なヘッダーは次のとおりです。 + +- `X-Anthropic-Api-Key`: Anthropic API キー +- `X-Anthropic-Baseurl`: 既定の Anthropic URL の代わりに使用するベース URL(例: プロキシ) + +実行時に指定された追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +ヘッダーは上記の[API 資格情報の例](#api-credentials)のように指定してください。 + +## 検索拡張生成 + +生成 AI 統合を設定した後、[単一プロンプト](#single-prompt)もしくは[グループ化タスク](#grouped-task)の方法で RAG 操作を実行します。 + +### 単一プロンプト + +![単一プロンプトの RAG 統合は、検索結果ごとに個別の出力を生成します](../_includes/integration_anthropic_rag_single.png) + +検索結果の各オブジェクトに対してテキストを生成するには、単一プロンプト方式を使用します。 + +次の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +単一プロンプトクエリを作成する際、Weaviate が言語モデルに渡すオブジェクトプロパティを埋め込むために `{}` を使用します。たとえばオブジェクトの `title` プロパティを渡したい場合は、クエリに `{title}` を含めてください。 + + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスクの RAG 統合は、検索結果のセットに対して 1 件の出力を生成します](../_includes/integration_anthropic_rag_grouped.png) + +検索結果全体に対して 1 件のテキストを生成する場合は、グループ化タスク方式を使用します。 + +言い換えると、`n` 件の検索結果がある場合、生成モデルはそのグループ全体に対して 1 件の出力を生成します。 + + + + + + + + + + + + + + +### 画像を用いた RAG + +単一プロンプトでもグループ化タスクでも、検索拡張生成を実行する際の入力の一部として画像を渡すこともできます。 + + + + + + + + + + + +## 参考情報 + +#### 出力トークンの上限 + +`maxTokens` パラメーターを使用して、Anthropic 生成 AI モデルの出力トークンの最大数を設定できます。このパラメーターは、最大入力トークン数(コンテキスト ウィンドウ)とは別に設定されます。 + +ほとんどのモデルでは、デフォルトの `maxTokens` は `4096`(かつ最大値)で、入力(コンテキスト ウィンドウ)サイズは `200,000` です。具体的な許可値はモデルによって異なる場合があります。最新情報は [Anthropic のドキュメント](https://docs.anthropic.com/en/docs/about-claude/models#model-comparison) を参照してください。 + +#### Base URL + +Anthropic では、API エンドポイントにカスタム Base URL を指定できます。専用の API エンドポイントを持っている、またはプロキシの背後にある場合に便利です。 + +カスタム Base URL は、前述のようにコレクションの設定で指定するか、リクエストヘッダーで指定できます。ヘッダーで指定する場合は、`X-Anthropic-Baseurl` キーにカスタム Base URL を値として設定して Weaviate クライアントを初期化します。 + +デフォルトの Base URL は `https://api.anthropic.com` です。 + +### 利用可能なモデル + +Anthropic API に用意されているすべてのモデルを Weaviate で使用できます。2024 年 7 月時点では、次のモデルが利用可能です。 + +- `claude-3-5-sonnet-20240620` (default) +- `claude-3-opus-20240229` +- `claude-3-sonnet-20240229` +- `claude-3-haiku-20240307` + +最新のモデル一覧は [Anthropic API ドキュメント](https://docs.anthropic.com/en/docs/about-claude/models#model-names) をご覧ください。 + +## 追加リソース + +### コード例 + +インテグレーションをコレクションに設定すると、Weaviate でのデータ管理と検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) では、データ操作(コレクションおよびその内部オブジェクトの作成、読み取り、更新、削除)方法を紹介しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) では、ベクトル検索、キーワード検索、ハイブリッド検索および検索拡張生成の実行方法を説明しています。 + +### 参照 + +- Anthropic [API ドキュメント](https://www.anthropic.com/docs) + +## 質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/index.md new file mode 100644 index 000000000..25a1820d6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anthropic/index.md @@ -0,0 +1,45 @@ +--- +title: Anthropic + Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_anthropic.jpg +# tags: ['model providers', 'anthropic'] +--- + + + +Anthropic は、自然言語処理および生成向けの幅広いモデルを提供しています。 Weaviate は Anthropic の API とシームレスに連携し、ユーザーは Weaviate データベースから直接 Anthropic のモデルを活用できます。 + +これらの連携により、開発者は高度な AI 主導のアプリケーションを簡単に構築できます。 + +## Anthropic との連携 + +### RAG 向け生成 AI モデル + +![単一プロンプトの RAG 連携は検索結果ごとに個別の出力を生成します](../_includes/integration_anthropic_rag_single.png) + +Anthropic の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間らしいテキストを生成できます。 + +[Weaviate の生成 AI 連携](./generative.md) により、ユーザーは Weaviate データベースから直接 検索拡張生成 (RAG) を実行できます。これにより、 Weaviate の高効率なストレージと高速検索機能と Anthropic の生成 AI モデルが組み合わさり、パーソナライズされた文脈認識応答を生成できます。 + +[Anthropic 生成 AI 連携ページ](./generative.md) + +## まとめ + +これらの連携により、開発者は Weaviate 内で Anthropic の強力なモデルを直接活用できます。 + +その結果、 AI 主導のアプリケーションを構築するプロセスが簡素化され、開発サイクルが加速するため、イノベーティブなソリューションの創出に集中できます。 + +## はじめに + +これらの連携を利用するには、 Weaviate に有効な Anthropic API キーを設定する必要があります。 [Anthropic](https://www.anthropic.com/) にアクセスしてサインアップし、 API キーを取得してください。 + +次に、関連する連携ページに移動し、 Anthropic モデルで Weaviate を設定して、アプリケーションで使用を開始してください。 + +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/_category_.json new file mode 100644 index 000000000..f0969fe09 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Anyscale", + "position": 205 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/generative.md new file mode 100644 index 000000000..f040de36d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/generative.md @@ -0,0 +1,295 @@ +--- +title: 生成 AI +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_anyscale.jpg +# tags: ['model providers', 'anyscale', 'generative', 'rag'] +--- + +# Weaviate と Anyscale による生成 AI + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + + Weaviate の Anyscale Endpoints API との統合により、 Weaviate から直接 Anyscale のモデル機能を利用できます。 + +[コレクションを設定](#configure-collection)して Anyscale の生成 AI モデルを使用すると、 Weaviate は指定したモデルとお客様の Anyscale API キーを用いて検索拡張生成 (RAG) を実行します。 + +具体的には、 Weaviate が検索を実行し、最も関連性の高いオブジェクトを取得した後、これらを Anyscale の生成モデルに渡して出力を生成します。 + +![RAG integration illustration](../_includes/integration_anyscale_rag.png) + +## 必要条件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスには、 Anyscale 生成 AI 統合 ( `generative-anyscale` ) モジュールが有効化されている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は、 Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザーの場合 + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効になっているかをご確認ください。 +- [モジュールの設定方法](../../configuration/modules.md) に従って、 Weaviate でモジュールを有効にしてください。 + +
+ +### API 認証情報 + +この統合を利用するには、有効な Anyscale API キーを Weaviate に提供する必要があります。 [Anyscale](https://www.anyscale.com/) でサインアップし、 API キーを取得してください。 + +以下のいずれかの方法で API キーを Weaviate に渡します。 + +- `ANYSCALE_APIKEY` 環境変数を設定して Weaviate から参照できるようにする。 +- 下記の例のように、実行時に API キーを渡す。 + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +[Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)して Anyscale の生成モデルを使用するには、次のように設定します。 + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを [指定](#generative-parameters) できます。モデルを指定しない場合は[デフォルトモデル](#available-models) が使用されます。 + +### モデルの選択 + + Weaviate に使用させる [利用可能なモデル](#available-models) を指定できます。以下はその設定例です。 + + + + + + + + + + + + + + +### 生成パラメーター + +以下の生成パラメーターを設定して、モデルの挙動をカスタマイズします。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[Anyscale Endpoints API documentation](https://docs.anyscale.com/endpoints/intro/) を参照してください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定する以外に、クエリ実行時に上書きすることも可能です。 + + + + + + + + + + +## ヘッダーパラメーター + +API キーおよびオプションのパラメーターは、リクエストに追加ヘッダーとして実行時に渡せます。利用可能なヘッダーは次のとおりです。 + +- `X-Anyscale-Api-Key`: Anyscale の API キー +- `X-Anyscale-Baseurl`: 既定の Anyscale URL の代わりに使用するベース URL(例: プロキシ) + +実行時に渡された追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +上記の [API credentials の例](#api-credentials) のようにヘッダーを指定してください。 + +## 検索拡張生成 + +生成 AI の統合を設定した後、[シングル プロンプト](#single-prompt) または [グループ化タスク](#grouped-task) の方法で RAG 操作を実行できます。 + +### シングル プロンプト + +![シングル プロンプトの RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_anyscale_rag_single.png) + +検索結果の各オブジェクトに対してテキストを生成する場合は、シングル プロンプト方式を使用します。 + +次の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +シングル プロンプト クエリを作成する際、Weaviate から言語モデルへ渡したいオブジェクトプロパティを中括弧 `{}` でインターポレートします。たとえば、オブジェクトの `title` プロパティを渡すには、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスクの RAG 統合は検索結果セット全体に対して 1 つの出力を生成します](../_includes/integration_anyscale_rag_grouped.png) + +検索結果のセット全体に対して 1 つのテキストを生成する場合は、グループ化タスク方式を使用します。 + +つまり、`n` 件の検索結果がある場合でも、生成モデルはグループ全体に対して 1 つの出力のみを生成します。 + + + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +* `meta-llama/Llama-2-70b-chat-hf` (default) +* `meta-llama/Llama-2-13b-chat-hf` +* `meta-llama/Llama-2-7b-chat-hf` +* `codellama/CodeLlama-34b-Instruct-hf` +* `mistralai/Mistral-7B-Instruct-v0.1` +* `mistralai/Mixtral-8x7B-Instruct-v0.1` + +## 追加リソース + +### コード例 + +コレクションで統合を設定すると、 Weaviate のデータ管理および検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) のガイドでは、データ操作(つまり create、read、update、delete によるコレクションおよびそれら内のオブジェクトの作成・読み取り・更新・削除)の方法を解説しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索、さらに 検索拡張生成 の実行方法を紹介しています。 + +### 参考 + +- Anyscale [Endpoints API ドキュメント](https://docs.anyscale.com/endpoints/intro/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/index.md new file mode 100644 index 000000000..64ec6e762 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/anyscale/index.md @@ -0,0 +1,45 @@ +--- +title: Anyscale + Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_anyscale.jpg +# tags: ['model providers', 'anyscale'] +--- + + + +Anyscale は自然言語処理と生成のための幅広いモデルを提供しています。Weaviate は Anyscale の Endpoints API とシームレスに統合されており、ユーザーは Weaviate Database から直接 Anyscale のモデルを利用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## Anyscale との統合 + +### RAG 向け生成 AI モデル + +![単一プロンプト RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_anyscale_rag_single.png) + +Anyscale の生成 AI モデルは、指定されたプロンプトとコンテキストに基づいて人間らしいテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md) を使用すると、ユーザーは Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。これにより、Weaviate の効率的なストレージと高速な検索機能に Anyscale の生成 AI モデルを組み合わせて、パーソナライズされコンテキストを考慮した応答を生成します。 + +[Anyscale 生成 AI 統合ページ](./generative.md) + +## Summary + +これらの統合により、開発者は Weaviate 内で直接 Anyscale の強力なモデルを活用できます。 + +その結果、AI 駆動アプリケーションの構築プロセスが簡素化され、開発を迅速化でき、革新的なソリューションの創出に集中できます。 + +## Get started + +これらの統合を利用するには、有効な Anyscale API キーを Weaviate に提供する必要があります。 [Anyscale](https://www.anyscale.com/) にアクセスしてサインアップし、API キーを取得してください。 + +次に、該当する統合ページに移動し、Weaviate で Anyscale モデルを設定してアプリケーションで使用する方法を確認してください。 + +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/_category_.json new file mode 100644 index 000000000..6604cb58f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "AWS", + "position": 210 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/embeddings.md new file mode 100644 index 000000000..43e7b797c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/embeddings.md @@ -0,0 +1,390 @@ +--- +title: テキスト Embeddings +description: " Weaviate が AWS の SageMaker および Bedrock API と連携し、これらのモデルの機能を Weaviate から直接利用できます。" +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_aws.jpg +# tags: ['model providers', 'aws', 'embeddings'] +--- + +# Weaviate での AWS 埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + + Weaviate が AWS の [SageMaker](https://aws.amazon.com/sagemaker/) と [Bedrock](https://aws.amazon.com/bedrock/) API に統合されているため、これらのモデルの機能を Weaviate から直接利用できます。 + +[ Weaviate ベクトルインデックス](#configure-the-vectorizer) を AWS の埋め込みモデルで使用するように設定すると、 Weaviate は指定したモデルとお客様の AWS API 資格情報を用いてさまざまな操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) に、 Weaviate はテキストオブジェクトの埋め込みを生成し、インデックスに保存します。さらに [ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、 Weaviate がテキストクエリを埋め込みへと変換します。 + +![Embedding integration illustration](../_includes/integration_aws_embedding.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、 AWS ベクトライザー統合(`text2vec-aws`)モジュールを有効にしておく必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は Weaviate Cloud (WCD) サーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザーの場合 + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効かどうかを確認します。 +- [モジュールの設定方法](../../configuration/modules.md) ガイドに従い、 Weaviate でモジュールを有効化します。 + +
+ +### API 資格情報 + +これらの統合を利用するには、[アクセスキー方式の AWS 資格情報](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) を Weaviate に提供する必要があります。 [AWS](https://aws.amazon.com/) にサインアップして、 AWS アクセスキー ID と対応する AWS シークレットアクセスキーを取得してください。 + +次のいずれかの方法で Weaviate に API 資格情報を提供します。 + +- `AWS_ACCESS_KEY` と `AWS_SECRET_KEY` の環境変数を設定し、 Weaviate から利用できるようにする +- 以下の例のように、実行時に API 資格情報を渡す + + + + + + + + + + + + + + + + + +### AWS モデルへのアクセス + +#### Bedrock + +[Bedrock](https://aws.amazon.com/bedrock/) を介してモデルを利用するには、そのモデルが利用可能であり、 AWS からのアクセス許可が付与されている必要があります。 + +利用可能なモデルの一覧は [AWS ドキュメント](https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions.html) を、モデルへのアクセス申請方法は [こちらのドキュメント](https://docs.aws.amazon.com/bedrock/latest/userguide/model-usage.html) を参照してください。 + +#### SageMaker + +[SageMaker](https://aws.amazon.com/sagemaker/) を通じてモデルを使用する場合は、そのモデルのエンドポイントにアクセスできる必要があります。 + +## ベクトライザーの設定 + + AWS 埋め込みモデルを使用するように [ Weaviate インデックス](../../manage-collections/vector-config.mdx#specify-a-vectorizer) を次のように設定します。 + + Bedrock と SageMaker のモデルでは必要なパラメーターが異なります。 + +### Bedrock + +Bedrock を使用する場合は、ベクトライザー設定にモデル名を指定する必要があります。 + + + + + + + + + + + + + + + + + + +### SageMaker + +SageMaker を使用する場合、ベクトライザーの設定で endpoint アドレスを指定する必要があります。 + + + + + + + + + + + + + + + + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +### ベクトライザーのパラメーター + +次の例では、AWS 固有のオプションの設定方法を示します。 + +AWS 統合では region の設定が必須です。 + +- Bedrock のユーザーは、`service` を `bedrock` に設定し、`model` 名を指定する必要があります。 +- SageMaker のユーザーは、`service` を `sagemaker` に設定し、`endpoint` アドレスを指定する必要があります。 + + + + + + + + + + + + + + + + +## データインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。Weaviate は指定されたモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデル ベクトル が既にある場合は、それを直接 Weaviate に渡すことができます。同じモデルで埋め込みを既に生成しており、他のシステムからの移行などでそれらを Weaviate で利用したい場合に便利です。 +::: + +## 検索 + +ベクトライザーの設定が完了すると、 Weaviate は指定した AWS モデルを使用してベクトル検索とハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイメージ](../_includes/integration_aws_embedding_search.png) + +### ベクトル(Near Text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、 Weaviate はクエリ テキストを指定されたモデルでベクトル化し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは `limit` で指定した値に応じて、データベースから `n` 件の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を実行し、その後で[結果を統合](../../search/hybrid.md)してデータベースから最適な一致オブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、 Weaviate はクエリ テキストを指定されたモデルでベクトル化し、データベースからスコアの高い順にオブジェクトを返します。 + +以下のクエリは `limit` で指定した値に応じて、データベースから `n` 件のスコアが最も高いオブジェクトを返します。 + + + + + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +#### Bedrock + +- `amazon.titan-embed-text-v1` +- `amazon.titan-embed-text-v2:0` +- `cohere.embed-english-v3` +- `cohere.embed-multilingual-v3` + +モデルがご利用のリージョンで使用可能か、またモデルへのアクセスをリクエストする方法については[こちらのドキュメント](https://docs.aws.amazon.com/bedrock/latest/userguide/model-usage.html)をご確認ください。 + +### SageMaker + +カスタム SageMaker 名(例: "TEI-xxx")はエンドポイントとして使用できます。 + +## 追加リソース + +### その他の統合 + +- [AWS 生成モデル + Weaviate](./generative.md) + +### コード例 + +コレクションに統合を設定すると、 Weaviate のデータ管理および検索操作は他のコレクションと同じ方法で動作します。以下のモデル非依存の例をご覧ください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) のガイドでは、データ操作(コレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)の方法を説明しています。 +- [How-to: Query & Search](../../search/index.mdx) のガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索、さらに検索拡張生成の実行方法を説明しています。 + +### 外部リソース + +- AWS [Bedrock documentation](https://docs.aws.amazon.com/bedrock/) +- AWS [SageMaker documentation](https://docs.aws.amazon.com/sagemaker/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/generative.md new file mode 100644 index 000000000..0f6ed2257 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/generative.md @@ -0,0 +1,328 @@ +--- +title: 生成 AI +description: AWS 生成モデルプロバイダー +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_aws.jpg +# tags: ['model providers', 'aws', 'generative', 'rag'] +--- + +# Weaviate と AWS 生成 AI + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate の AWS の [SageMaker](https://aws.amazon.com/sagemaker/) と [Bedrock](https://aws.amazon.com/bedrock/) API との統合により、モデルの機能に Weaviate から直接アクセスできます。 + +[AWS とともに生成 AI モデルを使用するように Weaviate コレクションを設定](#configure-collection)します。Weaviate は、指定したモデルと AWS の API 資格情報を用いて 検索拡張生成 (RAG) を実行します。 + +具体的には、Weaviate が検索を実行して最も関連性の高いオブジェクトを取得し、それらを AWS の生成モデルに渡して出力を生成します。 + +![RAG 統合のイラスト](../_includes/integration_aws_rag.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスには、AWS 生成 AI 統合 (`generative-aws`) モジュールが設定されている必要があります。 + +
+ Weaviate Cloud (WCD) 利用者向け + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスト環境向け + +- モジュールが有効になっているかどうかを確認するには、[クラスター メタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 資格情報 + +これらの統合を行うには、アクセスキー方式の AWS 資格情報を Weaviate に提供する必要があります。AWS に登録し、AWS access key ID と対応する AWS secret access key を取得してください。 + +以下のいずれかの方法で Weaviate に API 資格情報を渡します。 + +- `AWS_ACCESS_KEY` と `AWS_SECRET_KEY` 環境変数を設定し、Weaviate から参照できるようにします。 +- 下記の例のように、実行時に API 資格情報を渡します。 + + + + + + + + + + + + + +### AWS モデルへのアクセス + +#### Bedrock + +[Bedrock](https://aws.amazon.com/bedrock/) 経由でモデルを利用するには、そのモデルが利用可能であり、かつ AWS からアクセスが許可されている必要があります。 + +利用可能なモデルの一覧は [AWS のドキュメント](https://docs.aws.amazon.com/bedrock/latest/userguide/models-regions.html) を、モデルへのアクセス申請方法は [こちら](https://docs.aws.amazon.com/bedrock/latest/userguide/model-usage.html) を参照してください。 + +#### SageMaker + +[SageMaker](https://aws.amazon.com/sagemaker/) 経由でモデルを利用するには、モデルのエンドポイントへのアクセス権が必要です。 + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +AWS の生成モデルを使用するように、次のように [Weaviate インデックス](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration) を設定します。 + +### Bedrock + +Bedrock を使用する場合、生成 AI 設定でモデル名を指定する必要があります。 + + + + + + + + + + + + +### SageMaker + +SageMaker を使用する場合は、生成 AI 設定でエンドポイントアドレスを指定する必要があります。 + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを Weaviate に使用させるように [指定](#generative-parameters) できます。モデルを指定しない場合は [デフォルトモデル](#available-models) が使用されます。 + +### 生成パラメーター + +モデルパラメーターの詳細については、[関連する AWS ドキュメント](#further-resources) を参照してください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることも可能です。 + + + + + + + + + + +## 検索拡張生成 + +生成 AI 連携を設定した後、[シングルプロンプト](#single-prompt) または [グループ化タスク](#grouped-task) の方法で RAG 操作を実行します。 + +### シングルプロンプト + +![シングルプロンプトの RAG 連携では検索結果ごとに個別の出力を生成します](../_includes/integration_aws_rag_single.png) + +検索結果の各オブジェクトに対してテキストを生成するには、シングルプロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +シングルプロンプトクエリを作成する際、渡したいオブジェクトプロパティを波かっこ `{}` で囲んで記述すると、Weaviate がその値を言語モデルに渡します。たとえば、オブジェクトの `title` プロパティを渡すには、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスクの RAG 連携では検索結果全体に対して一つの出力を生成します](../_includes/integration_aws_rag_grouped.png) + +検索結果全体に対して一つのテキストを生成するには、グループ化タスク方式を使用します。 + +つまり、`n` 件の検索結果があっても、生成モデルはそのグループ全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + + + +### 画像付き RAG + +単一プロンプトでもグループ化されたタスクでも、検索拡張生成を行う際の入力の一部として画像を渡すこともできます。 + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +#### Bedrock + +- `ai21.j2-ultra-v1` +- `ai21.j2-mid-v1` +- `amazon.titan-text-lite-v1` +- `amazon.titan-text-express-v1` +- `amazon.titan-text-premier-v1:0` +- `anthropic.claude-v2` +- `anthropic.claude-v2:1` +- `anthropic.claude-instant-v1` +- `anthropic.claude-3-sonnet-20240229-v1:0` +- `anthropic.claude-3-haiku-20240307-v1:0` +- `cohere.command-text-v14` +- `cohere.command-light-text-v14` +- `cohere.command-r-v1:0` +- `cohere.command-r-plus-v1:0` +- `meta.llama3-8b-instruct-v1:0` +- `meta.llama3-70b-instruct-v1:0` +- `meta.llama2-13b-chat-v1` +- `meta.llama2-70b-chat-v1` +- `mistral.mistral-7b-instruct-v0:2` +- `mistral.mixtral-8x7b-instruct-v0:1` +- `mistral.mistral-large-2402-v1:0` + +モデルへのアクセスをリクエストする方法については [こちらのドキュメント](https://docs.aws.amazon.com/bedrock/latest/userguide/model-usage.html) を参照してください。 + +### SageMaker + +任意のカスタム SageMaker URL をエンドポイントとして使用できます。 + +## 追加リソース + +### その他の統合 + +- [AWS embedding models + Weaviate](./embeddings.md)。 + +### コード例 + +インテグレーションをコレクションで設定すると、Weaviate におけるデータ管理および検索操作は他のコレクションと同一の方法で機能します。以下のモデル非依存の例をご覧ください。 + +- [ハウツー: コレクション管理](../../manage-collections/index.mdx) および [ハウツー: オブジェクト管理](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)を行う方法を示しています。 +- [ハウツー: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作(ベクトル、キーワード、ハイブリッド)および 検索拡張生成 を実行する方法を示します。 + +### 参考文献 + +- AWS [Bedrock ドキュメント](https://docs.aws.amazon.com/bedrock/) +- AWS [SageMaker ドキュメント](https://docs.aws.amazon.com/sagemaker/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/index.md new file mode 100644 index 000000000..10eb94b8c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/aws/index.md @@ -0,0 +1,62 @@ +--- +title: AWS と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_aws.jpg +# tags: ['model providers', 'aws'] +--- + + + + AWS は、自然言語処理および生成のための幅広いモデルを提供しています。 Weaviate は AWS の API とシームレスに統合され、ユーザーは Weaviate Database から直接 AWS のモデルを活用できます。 + + Weaviate は、 AWS の [Sagemaker](https://aws.amazon.com/sagemaker/) と [Bedrock](https://aws.amazon.com/bedrock/) の両方と統合しています。 + + これらの統合により、開発者は高度な AI 駆動アプリケーションを容易に構築できます。 + +:::tip Sagemaker vs Bedrock +Amazon SageMaker は、機械学習モデルの構築、トレーニング、デプロイを行えるフルマネージドサービスです。Amazon Bedrock は、主要な AI 企業が提供する高性能な基盤モデル (FM) を選択できるフルマネージドサービスです。 +::: + +## AWS との統合 + +### ベクトル検索用埋め込みモデル + +![埋め込み統合のイラスト](../_includes/integration_aws_embedding.png) + + AWS の埋め込みモデルは、テキストデータをベクトル埋め込みに変換し、意味とコンテキストを捉えます。 + + [Weaviate は AWS の埋め込みモデルと統合](./embeddings.md) し、データのシームレスなベクトル化を実現します。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索およびハイブリッド検索を実行できます。 + +[AWS 埋め込み統合ページ](./embeddings.md) + +### RAG 向け生成 AI モデル + +![シングルプロンプト RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_aws_rag_single.png) + + AWS の生成 AI モデルは、与えられたプロンプトとコンテキストに基づき、人間のようなテキストを生成できます。 + + [Weaviate の生成 AI 統合](./generative.md) により、 Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。これにより、 Weaviate の効率的なストレージと高速な検索機能を AWS の生成 AI モデルと組み合わせ、パーソナライズされたコンテキスト認識の応答を生成します。 + +[AWS 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は Weaviate 内で直接 AWS の強力なモデルを活用できます。 + +その結果、AI 駆動アプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を利用するには、 Weaviate に [アクセスキー形式の AWS 認証情報](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) を提供する必要があります。 AWS にアクセスし、サインアップして AWS アクセスキーと対応する AWS シークレットアクセスキーを取得してください。 + +その後、該当する統合ページに移動し、 AWS モデルで Weaviate を設定してアプリケーションで使用する方法をご確認ください。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/_category_.json new file mode 100644 index 000000000..48bc03e4e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Cohere", + "position": 220 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/embeddings-multimodal.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/embeddings-multimodal.md new file mode 100644 index 000000000..82452d41c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/embeddings-multimodal.md @@ -0,0 +1,333 @@ +--- +title: マルチモーダル埋め込み +description: "Weaviate と Cohere の API 連携により、Weaviate から直接 Cohere モデルの機能にアクセスできます。" +sidebar_position: 25 +image: og/docs/integrations/provider_integrations_cohere.jpg +# tags: ['model providers', 'cohere', 'embeddings'] +--- + +# Weaviate における Cohere マルチモーダル埋め込み + +:::info Added in `1.25.25`, `1.26.9` and `v1.27.2` +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate と Cohere の API 連携により、Weaviate から Cohere モデルの機能に直接アクセスできます。 + +[vector インデックスを設定](#configure-the-vectorizer) して Cohere の埋め込みモデルを使用すると、Weaviate は指定したモデルとお持ちの Cohere API キーを用いて、各種操作に必要な埋め込みを生成します。この機能は *vectorizer* と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はマルチモーダルオブジェクト埋め込みを生成し、インデックスへ保存します。[vector](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。[マルチモーダル検索](#vector-near-media-search) もサポートされています。 + +![Embedding integration illustration](../_includes/integration_cohere_embedding.png) + +## 必要条件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスには Cohere ベクトライザー統合 (`multi2vec-cohere`) モジュールが有効である必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は WCD サーバーレスインスタンスでデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザーの場合 + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効かどうかを確認します。 +- Weaviate でモジュールを有効化するには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 資格情報 + +この連携を使用するには、有効な Cohere API キーを Weaviate に提供する必要があります。API キーの取得には [Cohere](https://cohere.com/) にサインアップしてください。 + +次のいずれかの方法で API キーを Weaviate に渡します。 + +- Weaviate が参照できる `COHERE_APIKEY` 環境変数を設定する。 +- 以下の例のように、実行時に API キーを提供する。 + + + + + + + + + + + + + +## ベクトライザーの設定 + +Cohere 埋め込みモデルを使用するように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します。 + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、ベクトライザーが使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + +Weaviate に使用させるモデルは [指定](#vectorizer-parameters) できます。モデルを指定しない場合は [デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ + + +### ベクトライザーのパラメーター + +以下の例では、Cohere 固有のオプションを設定する方法を示します。 + + + + + + + + + + + + +モデルのパラメーターの詳細については、[Cohere API ドキュメント](https://docs.cohere.com/reference/embed)をご覧ください。 + +## データインポート + +ベクトライザーを設定したら、Weaviate に[データをインポート](../../manage-objects/import.mdx)します。Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +すでに互換性のあるモデルベクトルをお持ちの場合は、それを直接 Weaviate に渡すことができます。たとえば、同じモデルで既に埋め込みを生成しており、他のシステムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した Cohere モデルを用いてベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合の図](../_includes/integration_cohere_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を行い、その結果を[組み合わせ](../../search/hybrid.md)てデータベースから最も一致するオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースからスコアが最も高いオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` のスコアが最も高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + +### ベクトル(near media)検索 + +[near image search](../../search/similarity.md#search-with-image) のようなメディア検索を実行すると、Weaviate はクエリを指定されたモデルで埋め込みに変換し、データベースからもっとも類似したオブジェクトを返します。 + +near image search のような near media 検索を行うには、メディアクエリを base64 文字列に変換し、それを検索クエリに渡します。 + +以下のクエリは、`limit` で設定した数 `n` 件の、入力画像にもっとも類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +- `embed-multilingual-v3.0` (デフォルト) +- `embed-multilingual-light-v3.0` +- `embed-english-v3.0` +- `embed-english-light-v3.0` + +## 追加リソース + +### その他の統合 + +- [Cohere テキスト埋め込みモデル + Weaviate](./embeddings.md). +- [Cohere 生成モデル + Weaviate](./generative.md). +- [Cohere reranker モデル + Weaviate](./reranker.md). + +### コード例 + +統合をコレクションで設定すると、Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように機能します。モデルに依存しない以下の例をご覧ください。 + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) のガイドでは、データ操作(コレクションとその内部のオブジェクトの作成・読み取り・更新・削除)方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) のガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索、および 検索拡張生成 の実行方法を説明しています。 + +### 外部リソース + +- Cohere [Embed API ドキュメント](https://docs.cohere.com/reference/embed) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/embeddings.md new file mode 100644 index 000000000..f565218c1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/embeddings.md @@ -0,0 +1,463 @@ +--- +title: テキスト埋め込み +description: "Weaviate と Cohere の API を統合することで、Cohere のモデル機能に Weaviate から直接アクセスできます。" +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_cohere.jpg +# tags: ['model providers', 'cohere', 'embeddings'] +--- + +# Weaviate における Cohere 埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import JavaConnect from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/Connect.java'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/UsageCohereTextEmbeddings.java'; +import JavaImportQueries from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/ImportAndQueries.java'; + +Weaviate の Cohere API との統合により、Cohere のモデル機能に Weaviate から直接アクセスできます。 + +[Weaviate ベクトル インデックスを構成](#configure-the-vectorizer)して Cohere の埋め込みモデルを使用すると、Weaviate は指定したモデルとお客様の Cohere API キーを用いて、さまざまな操作のための埋め込みを生成します。この機能は * ベクトライザー * と呼ばれます。 + +[インポート時](#data-import)には、Weaviate がテキストオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![Embedding integration illustration](../_includes/integration_cohere_embedding.png) + +## 要件 + +### Weaviate 設定 + +ご利用の Weaviate インスタンスで Cohere ベクトライザー統合(`text2vec-cohere`)モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は、Weaviate Cloud (WCD) のサーバーレス インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザーの場合 + +- [クラスターメタデータ](/deploy/configuration/meta.md)を確認し、モジュールが有効かどうか確認してください。 +- Weaviate でモジュールを有効化する手順は、[モジュールの設定方法](../../configuration/modules.md)ガイドをご覧ください。 + +
+ +### API 資格情報 + +この統合を利用するには、有効な Cohere API キーを Weaviate に提供する必要があります。API キーは [Cohere](https://cohere.com/) でサインアップして取得してください。 + +API キーは以下のいずれかの方法で Weaviate に渡します。 + +- `COHERE_APIKEY` 環境変数を設定して Weaviate から参照できるようにする +- 例に示すように、実行時に API キーを渡す + + + + + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +[Cohere 埋め込みモデルを使用するよう Weaviate インデックスを構成](../../manage-collections/vector-config.mdx#specify-a-vectorizer)するには、以下を参照してください。 + + + + + + + + + + + + + + + + + + + + + + +### モデルの選択 + +以下の設定例に示すように、ベクトライザーが使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + + + + + + + + + +Weaviate が使用する [利用可能なモデル](#available-models) のいずれかを [指定](#vectorizer-parameters) できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ +### ベクトライザーのパラメーター + +以下の例では、Cohere 固有のオプションを設定する方法を示します。 + + + + + + + + + + + + + + + + + + + + +モデル パラメーターの詳細については、[Cohere API ドキュメント](https://docs.cohere.com/reference/embed) を参照してください。 + +## ヘッダー パラメーター + +リクエストの追加ヘッダーとして実行時に API キーおよびいくつかのオプション パラメーターを渡すことができます。使用可能なヘッダーは次のとおりです: + +- `X-Cohere-Api-Key`: Cohere の API キー。 +- `X-Cohere-Baseurl`: デフォルトの Cohere URL の代わりに使用するベース URL (例: プロキシ)。 + +実行時に指定された追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +ヘッダーは上記の [API 資格情報の例](#api-credentials) のように指定してください。 + +## データのインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。Weaviate は指定したモデルを使用してテキスト オブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +既に互換性のあるモデル ベクトルをお持ちの場合は、それを直接 Weaviate に渡すことができます。同じモデルで埋め込みを生成済みで、別のシステムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、 Weaviate は指定した Cohere モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイメージ](../_includes/integration_cohere_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、 Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` 件の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索では、まずベクトル検索とキーワード(BM25)検索を行い、その後 [結果を結合](../../search/hybrid.md) してデータベースから最も一致度の高いオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、 Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` 件の最もスコアの高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +- `embed-v4.0` +- `embed-multilingual-v3.0` (Default) +- `embed-multilingual-light-v3.0` +- `embed-multilingual-v2.0` (previously `embed-multilingual-22-12`) +- `embed-english-v3.0` +- `embed-english-light-v3.0` +- `embed-english-v2.0` +- `embed-english-light-v2.0` + +
+ 非推奨モデル + +The following models are available, but deprecated: +- `multilingual-22-12` +- `large` +- `medium` +- `small` + +
+ +## 追加リソース + +### その他の統合 + +- [Cohere マルチモーダル embedding モデル + Weaviate](./embeddings-multimodal.md) +- [Cohere 生成モデル + Weaviate](./generative.md) +- [Cohere reranker モデル + Weaviate](./reranker.md) + +### コード例 + +統合がコレクションで構成されると、Weaviate でのデータ管理および検索操作は他のコレクションとまったく同じように動作します。以下のモデル非依存の例をご覧ください: + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) のガイドでは、データ操作(つまり、コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除)の方法を説明しています。 +- [How-to: Query & Search](../../search/index.mdx) のガイドでは、ベクトル検索・キーワード検索・ハイブリッド検索などの検索操作と、検索拡張生成の実行方法を説明しています。 + +### 外部リソース + +- Cohere [Embed API ドキュメント](https://docs.cohere.com/reference/embed) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/generative.md new file mode 100644 index 000000000..84e2e7852 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/generative.md @@ -0,0 +1,304 @@ +--- +title: 生成 AI +description: Cohere 生成モデルプロバイダー +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_cohere.jpg +# tags: ['model providers', 'cohere', 'generative', 'rag'] +--- + +# Weaviate での Cohere 生成 AI + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate は Cohere の API と統合することで、Cohere のモデル機能に直接アクセスできます。 + +[Weaviate コレクションを設定](#configure-collection)して Cohere の生成 AI モデルを使用すると、Weaviate は 検索拡張生成 (RAG) を指定したモデルとお持ちの Cohere API キーで実行します。 + +具体的には、Weaviate が検索を行い、最も関連性の高いオブジェクトを取得してから、それらを Cohere の生成モデルに渡して出力を生成します。 + +![RAG integration illustration](../_includes/integration_cohere_rag.png) + +## 必要条件 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスには、Cohere 生成 AI 統合モジュール (`generative-cohere`) が有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスティングの場合 + +- モジュールが有効かどうかを確認するには [クラスターメタデータ](/deploy/configuration/meta.md) をご確認ください。 +- モジュールを有効化する方法については、[モジュールの設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### API 認証情報 + +この統合を利用するには、有効な Cohere API キーを Weaviate に提供する必要があります。API キーは [Cohere](https://cohere.com/) でサインアップして取得してください。 + +以下のいずれかの方法で Weaviate に API キーを渡します。 + +- Weaviate が参照できる `COHERE_APIKEY` 環境変数を設定する。 +- 下記の例のように実行時に API キーを渡す。 + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +[Cohere 生成 AI モデルを使用するように Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)するには、以下のように指定します。 + + + + + + + + + + + + +### モデルの選択 + +Weaviate に使用させる [利用可能なモデル](#available-models) のいずれかを、次の設定例のように指定できます。 + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを[指定](#generative-parameters)できます。モデルを指定しない場合は [デフォルトモデル](#available-models) が使用されます。 + +### 生成パラメーター + +以下の生成パラメーターを設定して、モデルの動作をカスタマイズします。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[Cohere API ドキュメント](https://docs.cohere.com/reference/chat) を参照してください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## ヘッダーパラメーター + +リクエストに追加ヘッダーを付与することで、実行時に API キーおよびいくつかのオプションパラメーターを指定できます。利用可能なヘッダーは次のとおりです: + +- `X-Cohere-Api-Key`: Cohere の API キー。 +- `X-Cohere-Baseurl`: デフォルトの Cohere URL の代わりに使用するベース URL(例: プロキシ)。 + +実行時に指定した追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +ヘッダーは上記の [API credentials の例](#api-credentials) のとおりに指定してください。 + +## 検索拡張生成 + +生成 AI 連携を設定したら、[シングルプロンプト](#single-prompt) または [グループタスク](#grouped-task) のいずれかの方法で RAG 操作を実行します。 + +### シングルプロンプト + +![シングルプロンプト RAG 連携は検索結果ごとに個別の出力を生成します](../_includes/integration_cohere_rag_single.png) + +検索結果に含まれる各オブジェクトに対してテキストを生成するには、シングルプロンプト方式を使用します。 + +次の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +シングルプロンプトクエリを作成するときは、波括弧 `{}` を使用して、Weaviate から言語モデルへ渡したいオブジェクトのプロパティを埋め込みます。たとえばオブジェクトの `title` プロパティを渡すには、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループタスク + +![グループタスク RAG 連携は検索結果全体に対して 1 つの出力を生成します](../_includes/integration_cohere_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成するには、グループタスク方式を使用します。 + +言い換えると、`n` 件の検索結果があっても、生成モデルはグループ全体に対して 1 つの出力を返します。 + + + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +- `command-r-plus` ( `v1.25.0` で追加) +- `command-r`(デフォルト)( `v1.25.0` で追加) +- `command-xlarge` +- `command-xlarge-beta` +- `command-xlarge-nightly` +- `command-medium` +- `command-medium-nightly` +- `command` +- `command-nightly` +- `command-light` +- `command-light-nightly` + +## 追加リソース + +### その他の統合 + +- [Cohere text embedding models + Weaviate](./embeddings.md) +- [Cohere multimodal embedding embeddings models + Weaviate](./embeddings-multimodal.md) +- [Cohere reranker models + Weaviate](./reranker.md) + +### コード例 + +コレクションで統合を構成すると、Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) のガイドでは、データ操作(コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除)の方法を示しています。 +- [How-to: クエリと検索](../../search/index.mdx) のガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索に加えて 検索拡張生成 を実行する方法を示しています。 + +### 参照 + +- Cohere [Chat API documentation](https://docs.cohere.com/reference/chat) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/index.md new file mode 100644 index 000000000..4b7451602 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/index.md @@ -0,0 +1,69 @@ +--- +title: Cohere + Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_cohere.jpg +# tags: ['model providers', 'cohere'] +--- + + + +Cohere は、自然言語処理と生成のための幅広いモデルを提供しています。Weaviate は Cohere の API とシームレスに統合され、ユーザーは Weaviate Database から直接 Cohere のモデルを利用できます。 + +これらの統合により、開発者は高度な AI ドリブンアプリケーションを簡単に構築できるようになります。 + +## Cohere との統合 + +### ベクトル検索向け埋め込みモデル + +![Embedding integration illustration](../_includes/integration_cohere_embedding.png) + +Cohere の埋め込みモデルは、テキストデータを意味と文脈を捉えたベクトル埋め込みに変換します。 + +[Weaviate は Cohere の埋め込みモデルと統合](./embeddings.md)しており、データをシームレスにベクトル化できます。この統合により、追加の前処理やデータ変換なしにセマンティック検索やハイブリッド検索を実行できます。 + +[Cohere 埋め込み統合ページ](./embeddings.md) +[Cohere マルチモーダル埋め込み統合ページ](./embeddings-multimodal.md) + +### RAG 向け生成 AI モデル + +![Single prompt RAG integration generates individual outputs per search result](../_includes/integration_cohere_rag_single.png) + +Cohere の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間らしいテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md)により、Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。これにより、Weaviate の効率的なストレージと高速検索機能が Cohere の生成 AI モデルと組み合わさり、パーソナライズされた文脈対応の応答を生成します。 + +[Cohere 生成 AI 統合ページ](./generative.md) + +### Reranker モデル + +![Reranker integration illustration](../_includes/integration_cohere_reranker.png) + +Cohere の reranker モデルは、検索結果の関連性とランキングを向上させるよう設計されています。 + +[Weaviate の reranker 統合](./reranker.md)を利用することで、Cohere の reranker モデルを活用し、検索結果を簡単にリファインできます。 + +[Cohere reranker 統合ページ](./reranker.md) + +## 概要 + +これらの統合により、開発者は Cohere の強力なモデルを Weaviate 内で直接活用できます。 + +その結果、AI ドリブンアプリケーション開発のプロセスが簡素化され、開発スピードが向上し、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を利用するには、Weaviate に有効な Cohere API キーを提供する必要があります。[Cohere](https://cohere.com/) にアクセスしてサインアップし、API キーを取得してください。 + +その後、該当する統合ページで Cohere モデルを Weaviate に設定し、アプリケーションでの利用を開始しましょう。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) +- [Reranker](./reranker.md) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/reranker.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/reranker.md new file mode 100644 index 000000000..3abb249fd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/cohere/reranker.md @@ -0,0 +1,221 @@ +--- +title: リランカー +description: Cohere リランカー モデルプロバイダー +sidebar_position: 70 +image: og/docs/integrations/provider_integrations_cohere.jpg +# tags: ['model providers', 'cohere', 'reranking'] +--- + +# Weaviate との Cohere リランカー モデル + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.reranker.py'; +import TSCode from '!!raw-loader!../_includes/provider.reranker.ts'; + +Weaviate は Cohere の API と統合することで、同社のモデル機能に直接アクセスできます。 + +Cohere のリランカーモデルを使用するように [ Weaviate コレクションを設定](#configure-the-reranker) すると、 Weaviate は指定したモデルとお客様の Cohere API キーを使用して検索結果をリランクします。 + +この 2 ステップのプロセスでは、まず Weaviate が検索を実行し、その後指定したモデルを使用して結果をリランクします。 + +![リランカー統合の図](../_includes/integration_cohere_reranker.png) + +## 要件 + +### Weaviate 構成 + +お使いの Weaviate インスタンスは、 Cohere リランカー統合(`reranker-cohere`)モジュールを有効にしておく必要があります。 + +
+ Weaviate Cloud ( WCD ) ユーザー向け + +この統合は、 Weaviate Cloud ( WCD ) の serverless インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効になっているか確認するには、 [ クラスター メタデータ ](/deploy/configuration/meta.md) を確認してください。 +- モジュールを Weaviate で有効にするには、 [ モジュールの構成方法 ](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 資格情報 + +この統合には、 Weaviate に有効な Cohere API キーを提供する必要があります。 [ Cohere ](https://cohere.com/) にアクセスしてサインアップし、 API キーを取得してください。 + +次のいずれかの方法で Weaviate に API キーを渡してください: + +- `COHERE_APIKEY` 環境変数を設定し、 Weaviate から参照できるようにします。 +- 以下の例のように、実行時に API キーを渡します。 + + + + + + + + + + + + + +## リランカーの設定 + +import MutableRerankerConfig from '/_includes/mutable-reranker-config.md'; + + + +以下のように設定して、 Weaviate コレクションで Cohere リランカー モデルを使用します。 + + + + + + + + + + + + +### モデルを選択する + +以下の設定例のように、 Weaviate が使用する [ 利用可能なモデル ](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + +モデルを指定しない場合は、 [ デフォルトモデル ](#available-models) が使用されます。 + +## ヘッダー パラメーター + +リクエストの追加ヘッダーを通じて、実行時に API キーおよびオプション パラメーターを設定できます。利用可能なヘッダーは次のとおりです: + +- `X-Cohere-Api-Key`: Cohere API キー +- `X-Cohere-Baseurl`: デフォルトの Cohere URL の代わりに使用するベース URL (例: プロキシ) + +実行時に指定した追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +ヘッダーの指定方法は、上記の [API 認証情報の例](#api-credentials) を参照してください。 + +## リランキング クエリ + +リランカーの設定が完了すると、Weaviate は指定した Cohere モデルを使用して [リランキング処理](../../search/rerank.md) を実行します。 + +具体的には、まず Weaviate が初期検索を行い、その結果を指定したモデルでリランキングします。 + +Weaviate のあらゆる検索はリランカーと組み合わせてリランキングを実行できます。 + +![Reranker integration illustration](../_includes/integration_cohere_reranker.png) + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +- `rerank-v3.5` (default) +- `rerank-english-v3.0` +- `rerank-multilingual-v3.0` +- `rerank-english-v2.0` +- `rerank-multilingual-v2.0` + +以下のようなファインチューニング済みリランカーの model_id も選択できます: + +- `500df123-afr3-...` + +詳細は [こちらのブログ記事](https://weaviate.io/blog/fine-tuning-coheres-reranker) をご覧ください。 + +モデル パラメーターの詳細については [Cohere API ドキュメント](https://docs.cohere.com/reference/rerank) を参照してください。 + +## 追加リソース + +### その他のインテグレーション + +- [Cohere テキスト埋め込みモデル + Weaviate](./embeddings.md) +- [Cohere マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) +- [Cohere 生成モデル + Weaviate](./generative.md) + +### コード例 + +コレクションでインテグレーションを設定すると、Weaviate のデータ管理および検索操作は他のコレクションと同様に動作します。モデル非依存の次の例をご覧ください: + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) のガイドでは、データ操作 (コレクションおよびその中のオブジェクトの作成、読み取り、更新、削除) を行う方法を示しています。 +- [How-to: Query & Search](../../search/index.mdx) のガイドでは、検索操作 ( ベクトル、キーワード、ハイブリッド) と 検索拡張生成 を実行する方法を説明しています。 + +### 参照 + +- Cohere [Rerank API ドキュメント](https://docs.cohere.com/reference/rerank) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/_category_.json new file mode 100644 index 000000000..6d57dd6c8 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Databricks", + "position": 221 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/embeddings.md new file mode 100644 index 000000000..74a974b96 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/embeddings.md @@ -0,0 +1,295 @@ +--- +title: テキスト 埋め込み +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_databricks.jpg +# tags: ['model providers', 'databricks', 'embeddings'] +--- + +:::info Added in `v1.26.3` +::: + +# Weaviate と Databricks の埋め込み + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate の Databricks API 連携により、Databricks プラットフォームでホストされているモデルへ Weaviate から直接アクセスできます。 + +[Weaviate ベクトル インデックスを設定](#configure-the-vectorizer)して Databricks の埋め込みモデルを使用すると、指定したエンドポイントと Databricks トークンを用いて、さまざまな操作のために Weaviate が埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import)には、Weaviate がテキストオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) や [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![Embedding integration illustration](../_includes/integration_databricks_embedding.png) + +## 必要条件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスには、Databricks ベクトライザー連携 (`text2vec-databricks`) モジュールが組み込まれている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この連携は、Weaviate Cloud (WCD) のサーバーレス インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスト ユーザーの場合 + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効になっているかを確認してください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### Databricks Personal Access Token {#api-credentials} + +この連携には、有効な Databricks Personal Access Token (PAT) を Weaviate に提供する必要があります。ワークスペースでの PAT 生成方法については、[Databricks のドキュメント](https://docs.databricks.com/en/dev-tools/auth/pat.html) を参照してください。 + +以下のいずれかの方法で Databricks トークンを Weaviate に渡します。 + +- Weaviate が参照できる `DATABRICKS_TOKEN` 環境変数を設定する +- 下記の例のように実行時にトークンを渡す + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +Databricks のサービングモデル エンドポイントを使用するように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) するには、次のようにベクトライザーを指定します。 + + + + + + + + + + + + + + + + +これにより、指定したエンドポイントで提供されるベクトライザーを Weaviate が使用するように構成されます。 + + + +### ベクトライザーのパラメーター + +- `endpoint`: Databricks にホストされている埋め込みモデルの URL です。 +- `instruction`: 埋め込みモデルに渡す任意の instruction です。 + +モデルパラメーターの詳細については、[Databricks のドキュメント](https://docs.databricks.com/en/machine-learning/foundation-models/api-reference.html#embedding-request) を参照してください。 + +## ヘッダーパラメーター + +リクエストに追加ヘッダーを付与することで、実行時に API キーおよび任意のパラメーターを指定できます。利用可能なヘッダーは次のとおりです: + +- `X-Databricks-Token`: Databricks API トークンです。 +- `X-Databricks-Endpoint`: Databricks モデルで使用する endpoint です。 +- `X-Databricks-User-Agent`: Databricks モデルで使用する user agent です。 + +実行時に指定したその他のヘッダーは、既存の Weaviate の設定を上書きします。 + +ヘッダーは上記の [API 資格情報の例](#api-credentials) のとおりに指定してください。 + +## データインポート + +ベクトライザーの設定が完了したら、Weaviate に[データをインポート](../../manage-objects/import.mdx)します。Weaviate は [指定したモデル](#vectorizer-parameters) を使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + +:::tip 既存ベクトルを再利用する +互換性のあるモデル ベクトルが既にある場合は、それを直接 Weaviate に渡すことができます。同じモデルで既に埋め込みを生成しており、それらを Weaviate で使用したい場合、例えば他のシステムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、Weaviate は指定したモデルを使用してベクトル検索とハイブリッド検索を実行します。 + +![Embedding integration at search illustration](../_includes/integration_databricks_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、Weaviate はクエリー文字列を指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリーは、`limit` で指定した数 `n` の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索はベクトル検索とキーワード (BM25) 検索を行い、[結果を結合](../../search/hybrid.md)してデータベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、Weaviate はクエリー文字列を指定したモデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +以下のクエリーは、`limit` で指定した数 `n` の最もスコアの高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + + +## 参考資料 + +## 追加リソース + +### 他のインテグレーション + +- [Databricks 生成モデル + Weaviate](./generative.md) + +### コード例 + +コレクションで統合を設定すると、Weaviate でのデータ管理および検索操作は他のコレクションとまったく同じ方法で動作します。以下のモデル非依存の例をご覧ください: + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) ガイドでは、データ操作 (例: コレクションとその中のオブジェクトの作成、読み取り、更新、削除) の方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作 (例: ベクトル、キーワード、ハイブリッド) と検索拡張生成の方法を解説しています。 + +### 外部リソース + +- Databricks [Foundation model REST API リファレンス](https://docs.databricks.com/en/machine-learning/foundation-models/api-reference.html) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/generative.md new file mode 100644 index 000000000..2352a2557 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/generative.md @@ -0,0 +1,261 @@ +--- +title: 生成 AI +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_databricks.jpg +# tags: ['model providers', 'databricks', 'generative', 'rag'] +--- + +:::info `v1.26.3` で追加 +::: + +# Weaviate と Databricks の 生成 AI + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate と Databricks の API の統合により、Databricks のモデル機能に Weaviate から直接アクセスできます。 + +[Weaviate のコレクションを設定](#configure-collection) して、Databricks の生成 AI モデルを利用します。Weaviate は、指定したエンドポイントと Databricks トークンを使って 検索拡張生成 (RAG) を実行します。 + +具体的には、Weaviate が検索を実行し、最も関連性の高いオブジェクトを取得したうえで、それらを Databricks の生成モデルに渡して出力を生成します。 + +![RAG 連携の図](../_includes/integration_databricks_rag.png) + +## 要件 + +### Weaviate 構成 + +ご利用の Weaviate インスタンスには、Databricks 生成 AI 連携 (`generative-databricks`) モジュールが設定されている必要があります。 + +
+ Weaviate Cloud (WCD) 利用者向け + +この連携は Weaviate Cloud (WCD) のサーバーレス インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスト利用者向け + +- モジュールが有効になっているか確認するため、[クラスターメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効化するには、[モジュール構成方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 資格情報 + +この連携を利用するには、有効な Databricks Personal Access Token (PAT) を Weaviate に渡す必要があります。PAT の生成方法については、[Databricks のドキュメント](https://docs.databricks.com/en/dev-tools/auth/pat.html) を参照してください。 + +次のいずれかの方法で Databricks トークンを Weaviate に提供します。 + +- Weaviate から参照可能な `DATABRICKS_TOKEN` 環境変数を設定する。 +- 以下の例のように、実行時に API キーを渡す。 + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +[Weaviate のコレクションを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration) し、次のように Databricks の生成 AI エンドポイントを指定してください。 + + + + + + + + + + + +これにより、指定したエンドポイントで提供される生成 AI モデルを Weaviate が使用するように設定されます。 + +### 生成パラメーター + +モデルの動作をカスタマイズするため、以下の生成パラメーターを設定できます。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[Databricks のドキュメント](https://docs.databricks.com/en/machine-learning/foundation-models/api-reference.html#chat-task) を参照してください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## ヘッダー パラメーター + +API キーのほか、いくつかのオプションパラメーターを追加ヘッダーとして実行時に渡すことができます。利用可能なヘッダーは次のとおりです。 + +- `X-Databricks-Token`: Databricks API トークン。 +- `X-Databricks-Endpoint`: Databricks モデルに使用するエンドポイント。 +- `X-Databricks-User-Agent`: Databricks モデルに使用するユーザーエージェント。 + +実行時に渡された追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +ヘッダーは上記の [API 資格情報の例](#api-credentials) のとおりに指定してください。 + +## 検索拡張生成 + +生成 AI 連携を設定した後、[シングル プロンプト](#single-prompt) または [グループ化タスク](#grouped-task) の方法で RAG 操作を実行します。 + +### シングル プロンプト + +![シングル プロンプト RAG 連携は検索結果ごとに個別の出力を生成します](../_includes/integration_databricks_rag_single.png) + +検索結果内の各オブジェクトに対してテキストを生成するには、シングル プロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +シングル プロンプト クエリを作成する際は、Weaviate が言語モデルへ渡すオブジェクトプロパティを中かっこ `{}` で記述してください。たとえばオブジェクトの `title` プロパティを渡すには、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスク RAG 連携は検索結果のセットに対して 1 つの出力を生成します](../_includes/integration_databricks_rag_grouped.png) + +検索結果のセット全体に対して 1 つのテキストを生成するには、グループ化タスク方式を使用します。 + +言い換えれば、`n` 件の検索結果があっても、生成モデルはグループ全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + + + +## 追加リソース + +### その他の連携 + +- [Databricks 埋め込みモデル + Weaviate](./embeddings.md) + +### コード例 + +コレクションで連携を設定すると、Weaviate でのデータ管理および検索操作は他のコレクションと同一になります。以下にモデル非依存の例を示します。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその内部オブジェクトの作成、読み取り、更新、削除)方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索、そして 検索拡張生成 の方法を説明しています。 + +### 参考資料 + +- [Databricks foundation model ドキュメント](https://docs.databricks.com/en/machine-learning/foundation-models/api-reference.html) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/index.md new file mode 100644 index 000000000..2538e2b39 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/databricks/index.md @@ -0,0 +1,60 @@ +--- +title: Databricks と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_databricks.jpg +# tags: ['model providers', 'databricks'] +--- + + + +:::info `v1.26.3` で追加 +::: + +Databricks は、自然言語処理と生成のために幅広いモデルを提供しています。 + Weaviate は Databricks の Foundation Model API とシームレスに統合されており、ユーザーは Weaviate Database から直接 Databricks のモデルを活用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## Databricks との統合 + +### ベクトル検索用の埋め込みモデル + +![Embedding integration illustration](../_includes/integration_databricks_embedding.png) + +Databricks の埋め込みモデルは、テキストデータを意味と文脈を捉えた ベクトル 埋め込みへと変換します。 + +[Weaviate は Databricks の埋め込みモデルと統合](./embeddings.md) し、データのシームレスなベクトル化を実現します。これにより、追加の前処理やデータ変換を行うことなく、セマンティック検索やハイブリッド検索を実行できます。 + +[Databricks 埋め込み統合ページ](./embeddings.md) + +### RAG 用の生成 AI モデル + +![Single prompt RAG integration generates individual outputs per search result](../_includes/integration_openai_rag_single.png) + +Databricks の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間のようなテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md) は、Weaviate Database から直接 検索拡張生成 (RAG) を実行できるようにします。これにより、Weaviate の効率的なストレージと高速な検索機能を Databricks の生成 AI モデルと組み合わせて、パーソナライズされた文脈に応じた回答を生成します。 + +[Databricks 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は Databricks の強力なモデルを Weaviate 内で直接活用できます。 + +その結果、AI 駆動アプリケーションの開発プロセスが簡素化され、開発スピードが向上し、より革新的なソリューションの創出に集中できます。 + +## はじめる + +これらの統合を利用するには、Databricks のパーソナルアクセス トークンを Weaviate に提供する必要があります。トークンの生成方法については、[Databricks のドキュメント](https://docs.databricks.com/en/dev-tools/auth/pat.html) を参照してください。 + +その後、該当する統合ページで Weaviate を OpenAI モデルと連携する方法を確認し、アプリケーションでご利用ください。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/_category_.json new file mode 100644 index 000000000..f7611a6c0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "FriendliAI", + "position": 221 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/generative.md new file mode 100644 index 000000000..fb13d5e2c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/generative.md @@ -0,0 +1,337 @@ +--- +title: 生成 AI +sidebar_position: 51 +image: og/docs/integrations/provider_integrations_friendliai.jpg +# tags: ['model providers', 'friendliai', 'generative', 'rag'] +--- + +# Weaviate と FriendliAI の生成 AI + +:::info `v1.26.3` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate の FriendliAI API 連携を利用すると、FriendliAI のモデル機能に Weaviate から直接アクセスできます。 + +FriendliAI の生成 AI モデルを使用するように [Weaviate のコレクションを設定](#configure-collection) してください。指定したモデルと Friendli トークンを用いて、Weaviate が 検索拡張生成 (RAG) を実行します。 + +具体的には、Weaviate が検索を実行して最も関連性の高いオブジェクトを取得し、それらを FriendliAI の生成モデルに渡して出力を生成します。 + +![RAG 連携のイメージ](../_includes/integration_friendliai_rag.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスには、FriendliAI 生成 AI 連携 (`generative-friendliai`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この連携は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかは、[クラスターメタデータ](/deploy/configuration/meta.md) で確認してください。 +- Weaviate でモジュールを有効にする手順は、[モジュール設定方法](../../configuration/modules.md) ガイドを参照してください。 + +
+ +### API 資格情報 + +この連携を利用するには、有効な Friendli Suite Token を Weaviate に提供する必要があります。登録とトークン取得は [Friendli Suite](https://docs.friendli.ai/openapi/create-chat-completions) で行えます。 + +Friendli トークンは、次のいずれかの方法で Weaviate に渡してください。 + +- Weaviate で参照可能な `FRIENDLI_TOKEN` 環境変数を設定する +- 下記の例のように実行時にトークンを渡す + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +FriendliAI の生成 AI モデルを使用するには、以下のように [Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration) します。 + + + + + + + + + + + + +### モデルの選択 + +次の設定例のように、Weaviate に使用させる [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを [指定](#generative-parameters) できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +### 生成パラメーター + +次の生成パラメーターを設定して、モデルの挙動をカスタマイズします。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[FriendliAI の API ドキュメント](https://docs.friendli.ai/openapi/create-chat-completions) を参照してください。 + +## 実行時のモデル選択 + +コレクションを作成するときにデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## ヘッダーパラメーター + +リクエストに追加のヘッダーを付与することで、実行時に API キーと任意のパラメーターを指定できます。利用可能なヘッダーは次のとおりです。 + +- `X-Friendli-Api-Key`: Friendli の API キー。 +- `X-Friendli-Baseurl`: 既定の Friendli URL の代わりに使用するベース URL(例: プロキシ)。 + +実行時に指定した追加ヘッダーは、既存の Weaviate の設定を上書きします。 + +ヘッダーの指定方法については、上記の [API credentials の例](#api-credentials) を参照してください。 + +## 検索拡張生成 + +生成 AI との統合を設定したら、[single prompt](#single-prompt) もしくは [grouped task](#grouped-task) のいずれかの方法で RAG 操作を実行します。 + +### シングルプロンプト + +![シングルプロンプトの RAG 統合は、検索結果ごとに個別の出力を生成します](../_includes/integration_friendliai_rag_single.png) + +検索結果の各オブジェクトに対してテキストを生成する場合は、シングルプロンプト方式を使用します。 + +次の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +シングルプロンプト クエリを作成する際は、波かっこ `{}` を使用して、言語モデルに渡したいオブジェクトのプロパティを埋め込みます。たとえば、オブジェクトの `title` プロパティを渡す場合は、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループタスク + +![グループタスクの RAG 統合は、検索結果の集合に対して 1 つの出力を生成します](../_includes/integration_friendliai_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成する場合は、グループタスク方式を使用します。 + +言い換えると、`n` 件の検索結果がある場合でも、生成モデルはグループ全体に対して 1 つの出力だけを生成します。 + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +* `meta-llama-3.1-70b-instruct` (default) +* `meta-llama-3.1-8b-instruct` +* `mixtral-8x7b-instruct-v0-1` + +Weaviate とともに Friendli Suite にデプロイされた任意のモデルを使用できます。 + +FriendliAI が提供する [利用可能なモデル](https://friendli.ai/models) は幅広く、オプションで [ファインチューニング](https://docs.friendli.ai/guides/dedicated_endpoints/fine-tuning) も可能です。手順については [FriendliAI クイックスタートガイド](https://docs.friendli.ai/guides/dedicated_endpoints/quickstart) を参照してください。 + +Weaviate との統合で専用の FriendliAI エンドポイントを使用する場合は、以下のように指定します。 + + + + + + + + + + + + + + + + + + + + + + + + +## 追加リソース + +### コード例 + +コレクションで統合が構成されると、Weaviate におけるデータ管理および検索操作は他のコレクションと同様に動作します。以下のモデル非依存の例を参照してください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) および [How-to: Manage objects](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)を行う方法を示しています。 +- [How-to: Query & Search](../../search/index.mdx) ガイドでは、検索操作(ベクトル、キーワード、ハイブリッド)と検 索拡張生成の実行方法を説明しています。 + +### 参照 + +- [FriendliAI API ドキュメント](https://docs.friendli.ai/openapi/create-chat-completions) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/index.md new file mode 100644 index 000000000..c8f284d55 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/friendliai/index.md @@ -0,0 +1,46 @@ +--- +title: FriendliAI と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_friendliai.jpg +# tags: ['model providers', 'friendliai'] +--- + + + +:::info `v1.26.3` で追加されました +::: + + FriendliAI は、自然言語処理および生成のための幅広いモデルを提供しています。 Weaviate は FriendliAI の API とシームレスに統合され、ユーザーは Weaviate Database 内で FriendliAI の推論エンジンを利用できます。 + + FriendliAI との統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## FriendliAI との統合 + +### RAG 向け生成 AI モデル + +![単一プロンプトの RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_friendliai_rag_single.png) + + FriendliAI の生成 AI モデルは、指定されたプロンプトとコンテキストに基づいて人間のようなテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md) を使用すると、Weaviate Database から直接 Retrieval Augmented Generation (RAG) を実行できます。これにより、 Weaviate の効率的なストレージと高速検索機能に FriendliAI の生成 AI モデルを組み合わせ、パーソナライズされたコンテキスト認識の応答を生成します。 + +詳しくは、[FriendliAI 生成 AI 統合ページ](./generative.md) をご覧ください。 + +## まとめ + +この統合により、開発者は Weaviate 内で FriendliAI の推論エンジンのパワーを活用できます。 + +その結果、 AI 駆動アプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を利用するには、有効な Friendli トークン (Personal Access Token) を Weaviate に提供する必要があります。 [Friendli Suite](https://suite.friendli.ai/) にアクセスしてサインアップし、パーソナルアクセストークンを取得してください。 + +次に、該当する統合ページで、 FriendliAI モデルを Weaviate に設定する方法を確認し、アプリケーションで使用を開始しましょう。 + +- [生成 AI](./generative.md) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/_category_.json new file mode 100644 index 000000000..1b646bcca --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Google", + "position": 225 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/_includes/use_google_auth_instructions.mdx b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/_includes/use_google_auth_instructions.mdx new file mode 100644 index 000000000..419de7db9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/_includes/use_google_auth_instructions.mdx @@ -0,0 +1,33 @@ +:::info Added in +Weaviate バージョン `1.24.16`, `1.25.3` および `1.26` から追加されました。 +::: + +:::info Not available on Weaviate Cloud instances +この機能は Weaviate Cloud インスタンスでは利用できません。 +::: + +Google Vertex AI の認証情報を保存し、Weaviate に必要なトークンを生成させることができます。これにより、Google の認証情報を保持できるプライベート環境で IAM サービス アカウントを使用できます。 + +手順は次のとおりです。 + +- `USE_GOOGLE_AUTH` [環境変数](/deploy/configuration/env-vars/index.md#module-specific) を `true` に設定します。 +- 認証情報ファイルを以下のいずれかの場所に配置します。 + +適切な認証情報が見つかると、Weaviate はそれを使用してアクセストークンを生成し、Vertex AI に対して自身を認証します。トークンが期限切れになると、Weaviate は新しいアクセストークンを生成します。 + +コンテナ環境では、認証情報ファイルをコンテナにマウントできます。たとえば、認証情報ファイルを `/etc/weaviate/` ディレクトリにマウントし、`GOOGLE_APPLICATION_CREDENTIALS` 環境変数を `/etc/weaviate/google_credentials.json` に設定します。 + +
+ + Google Vertex AI 認証情報の検索場所 + + +`USE_GOOGLE_AUTH` を `true` に設定すると、Weaviate は次の場所で認証情報を検索し、最初に見つかった場所を優先します。 + +1. `GOOGLE_APPLICATION_CREDENTIALS` 環境変数で指定されたパスの JSON ファイル。ワークロード アイデンティティ フェデレーションの場合、オンプレミスや非 Google クラウド プラットフォーム向けの JSON 構成ファイルの生成方法については [こちら](https://cloud.google.com/iam/docs/how-to#using-workload-identity-federation) を参照してください。 +2. `gcloud` コマンドライン ツールが認識する場所にある JSON ファイル。Windows では `%APPDATA%/gcloud/application_default_credentials.json`、その他のシステムでは `$HOME/.config/gcloud/application_default_credentials.json` です。 +3. Google App Engine Standard 第 1 世代ランタイム (<= Go 1.9) では、`appengine.AccessToken` 関数を使用します。 +4. Google Compute Engine、Google App Engine Standard 第 2 世代ランタイム (>= Go 1.11)、および Google App Engine Flexible Environment では、メタデータ サーバーから認証情報を取得します。 + +
+ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/embeddings-multimodal.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/embeddings-multimodal.md new file mode 100644 index 000000000..e463f5253 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/embeddings-multimodal.md @@ -0,0 +1,344 @@ +--- +title: マルチモーダル埋め込み +sidebar_position: 25 +image: og/docs/integrations/provider_integrations_google.jpg +# tags: ['model providers', 'google', 'embeddings'] +--- + +# Weaviate における Google マルチモーダル埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +[Google Vertex AI](https://cloud.google.com/vertex-ai) API と Weaviate の統合により、モデルの機能を Weaviate から直接利用できます。 + +:::note Gemini API は利用できません +現在、Google Gemini API ではマルチモーダル埋め込みを利用できません。 +::: + +[ベクトルインデックスを設定](#configure-the-vectorizer) して Google の埋め込みモデルを使用すると、Weaviate は指定したモデルと Google API キーを使って各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) には、Weaviate がマルチモーダルオブジェクト埋め込みを生成してインデックスに保存します。[ ベクトル ](#vector-near-text-search) および [ ハイブリッド ](#hybrid-search) 検索では、Weaviate が 1 種類以上のモダリティのクエリを埋め込みに変換します。[ マルチモーダル検索操作 ](#vector-near-media-search) にも対応しています。 + +![Embedding integration illustration](../_includes/integration_google_embedding.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスでは、Google マルチモーダルベクトライザー統合モジュール (`multi2vec-google`) を有効にしておく必要があります。 + +:::info モジュール名の変更 +`multi2vec-google` は Weaviate `v1.27` 以前では `multi2vec-palm` という名称でした。 +::: + +
+ Weaviate Cloud (WCD) をご利用の場合 + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスト環境の場合 + +- [ クラスターメタデータ ](/deploy/configuration/meta.md) でモジュールが有効かどうかを確認してください。 +- Weaviate でモジュールを有効にする手順は、[モジュール設定方法](../../configuration/modules.md) をご覧ください。 + +
+ +### API 認証情報 + +適切な統合を行うため、Weaviate には有効な API 認証情報を提供する必要があります。 + +#### Vertex AI + +Google Cloud では `access token` と呼ばれます。 + +##### トークンの自動生成 + +import UseGoogleAuthInstructions from './_includes/use_google_auth_instructions.mdx'; + + + +##### トークンを手動で取得する + +[Google Cloud CLI ツール](https://cloud.google.com/cli) がインストール済みで設定が完了している場合、次のコマンドでトークンを確認できます。 + +```shell +gcloud auth print-access-token +``` + +#### Vertex AI ユーザー向けトークンの有効期限 + +import GCPTokenExpiryNotes from '/_includes/gcp.token.expiry.notes.mdx'; + + + +#### API キーの提供 + +以下の例のように、実行時に Weaviate へ API キーを渡してください。 + + + +import ApiKeyNote from '../_includes/google-api-key-note.md'; + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +Google 埋め込みモデルを使用できるよう、[ Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します。 + + + + + + + + API v + + + + +[ 使用可能なモデル ](#available-models) のいずれかを [指定](#vectorizer-parameters) できます。現在利用可能なモデルは `multimodalembedding@001` のみです。 + + + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ + + +### ベクトライザーのパラメーター + +以下の例では、Google 固有のオプションの設定方法を示します。 + +- `location` (必須): 例: `"us-central1"` +- `projectId` (Vertex AI を使用する場合のみ必須): 例: `cloud-large-language-models` +- `apiEndpoint` (オプション): 例: `us-central1-aiplatform.googleapis.com` +- `modelId` (オプション): 例: `multimodalembedding@001` +- `dimensions` (オプション): 次のいずれかである必要があります: `128`, `256`, `512`, `1408`。デフォルトは `1408` です。 + + + + + + + + + + + + +## データのインポート + +ベクトライザーを設定したら、Weaviate へ [データをインポートする](../../manage-objects/import.mdx) と、指定したモデルを使用してオブジェクトの埋め込みが生成されます。 + + + + + + + + + + + + + +:::tip 既存のベクトルを再利用する +すでに互換性のあるモデルのベクトルをお持ちであれば、それを直接 Weaviate に渡すことができます。同じモデルで事前に埋め込みを生成しており、別のシステムからデータを移行する場合などに役立ちます。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した Google モデルを用いてベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイラスト](../_includes/integration_google_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を行うと、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で指定した `n` 件の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を実行し、その結果を [組み合わせて](../../search/hybrid.md) データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +次のクエリは、`limit` で指定した `n` 件の最もスコアの高いオブジェクトを返します。 + + + + + + + + + + + + + + +### ベクトル(near media)検索 + +例えば near image search のようなメディア検索を実行すると、 Weaviate は指定したモデルを使用してクエリを埋め込み(embedding)に変換し、データベースから最も類似したオブジェクトを返します。 + + near image search のような near media search を実行するには、メディアクエリを base64 文字列に変換し、それを検索クエリに渡します。 + +以下のクエリは、`limit` で指定した数 n 件の入力画像に最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参考 + +### 利用可能なモデル + +- `multimodalembedding@001` (デフォルト) + +## 追加リソース + +### 他のインテグレーション + +- [Google テキスト埋め込みモデル + Weaviate](./embeddings.md) +- [Google AI 生成モデル + Weaviate](./generative.md) + +### コード例 + +コレクションでインテグレーションを設定すると、 Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように機能します。モデル非依存の例は以下を参照してください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)を実行する方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作( vector、 keyword、 hybrid)や 検索拡張生成 を実行する方法を説明しています。 + +### 外部リソース + +- [Google Vertex AI](https://cloud.google.com/vertex-ai) +- [Google Gemini API](https://ai.google.dev/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/embeddings.md new file mode 100644 index 000000000..14902c49e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/embeddings.md @@ -0,0 +1,432 @@ +--- +title: テキスト Embeddings +description: "Weaviate の Google Gemini API および Google Vertex AI API との統合により、これらのモデルの機能へ Weaviate から直接アクセスできます。" +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_google.jpg +# tags: ['model providers', 'google', 'embeddings'] +--- + +# Weaviate での Google テキスト Embeddings + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate と [Google Gemini API](https://ai.google.dev/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) および [Google Vertex AI](https://cloud.google.com/vertex-ai) API との統合により、これらのモデルの機能へ Weaviate から直接アクセスできます。 + +[Weaviate ベクトルインデックスを設定](#configure-the-vectorizer) して Google の埋め込みモデルを使用すると、Weaviate は指定したモデルとお持ちの Google API キーを用いてさまざまな操作のために埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) には、Weaviate がテキストオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![Embedding integration illustration](../_includes/integration_google_embedding.png) + +:::info Gemini API の提供状況 +執筆時点(2023 年 11 月)では、Gemini API はすべてのリージョンで利用できるわけではありません。最新情報は [こちらのページ](https://ai.google.dev/gemini-api/docs/available-regions) をご覧ください。 +::: + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスには、Google ベクトライザー統合(`text2vec-google`)モジュールが有効になっている必要があります。 + +:::info モジュール名の変更 +`text2vec-google` は Weaviate v1.27 より前のバージョンでは `text2vec-palm` と呼ばれていました。 +::: + +
+ Weaviate Cloud (WCD) ユーザーの方へ + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザーの方へ + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### API 認証情報 + +該当する統合用の有効な API 認証情報を Weaviate に提供する必要があります。 + +#### Gemini API + +[Google Gemini API](https://aistudio.google.com/app/apikey/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) にアクセスし、サインアップして API キーを取得してください。 + +#### Vertex AI + +Google Cloud では `access token` と呼ばれます。 + +##### 自動トークン生成 + +import UseGoogleAuthInstructions from './_includes/use_google_auth_instructions.mdx'; + + + +[Google Cloud CLI ツール](https://cloud.google.com/cli) がインストール済みで設定されている場合、次のコマンドでトークンを確認できます。 + +```shell +gcloud auth print-access-token +``` + +#### Vertex AI ユーザー向けのトークン有効期限 + +import GCPTokenExpiryNotes from '/_includes/gcp.token.expiry.notes.mdx'; + + + +#### API キーの提供 + +以下の例のように、実行時に Weaviate へ API キーを渡してください。 + +[Gemini API](#gemini-api) と [Vertex AI](#vertex-ai) 向けに用意された別々のヘッダーに注意してください。 + +import ApiKeyNote from '../_includes/google-api-key-note.md'; + + + + + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) して、 Google 埋め込みモデルを使用するには次のようにします: + +必須パラメーターは Vertex AI と Gemini API で異なる点にご注意ください。 + +Weaviate で使用する [利用可能なモデル](#available-models) のいずれかを [指定](#vectorizer-parameters) できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +### Vertex AI + +Vertex AI のユーザーは、ベクトライザー設定で Google Cloud プロジェクト ID を指定する必要があります。 + + + + + + + + + + + + + + + + +### Gemini API + + + + + + + + + + + + + + + + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ +### ベクトライザーのパラメーター + +以下の例では、 Google 固有のオプションを設定する方法を示します。 + +- `projectId` ( Vertex AI 使用時のみ必須): 例 `cloud-large-language-models` +- `apiEndpoint` (任意): 例 `us-central1-aiplatform.googleapis.com` +- `modelId` (任意): 例 `gemini-embedding-001` + + + + + + + + + + + + + + + + + + + +## データのインポート + +ベクトライザーを設定したら、Weaviate に [データをインポート](../../manage-objects/import.mdx) します。Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデルベクトルがすでにある場合は、それを直接 Weaviate に渡すことができます。これは同じモデルで埋め込みをすでに生成しており、他システムからデータを移行する際などに Weaviate でそれらを再利用したい場合に役立ちます。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した Google モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![Embedding integration at search illustration](../_includes/integration_google_embedding_search.png) + +### ベクトル( near text )検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、Weaviate はテキストクエリを指定したモデルでベクトル化し、データベースからもっとも類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定された `n` 件のもっとも類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索はベクトル検索とキーワード(BM25)検索を実行し、その後 [結果を結合](../../search/hybrid.md) してデータベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、Weaviate はテキストクエリを指定したモデルでベクトル化し、データベースからもっともスコアの高いオブジェクトを返します。 + +以下のクエリは、`limit` で指定された `n` 件のもっともスコアの高いオブジェクトを返します。 + + + + + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +Vertex AI: +- `gemini-embedding-001` (デフォルト、 1.29.9 、 1.30.11 、 1.31.5 以降で追加) +- `text-embedding-005` (v 1.29.9 、 1.30.11 、 1.31.5 以降で追加) +- `text-multilingual-embedding-002` (v 1.29.9 、 1.30.11 、 1.31.5 以降で追加) + +
+ 非推奨モデル + +以下のモデルは Google によって非推奨となり、サポートされていません。期待どおりに動作しない可能性があります。 + +- `textembedding-gecko@001` +- `textembedding-gecko@002` +- `textembedding-gecko@003` +- `textembedding-gecko@latest` +- `textembedding-gecko-multilingual@001` +- `textembedding-gecko-multilingual@latest` +- `text-embedding-preview-0409` +- `text-multilingual-embedding-preview-0409` + +
+ +Gemini API: +- `gemini-embedding-001` (デフォルト) + - `embedding-001` (`gemini-embedding-001` の旧名、非推奨) +- `text-embedding-004` + +## 追加リソース + +### その他のインテグレーション + +- [Google generative models + Weaviate](./generative.md)。 + +### コード例 + +コレクションでインテグレーションを設定すると、 Weaviate におけるデータ管理および検索操作は他のコレクションと同一に動作します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) のガイドでは、データ操作(すなわちコレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)の方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) のガイドでは、ベクトル、キーワード、ハイブリッド検索を含む検索操作および 検索拡張生成 の実行方法を説明しています。 + +### 外部リソース + +- [Google Vertex AI](https://cloud.google.com/vertex-ai) +- [Google Gemini API](https://ai.google.dev/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/generative.md new file mode 100644 index 000000000..7e367235d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/generative.md @@ -0,0 +1,366 @@ +--- +title: 生成 AI +description: Google 生成モデルプロバイダー +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_google.jpg +# tags: ['model providers', 'google', 'generative', 'rag'] +--- + +# Weaviate と Google 生成 AI + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate の統合により、[Google Gemini API](https://ai.google.dev/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) と [Google Vertex AI](https://cloud.google.com/vertex-ai) の各 API が提供するモデル機能を Weaviate から直接利用できます。 + +[コレクションを設定](#configure-collection) して Google の生成 AI モデルを使用すると、Weaviate が 検索拡張生成 (RAG) を指定したモデルとお客様の Google API キーで実行します。 + +具体的には、Weaviate が検索を実行し、最も関連性の高いオブジェクトを取得した後、それらを Google の生成モデルに渡して出力を生成します。 + +![RAG integration illustration](../_includes/integration_google_rag.png) + +:::info Gemini API の提供状況 +執筆時点 (2023 年 11 月) では、Gemini API はすべてのリージョンで利用可能ではありません。最新情報は [こちら](https://ai.google.dev/gemini-api/docs/available-regions) をご覧ください。 +::: + +## 要件 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスには、Google 生成 AI 連携 (`generative-google`) モジュールが有効になっている必要があります。 + +:::info モジュール名の変更 +`generative-google` は Weaviate `v1.27` 以前では `generative-palm` と呼ばれていました。 +::: + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この連携は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザーの場合 + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効になっているかを確認してください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### API 資格情報 + +適切な連携を利用するために、有効な API 資格情報を Weaviate に提供する必要があります。 + +#### Gemini API + +[Google Gemini API](https://aistudio.google.com/app/apikey/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) にアクセスしてサインアップし、API キーを取得してください。 + +#### Vertex AI + +Google Cloud では `access token` と呼ばれます。 + +##### トークンの自動生成 + +import UseGoogleAuthInstructions from './_includes/use_google_auth_instructions.mdx'; + + + +##### トークンの手動取得 + +Google Cloud では `access token` と呼ばれます。 + +[Google Cloud CLI ツール](https://cloud.google.com/cli) をインストールして設定済みの場合、以下のコマンドでトークンを確認できます。 + +```shell +gcloud auth print-access-token +``` + +import GCPTokenExpiryNotes from '/_includes/gcp.token.expiry.notes.mdx'; + + + +#### API キーの提供 + +以下の例に示すように、実行時に API キーを Weaviate に渡してください。 + +[Gemin​​i API](#gemini-api) と [Vertex AI](#vertex-ai) ユーザー向けに、個別のヘッダーが用意されていますのでご注意ください。 + +import ApiKeyNote from '../_includes/google-api-key-note.md'; + + + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +[Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration) し、Google の生成 AI モデルを使用するには次のようにします。 + +Vertex AI と Gemini API では、必要なパラメーターが異なる点に注意してください。 + +Weaviate に [利用可能なモデル](#available-models) の中から [指定](#generative-parameters) することも、モデルを指定しない場合は [デフォルトモデル](#available-models) が使用されます。 + +### Vertex AI + +Vertex AI ユーザーは、コレクション設定で Google Cloud プロジェクト ID を指定する必要があります。 + + + + + + + + + + + + +### Gemini API + + + + + + + + + + + + +### 生成パラメーター + +以下の生成パラメーターを設定して、モデルの動作をカスタマイズします。 + + + + + + + + + + + + +## 実行時モデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するほか、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## 検索拡張生成 + +生成 AI の統合を設定した後、[single prompt](#single-prompt) または [grouped task](#grouped-task) の方法で RAG 操作を実行します。 + +### シングル プロンプト + +![シングル プロンプト RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_google_rag_single.png) + +検索結果内の各オブジェクトに対してテキストを生成する場合は、シングル プロンプト方式を利用します。 + +以下の例では、`limit` パラメーターで指定された `n` 件の検索結果それぞれに対して出力を生成します。 + +シングル プロンプト クエリを作成する際は、Weaviate から言語モデルへ渡したいオブジェクトプロパティを波かっこ `{}` で囲んで挿入します。たとえば、オブジェクトの `title` プロパティを渡すには、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + + +### グループ化タスク + +![検索結果セットに対して 1 つの出力を生成するグループ化タスク RAG 統合](../_includes/integration_google_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成するには、グループ化タスク方式を使用します。 + +つまり、`n` 件の検索結果がある場合でも、生成モデルはそのグループ全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + +### 画像を用いた RAG + +検索拡張生成を行う際、単一プロンプトでもグループ化タスクでも、入力の一部として画像を渡すことができます。 + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +Vertex AI: +- `chat-bison` (default) +- `chat-bison-32k` (from Weaviate `v1.24.9`) +- `chat-bison@002` (from Weaviate `v1.24.9`) +- `chat-bison-32k@002` (from Weaviate `v1.24.9`) +- `chat-bison@001` (from Weaviate `v1.24.9`) +- `gemini-1.5-pro-preview-0514` (from Weaviate `v1.25.1`) +- `gemini-1.5-pro-preview-0409` (from Weaviate `v1.25.1`) +- `gemini-1.5-flash-preview-0514` (from Weaviate `v1.25.1`) +- `gemini-1.0-pro-002` (from Weaviate `v1.25.1`) +- `gemini-1.0-pro-001` (from Weaviate `v1.25.1`) +- `gemini-1.0-pro` (from Weaviate `v1.25.1`) + +Gemini API: +- `chat-bison-001` (default) +- `gemini-pro` + + +## 追加リソース + +### その他の統合 + +- [Google テキスト埋め込みモデル + Weaviate](./embeddings.md). +- [Google マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md). + +### コード例 + +コレクションで統合を設定すると、Weaviate におけるデータ管理と検索操作は他のコレクションと同様に動作します。以下のモデル非依存の例をご覧ください。 + +- [ハウツー: コレクションを管理](../../manage-collections/index.mdx) および [ハウツー: オブジェクトを管理](../../manage-objects/index.mdx) では、データ操作 (コレクションとその中のオブジェクトの作成、読み込み、更新、削除) の方法を示しています。 +- [ハウツー: クエリ & 検索](../../search/index.mdx) では、ベクトル検索、キーワード検索、ハイブリッド検索、そして検索拡張生成の実行方法を解説しています。 + +### 参考文献 + +- [Google Vertex AI](https://cloud.google.com/vertex-ai) +- [Google Gemini API](https://ai.google.dev/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/index.md new file mode 100644 index 000000000..2572ef0c7 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/google/index.md @@ -0,0 +1,70 @@ +--- +title: Google と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_google.jpg +# tags: ['model providers', 'google'] +--- + + + +Google は、自然言語処理および生成のための幅広いモデルを提供しています。Weaviate は [Google Gemini API](https://ai.google.dev/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) と [Google Vertex AI](https://cloud.google.com/vertex-ai) の API とシームレスに統合されており、ユーザーは Google のモデルを Weaviate Database から直接利用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## Google との統合 + +### ベクトル検索向け埋め込みモデル + +![埋め込み統合の図](../_includes/integration_google_embedding.png) + +Google の埋め込みモデルは、テキストデータを意味と文脈を捉えたベクトル埋め込みに変換します。 + +[Weaviate は Google の埋め込みモデルと統合](./embeddings.md) しており、データのシームレスなベクトライゼーションを実現します。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索およびハイブリッド検索を実行できます。 + +[Google 埋め込み統合ページ](./embeddings.md) +[Google マルチモーダル埋め込み統合ページ](./embeddings-multimodal.md) + +### RAG 向け生成 AI モデル + +![単一プロンプト RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_google_rag_single.png) + +Google の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間のようなテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md) を利用すると、Weaviate Database から直接検索拡張生成 (RAG) を実行できます。これにより、Weaviate の効率的なストレージと高速な検索機能を Google の生成 AI モデルと組み合わせ、パーソナライズされたコンテキスト対応の応答を生成します。 + +[Google 生成 AI 統合ページ](./generative.md) + +## 概要 + +これらの統合により、開発者は Weaviate 内で Google の強力なモデルを直接活用できます。 + +その結果、AI 駆動アプリケーションの構築が簡素化され、開発プロセスが加速されるため、革新的なソリューションの創出に集中できます。 + +## 認証情報 + +これらの統合を利用するには、有効な Google API 認証情報を Weaviate に提供する必要があります。 + +### Vertex AI + +##### 自動トークン生成 + +import UseGoogleAuthInstructions from './_includes/use_google_auth_instructions.mdx'; + + + +## 開始方法 + +Weaviate は [Google Gemini API](https://aistudio.google.com/app/apikey/?utm_source=weaviate&utm_medium=referral&utm_campaign=partnerships&utm_content=) と [Google Vertex AI](https://cloud.google.com/vertex-ai) の両方と統合しています。 + +各統合ページで、Google モデルを Weaviate に設定し、アプリケーションでの利用を始める方法をご確認ください。 + +- [テキスト埋め込み](./embeddings.md) +- [マルチモーダル埋め込み](./embeddings-multimodal.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/_category_.json new file mode 100644 index 000000000..8f8d4ff1e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "GPT4All (locally hosted)", + "position": 320 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/embeddings.md new file mode 100644 index 000000000..ffe7c5c2d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/embeddings.md @@ -0,0 +1,318 @@ +--- +title: テキスト埋め込み +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_gpt4all.jpg +# tags: ['model providers', 'gpt4all', 'embeddings'] +--- + +# Weaviate での GPT4All 埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.local.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.local.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +:::caution Deprecated integration +この統合は非推奨で、今後のリリースで削除される予定です。新しいプロジェクトでは、他のモデルプロバイダーの利用を推奨します。 + +ローカル AI モデルの統合には、[Ollama](../ollama/index.md) または [ローカル HuggingFace](../transformers/) モデル統合の利用をご検討ください。 +::: + +Weaviate と GPT4All のモデルの統合により、Weaviate から直接それらのモデル機能へアクセスできます。 + +[ベクトルインデックスを設定](#configure-the-vectorizer) して GPT4All の埋め込みモデルを使用すると、Weaviate は GPT4All 推論コンテナ経由で指定したモデルを使用して、さまざまな操作のための埋め込みを生成します。この機能は * ベクトライザー * と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はテキストオブジェクトの埋め込みを生成し、それらをインデックスに保存します。また、[ ベクトル ](#vector-near-text-search) や [ ハイブリッド ](#hybrid-search) 検索操作では、テキストクエリを埋め込みに変換します。 + +![埋め込み統合のイメージ](../_includes/integration_gpt4all_embedding.png) + +このモジュールは `ggml` ライブラリを利用して CPU に最適化されており、GPU がなくても高速に推論できます。 + +## 要件 + +現在、GPT4All 統合は `amd64/x86_64` アーキテクチャデバイスのみで利用可能です。`gpt4all` ライブラリが ARM デバイス(Apple M シリーズなど)をまだサポートしていないためです。 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスには、GPT4All ベクトライザー統合(`text2vec-gpt4all`)モジュールが設定されている必要があります。 + +
+ Weaviate Cloud (WCD) のユーザー向け + +この統合はローカルで動作する GPT4All インスタンスを必要とするため、Weaviate Cloud (WCD) のサーバーレスインスタンスでは利用できません。 +
+ +
+ セルフホストユーザー向け + +- [クラスターメタデータ](/deploy/configuration/meta.md) でモジュールが有効になっているか確認してください。 +- Weaviate でモジュールを有効化するために、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 +
+ +#### 統合の設定 + +この統合を使用するには、GPT4All モデルのコンテナイメージと、コンテナ化されたモデルの推論エンドポイントを設定する必要があります。 + +以下は、Weaviate で GPT4All 統合を設定する例です。 + + + + +#### Docker オプション 1: 事前構成済み `docker-compose.yml` ファイルを使用する + +[Weaviate Docker インストールコンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator) の手順に従い、選択したモデルを含む事前構成済みの `docker-compose.yml` ファイルをダウンロードします。 +
+ +#### Docker オプション 2: 設定を手動で追加する + +代わりに、以下の例のように `docker-compose.yml` ファイルに設定を手動で追加します。 + +```yaml +services: + weaviate: + # Other Weaviate configuration + environment: + GPT4ALL_INFERENCE_API: http://text2vec-gpt4all:8080 # Set the inference API endpoint + text2vec-gpt4all: # Set the name of the inference container + image: cr.weaviate.io/semitechnologies/gpt4all-inference:all-MiniLM-L6-v2 +``` + +- `GPT4ALL_INFERENCE_API` 環境変数で推論 API エンドポイントを指定します +- `text2vec-gpt4all` は推論コンテナの名前です +- `image` はコンテナイメージを示します + +
+ + +Weaviate Helm チャートの `values.yaml` ファイル内の `modules` セクションに `text2vec-gpt4all` モジュールを追加または更新して、GPT4All 統合を設定します。例として、`values.yaml` ファイルを次のように変更します。 + +```yaml +modules: + + text2vec-gpt4all: + + enabled: true + tag: all-MiniLM-L6-v2 + repo: semitechnologies/gpt4all-inference + registry: cr.weaviate.io +``` + +より詳細な設定オプションについては、[Weaviate Helm チャート](https://github.com/weaviate/weaviate-helm/blob/master/weaviate/values.yaml) の `values.yaml` 例をご覧ください。 + + +
+ +### 認証情報 + +この統合はローカルの GPT4All コンテナへ接続するため、追加の認証情報(API キーなど)は不要です。以下の例のように、通常どおり Weaviate に接続してください。 + + + + + + + + + + + + + +## ベクトライザーの設定 + +GPT4All 埋め込みモデルを使用するために、[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) してください。 + + + + + + + + + + + + +現在利用可能なモデルは [`all-MiniLM-L6-v2`](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) のみです。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ + + +## データ インポート + +ベクトライザーを設定したら、Weaviate に[データをインポート](../../manage-objects/import.mdx)します。Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存のベクトルの再利用 +すでに互換性のあるモデルベクトルがある場合は、それを直接 Weaviate に渡すことができます。これは、同じモデルで埋め込みを生成済みで、それらを Weaviate で利用したい場合、たとえば別のシステムからデータを移行する際に便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した GPT4All モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![Embedding integration at search illustration](../_includes/integration_gpt4all_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で設定された件数 ( n 件) の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索はベクトル検索とキーワード (BM25) 検索を行い、その後[結果を組み合わせて](../../search/hybrid.md)データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースからスコアの高いオブジェクトを返します。 + +以下のクエリは、`limit` で設定された件数 ( n 件) の最もスコアが高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参考資料 + + + + + + + +### 利用可能なモデル + +現在利用可能なモデルは [`all-MiniLM-L6-v2`](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) のみです。 + +## 追加リソース + +### コード例 + +コレクションで統合を設定すると、 Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください: + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) の各ガイドでは、データ操作 (例: コレクションおよびその中のオブジェクトの作成、読み取り、更新、削除) の方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作 (例: ベクトル、キーワード、ハイブリッド) や 検索拡張生成 について説明しています。 + +### 外部リソース + +- [GPT4All ドキュメント](https://docs.gpt4all.io/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/index.md new file mode 100644 index 000000000..12e023184 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/gpt4all/index.md @@ -0,0 +1,53 @@ +--- +title: GPT4All と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_gpt4all.jpg +# tags: ['model providers', 'gpt4all'] +--- + + + +:::caution 非推奨の統合 +この統合は非推奨で、今後のリリースで削除される予定です。新しいプロジェクトでは、他のモデルプロバイダーの利用をおすすめします。 + +ローカル AI モデルの統合には、[Ollama](../ollama/index.md) または [ローカル HuggingFace](../huggingface/index.md) のモデル統合をご検討ください。 +::: + +GPT4All ライブラリを使用すると、幅広いモデルを簡単にローカルデバイス上で実行できます。Weaviate は GPT4All ライブラリとシームレスに統合されており、ユーザーは互換性のあるモデルを Weaviate Database から直接利用できます。 + +これらの統合により、開発者は高度な AI ドリブンアプリケーションを容易に構築できます。 + +## GPT4All との統合 + +Weaviate は、ローカルでホストされた GPT4All API にアクセスすることで、互換性のある GPT4All モデルと統合します。 + +### ベクトル検索用埋め込みモデル + +![埋め込み統合のイラスト](../_includes/integration_gpt4all_embedding.png) + +GPT4All の埋め込みモデルは、テキストデータをベクトル埋め込みに変換し、意味とコンテキストを捉えます。 + +[Weaviate は GPT4All の埋め込みモデルと統合](./embeddings.md) しており、データのシームレスなベクトル化を実現します。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[GPT4All 埋め込み統合ページ](./embeddings.md) + +## 概要 + +これらの統合により、開発者は Weaviate から直接強力な GPT4All モデルを活用できます。 + +その結果、AI ドリブンアプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を利用するには、ローカルでホストされた Weaviate インスタンスが必要です。自身の GPT4All モデルをホストしてください。 + +該当する統合ページで、Weaviate を GPT4All モデルと連携させる方法を学び、アプリケーションで使用を開始しましょう。 + +- [テキスト埋め込み](./embeddings.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/_category_.json new file mode 100644 index 000000000..72d5fb090 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Hugging Face (API)", + "position": 230 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/embeddings.md new file mode 100644 index 000000000..93488aaf9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/embeddings.md @@ -0,0 +1,338 @@ +--- +title: テキスト 埋め込み +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_huggingface.jpg +# tags: ['model providers', 'huggingface', 'embeddings'] +--- + +# Weaviate と Hugging Face の埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate の Hugging Face API との統合により、Weaviate から直接モデルの機能にアクセスできます。 + +[Weaviate の ベクトル インデックスを設定](#configure-the-vectorizer) して Hugging Face Hub の埋め込みモデルを使用すると、Weaviate は指定したモデルと Hugging Face API キーを使用して各種操作のための埋め込みを生成します。この機能は *vectorizer* と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はテキストオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) 検索および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate はテキストクエリを埋め込みに変換します。 + +![埋め込み統合の図](../_includes/integration_huggingface_embedding.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、Hugging Face ベクトライザー統合(`text2vec-huggingface`)モジュールが有効になっている必要があります。 + +
+ For Weaviate Cloud (WCD) users + +この統合は Weaviate Cloud (WCD) のサーバーレス インスタンスではデフォルトで有効になっています。 + +
+ +
+ For self-hosted users + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効かどうかを確認します。 +- [モジュールの設定方法](../../configuration/modules.md) ガイドに従い、Weaviate でモジュールを有効にします。 + +
+ +### API 認証情報 + +この統合を使用するには、Weaviate に有効な Hugging Face API キーを渡す必要があります。API キーの取得方法は [Hugging Face](https://huggingface.co/docs/api-inference/en/quicktour) を参照してください。 + +以下のいずれかの方法で Weaviate に API キーを提供します。 + +- Weaviate から参照できる `HUGGINGFACE_APIKEY` 環境変数を設定します。 +- 下記の例のように、実行時に API キーを渡します。 + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +以下のように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) し、Hugging Face の埋め込みモデルを使用します。 + + + + + + + + + + + + + + + +ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定する必要があります。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ + + +### ベクトライザー パラメーター + +以下の例では、Hugging Face 固有のオプションの設定方法を示します。 + + + + + + + + + + + + + + + + +#### モデル選択パラメーター + +モデルを指定するには、次のパラメーターのうち 1 つだけを選択してください: + +- `model` +- `passageModel` と `queryModel` +- `endpointURL` + +:::note `model`、`passageModel`/`queryModel` と `endpointURL` の違い +`passageModel` と `queryModel` パラメーターは組み合わせて使用し、[DPR](https://huggingface.co/docs/transformers/en/model_doc/dpr) の passage モデルと query モデルを指定します。 + +`endpointURL` パラメーターは、[カスタム Hugging Face Inference Endpoint](https://huggingface.co/inference-endpoints) を指定するために使用します。このパラメーターを設定すると、`model`、`passageModel`、`queryModel` の各パラメーターより優先されます。 +::: + +#### 追加パラメーター + +- `options.waitForModel`:モデルが準備完了でない場合、`503` エラーを返す代わりに準備が整うまで待機します。 +- `options.useGPU`:ご利用の [アカウント プラン](https://huggingface.co/inference-api#pricing) が対応している場合、推論に GPU を使用します。 +- `options.useCache`:キャッシュがある場合はそれを利用します。(非決定的なモデルではキャッシュ メカニズムを無効にする際に使用します。) + +## データ インポート + +ベクトライザーを設定したら、Weaviate に [データをインポート](../../manage-objects/import.mdx) します。Weaviate は指定されたモデルを使用してテキスト オブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +既に互換性のあるモデル ベクトルをお持ちの場合、それを Weaviate に直接提供できます。これは、同じモデルを使用して埋め込みを生成済みで、それらを Weaviate で再利用したい場合、たとえば別システムからデータを移行する際に便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、Weaviate は指定された Hugging Face モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![Embedding integration at search illustration](../_includes/integration_huggingface_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を行うと、Weaviate はテキスト クエリを指定モデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で指定した件数 `n` の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード (BM25) 検索を実行し、その結果を [結合](../../search/hybrid.md) してデータベースから最も一致するオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も高いスコアのオブジェクトを返します。 + +以下のクエリは、`limit` で設定されたデータベース内の `n` 件の最もスコアが高いオブジェクトを返します。 + + + + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +`text2vec-huggingface` では、パブリックおよびプライベートの Hugging Face モデルを含む任意の Hugging Face 埋め込みモデルを使用できます。一般的に、[Sentence similarity モデル](https://huggingface.co/models?pipeline_tag=sentence-similarity&sort=downloads) が最も良い結果をもたらします。 + +## 追加リソース + +- [Hugging Face 連携 (ローカルホスト)](../transformers/index.md) + +### コード例 + +連携をコレクションで設定すると、Weaviate のデータ管理および検索操作は他のコレクションと同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) では、コレクションおよびその中のオブジェクトを作成・読み取り・更新・削除する方法を示しています。 +- [How-to: 検索 & クエリ](../../search/index.mdx) では、ベクトル、キーワード、ハイブリッド検索に加え、検索拡張生成の方法を解説しています。 + +### 外部リソース + +- Hugging Face [Inference API ドキュメント](https://huggingface.co/docs/api-inference/en/quicktour) +- Hugging Face [Model Hub](https://huggingface.co/models) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/index.md new file mode 100644 index 000000000..0ece8bf88 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/huggingface/index.md @@ -0,0 +1,46 @@ +--- +title: Hugging Face と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_huggingface.jpg +# tags: ['model providers', 'huggingface'] +--- + + + +Hugging Face は自然言語処理向けに幅広いモデルを提供しています。 Weaviate は Hugging Face の Inference API とシームレスに統合されており、ユーザーは Hugging Face Hub のモデルを Weaviate データベースから直接利用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## Hugging Face との統合 + +### ベクトル検索用の埋め込みモデル + +![埋め込み統合のイメージ](../_includes/integration_huggingface_embedding.png) + +Hugging Face Hub の埋め込みモデルはテキストデータをベクトル埋め込みに変換し、意味とコンテキストを捉えます。 + +[Weaviate は Hugging Face Hub の埋め込みモデルと統合](./embeddings.md) しており、データをシームレスにベクトル化できます。この統合により、追加の前処理やデータ変換を行わずにセマンティック検索やハイブリッド検索が可能になります。 + +[Hugging Face 埋め込み統合ページ](./embeddings.md) + +## まとめ + +これらの統合を利用することで、開発者は Hugging Face の強力なモデルを Weaviate 内で直接活用できます。 + +その結果、 AI 駆動アプリケーションの開発プロセスが簡素化され、イノベーティブなソリューションの創出に集中できます。 + +## はじめに + +これらの統合を使用するには、有効な Hugging Face API キーを Weaviate に提供する必要があります。 [Hugging Face](https://huggingface.co/docs/api-inference/en/quicktour) にアクセスしてサインアップし、 API キーを取得してください。 + +次に、該当する統合ページに移動し、 Hugging Face Hub のモデルで Weaviate を設定してアプリケーションで使用を開始しましょう。 + +- [テキスト埋め込み](./embeddings.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/_category_.json new file mode 100644 index 000000000..df188e57b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Meta ImageBind (locally hosted)", + "position": 360 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/embeddings-multimodal.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/embeddings-multimodal.md new file mode 100644 index 000000000..2b5d62a70 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/embeddings-multimodal.md @@ -0,0 +1,351 @@ +--- +title: マルチモーダル埋め込み +sidebar_position: 30 +image: og/docs/integrations/provider_integrations_imagebind.jpg +# tags: ['model providers', 'imagebind', 'embeddings'] +--- + +# ローカルホスト ImageBind 埋め込み + Weaviate + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.local.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.local.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate の Meta ImageBind ライブラリとの統合により、 ImageBind の機能を Weaviate から直接利用できます。 ImageBind モデルは複数のモダリティ(テキスト、画像、音声、動画、サーマル、 IMU、深度)をサポートします。 + +[ベクトル化を設定](#configure-the-vectorizer)して ImageBind 統合を使用し、[Weaviate インスタンスを設定](#weaviate-configuration)してモデルイメージを指定すると、 Weaviate は ImageBind 推論コンテナ内の指定モデルを用いて各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import)には、 Weaviate がマルチモーダルオブジェクト埋め込みを生成し、インデックスに保存します。 [ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、 Weaviate が 1 つ以上のモダリティのクエリを埋め込みに変換します。 [マルチモーダル検索操作](#vector-near-media-search) もサポートされています。 + +![Embedding integration illustration](../_includes/integration_imagebind_embedding.png) + +## 必要条件 + +### Weaviate 設定 + +お使いの Weaviate インスタンスは、 ImageBind マルチモーダル ベクトライザー統合(`multi2vec-bind`)モジュールを有効にしている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は ImageBind モデルを含むコンテナを起動する必要があるため、 Weaviate Cloud (WCD) のサーバーレスインスタンスでは利用できません。 + +
+ +#### 統合モジュールの有効化 + +- モジュールが有効になっているかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) を確認してください。 +- Weaviate でモジュールを有効化するには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +#### 統合の設定 + +この統合を使用するには、 ImageBind モデルのコンテナイメージと、その推論エンドポイントを設定する必要があります。 + +以下は Weaviate で ImageBind 統合を設定する例です。 + + + + +#### Docker オプション 1: 事前設定済み `docker-compose.yml` を使用 + +[Weaviate Docker インストールコンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator) の手順に従い、選択したモデルを含む事前設定済み `docker-compose.yml` ファイルをダウンロードしてください。 +
+ +#### Docker オプション 2: 手動で設定を追加 + +または、下記の例のように `docker-compose.yml` ファイルへ手動で設定を追加します。 + +```yaml +services: + weaviate: + # Other Weaviate configuration + environment: + BIND_INFERENCE_API: http://multi2vec-bind:8080 # Set the inference API endpoint + multi2vec-bind: # Set the name of the inference container + mem_limit: 12g + image: cr.weaviate.io/semitechnologies/multi2vec-bind:imagebind + environment: + ENABLE_CUDA: 0 # Set to 1 to enable +``` + +- `BIND_INFERENCE_API` 環境変数で推論 API エンドポイントを指定します +- `multi2vec-bind` は推論コンテナの名前です +- `image` はコンテナイメージです +- `ENABLE_CUDA` 環境変数で GPU 使用を有効化します + +
+ + +Weaviate Helm チャートの `values.yaml` ファイルで `modules` セクションに `multi2vec-bind` モジュールを追加または更新し、 ImageBind 統合を設定します。例として、 `values.yaml` を以下のように修正します。 + +```yaml +modules: + + multi2vec-bind: + + enabled: true + tag: imagebind + repo: semitechnologies/multi2vec-bind + registry: cr.weaviate.io + envconfig: + enable_cuda: true +``` + +より多くの設定オプションを含む `values.yaml` の例については、[Weaviate Helm チャート](https://github.com/weaviate/weaviate-helm/blob/master/weaviate/values.yaml) を参照してください。 + + +
+ +### 認証情報 + +この統合は ImageBind モデルを含むローカルコンテナを起動するため、追加の認証情報(例: API キー)は不要です。以下の例のように通常どおり Weaviate に接続してください。 + + + + + + + + + + + + + +## ベクトライザーの設定 + +ImageBind 埋め込みモデルを使用するように、[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer)します。 + + + + + + + + + + + + +利用可能な ImageBind モデルは 1 つのみです。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ + + +### ベクトライザーのパラメーター + +ImageBind ベクトライザーは複数のモダリティ(テキスト、画像、音声、動画、サーマル、IMU、深度)をサポートします。以下のように、これらのうち 1 つ以上をベクトライザー設定で指定できます。 + + + + + + + + + + + + +## データインポート + +ベクトライザーを設定したら、Weaviate に [データをインポート](../../manage-objects/import.mdx) します。Weaviate は指定したモデルを使用してオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +すでに互換性のあるモデルベクトルをお持ちの場合は、それを Weaviate に直接渡すことができます。すでに同じモデルで埋め込みを生成しており、別のシステムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーの設定が完了すると、Weaviate は指定した ImageBind モデルを使用して ベクトル検索 とハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイメージ](../_includes/integration_imagebind_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で設定した数 `n` 件の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は ベクトル検索 とキーワード(BM25)検索を行い、その結果を [組み合わせて](../../search/hybrid.md) データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +次のクエリは、`limit` で設定した数 `n` 件の最もスコアが高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ベクトル ( near メディア ) 検索 + +メディア検索(例えば [near image 検索](../../search/similarity.md#search-with-image))を実行すると、Weaviate はクエリを指定モデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +near メディア検索(near image 検索など)を実行するには、メディアクエリを base64 文字列に変換し、それを検索クエリに渡します。 + +以下のクエリは、`limit` で設定された件数、つまり入力画像に最も類似した `n` 件のオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +同様の検索は、オーディオ、ビデオ、サーマル、IMU、デプスなど他のメディアタイプについても、対応する検索クエリを使用して実行できます。 + +## 参照 + +### 利用可能なモデル + +利用可能な ImageBind モデルは 1 つだけです。 + +## 追加リソース + +### コード例 + +インテグレーションをコレクションで設定すると、Weaviate でのデータ管理および検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)を実行する方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作(ベクトル、キーワード、ハイブリッド)および検索拡張生成を実行する方法を説明しています。 + +### モデルライセンス + +[ImageBind ページ](https://github.com/facebookresearch/ImageBind)でモデルのライセンスを確認してください。 + +そのライセンス条件がご自身の用途に適切かどうかを評価する責任は、利用者にあります。 + +### 外部リソース + +- [ImageBind GitHub ページ](https://github.com/facebookresearch/ImageBind) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/index.md new file mode 100644 index 000000000..95787f375 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/imagebind/index.md @@ -0,0 +1,47 @@ +--- +title: ローカルホストの ImageBind と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_imagebind.jpg +# tags: ['model providers', 'huggingface', 'imagebind'] +--- + + + +Meta の ImageBind ライブラリは、自然言語処理向けの幅広いモデルで利用できます。Weaviate は ImageBind ライブラリとシームレスに統合されており、ユーザーは Weaviate Database から互換性のあるモデルを直接利用できます。 + +これらの統合により、開発者は高度な AI 駆動型アプリケーションを簡単に構築できます。 + +## ImageBind との統合 + +Weaviate はコンテナ内で ImageBind モデルを起動することで統合を実現しています。これにより、ユーザーは独自のモデルをホストし、Weaviate と一緒に利用できます。 + +### ベクトル検索用の埋め込みモデル + +![埋め込み統合のイラスト](../_includes/integration_imagebind_embedding.png) + +ImageBind の埋め込みモデルは、マルチモーダルデータをベクトル埋め込みに変換し、その意味とコンテキストを捉えます。 + +[Weaviate は ImageBind の埋め込みモデルと統合](./embeddings-multimodal.md)し、データのシームレスなベクトル化を可能にします。この統合により、追加の前処理やデータ変換を行うことなく、セマンティック検索やハイブリッド検索を実行できます。 + +[ImageBind 埋め込み統合ページ](./embeddings-multimodal.md) + +## 概要 + +これらの統合により、開発者は Weaviate 内から直接強力な ImageBind モデルを活用できます。 + +その結果、AI 駆動型アプリケーションの開発プロセスが簡素化され、イノベーティブなソリューションの創造に集中できます。 + +## 開始方法 + +これらの統合を利用するには、ローカルホストの Weaviate インスタンスが必要です。これにより、ご自身の ImageBind モデルをホストできます。 + +該当の統合ページにアクセスし、ImageBind モデルで Weaviate を構成する方法を学び、アプリケーションで利用を開始してください。 + +- [マルチモーダル埋め込み](./embeddings-multimodal.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/index.md new file mode 100644 index 000000000..6f57ca085 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/index.md @@ -0,0 +1,135 @@ +--- +title: モデル プロバイダー統合 +sidebar_position: 50 +image: og/docs/model-provider-integrations.jpg +# tags: ['getting started', 'model providers', 'integrations'] +--- + +Weaviate は、さまざまなプロバイダーが提供する [セルフホスト型](#locally-hosted) と [API ベース](#api-based) のモデルと統合できます。 + +これにより、次のような開発体験が向上します。 +- 埋め込みを手動で指定せずに、オブジェクトを Weaviate へ直接インポートできる +- 生成 AI モデルと連携した 検索拡張生成 ( RAG ) パイプラインを構築できる + +## モデル プロバイダー統合 + +### API ベース + +| Model provider | 埋め込み | 生成 AI | その他 | +| --- | --- | --- | --- | +| [Anthropic](./anthropic/index.md) | - | [Text](./anthropic/generative.md) | - | +| [Anyscale](./anyscale/index.md) | - | [Text](./anyscale/generative.md) | - | +| [AWS](./aws/index.md) | [Text](./aws/embeddings.md) | [Text](./aws/generative.md) | +| [Cohere](./cohere/index.md) | [Text](./cohere/embeddings.md), [Multimodal](./cohere/embeddings-multimodal.md) | [Text](./cohere/generative.md) | [Reranker](./cohere/reranker.md) | +| [Databricks](./databricks/index.md) | [Text](./databricks/embeddings.md) | [Text](./databricks/generative.md) | - | +| [FriendliAI](./friendliai/index.md) | - | [Text](./friendliai/generative.md) | - | +| [Google](./google/index.md) | [Text](./google/embeddings.md), [Multimodal](./google/embeddings-multimodal.md) | [Text](./google/generative.md) | - | +| [Hugging Face](./huggingface/index.md) | [Text](./huggingface/embeddings.md) | - | - | +| [Jina AI](./jinaai/index.md) | [Text](./jinaai/embeddings.md), [Multimodal](./jinaai/embeddings-multimodal.md) | - | [Reranker](./jinaai/reranker.md) | +| [Mistral](./mistral/index.md) | [Text](./mistral/embeddings.md) | [Text](./mistral/generative.md) | - | +| [NVIDIA](./nvidia/index.md) | [Text](./nvidia/embeddings.md), [Multimodal](./nvidia/embeddings-multimodal.md) | [Text](./nvidia/generative.md) | [Reranker](./nvidia/reranker.md) | +| [OctoAI (Deprecated)](./octoai/index.md) | [Text](./octoai/embeddings.md) | [Text](./octoai/generative.md) | - | +| [OpenAI](./openai/index.md) | [Text](./openai/embeddings.md) | [Text](./openai/generative.md) | - | +| [Azure OpenAI](./openai-azure/index.md) | [Text](./openai-azure/embeddings.md) | [Text](./openai-azure/generative.md) | - | +| [Voyage AI](./voyageai/index.md) | [Text](./voyageai/embeddings.md), [Multimodal](./voyageai/embeddings-multimodal.md) | - | [Reranker](./voyageai/reranker.md) | +| [Weaviate](./weaviate/index.md) | [Text](./weaviate/embeddings.md) | - | - | +| [xAI](./xai/index.md) | - | [Text](./xai/generative.md) | - | + +#### すべての API ベース モジュールを有効化 + +:::caution Experimental feature +Available starting in `v1.26.0`. This is an experimental feature. Use with caution. +::: + +[環境変数 `ENABLE_API_BASED_MODULES` を `true` に設定](../configuration/modules.md#enable-all-api-based-modules) することで、すべての API ベース統合を一度に有効化できます。 + +これにより、Anthropic、Cohere、OpenAI などの API ベースモデル統合がすべて使用可能になります。これらのモジュールは軽量なため、すべてを有効にしてもリソース使用量は大きく増加しません。 + +[すべての API ベース モジュールを有効化する方法](../configuration/modules.md#enable-all-api-based-modules) を参照してください。 + +### セルフホスト型 + +| Model provider | 埋め込み | 生成 AI | その他 | +| --- | --- | --- | --- | +| [GPT4All (Deprecated)](./gpt4all/index.md) | [Text (Deprecated)](./gpt4all/embeddings.md) | - | - | +| [Hugging Face](./transformers/index.md) | [Text](./transformers/embeddings.md), [Multimodal (CLIP)](./transformers/embeddings-multimodal.md) | - | [Reranker](./transformers/reranker.md) | +| [KubeAI](./kubeai/index.md) | [Text](./kubeai/embeddings.md) | - | - | +| [Model2vec](./model2vec/index.md) | [Text](./model2vec/embeddings.md) | - | - | +| [Meta ImageBind](./imagebind/index.md) | [Multimodal](./imagebind/embeddings-multimodal.md) | - | - | +| [Ollama](./ollama/index.md) | [Text](./ollama/embeddings.md) | [Text](./ollama/generative.md) | - | + +## Weaviate はどのように埋め込みを生成しますか? + +埋め込み用のモデル プロバイダー統合が有効になっている場合、データベースに追加されたオブジェクトに対して Weaviate が自動的に埋め込みを生成します。 + +これは、ソース データを統合プロバイダーに送信し、プロバイダーが生成した埋め込みを Weaviate に返し、最終的に埋め込みが Weaviate データベースに保存されるという流れです。 + +```mermaid +%%{init: { + 'theme': 'base', + 'themeVariables': { + 'primaryColor': '#4a5568', + 'primaryTextColor': '#2d3748', + 'primaryBorderColor': '#718096', + 'lineColor': '#718096', + 'secondaryColor': '#f7fafc', + 'tertiaryColor': '#edf2f7' + } +}}%% + +flowchart LR + %% Style definitions + classDef systemBox fill:#f7fafc,stroke:#3182ce,stroke-width:2px,color:#2d3748 + classDef weaviateBox fill:#f7fafc,stroke:#2d3748,stroke-width:2px,color:#2d3748 + classDef providerBox fill:#f7fafc,stroke:#48bb78,stroke-width:2px,color:#2d3748 + classDef component fill:white,stroke:#718096,stroke-width:1.5px,color:#2d3748,rx:6 + + %% Model Provider section (leftmost) + subgraph provider["Model Provider"] + inference["🤖 Inference API /
Local Model"] + end + + %% Weaviate section (middle) + subgraph weaviate["Weaviate"] + vectorizer["🔌 Model Provider
Integration"] + core["⚡️ Data & vector store"] + end + + %% User System (bottom) + subgraph user["User System"] + data["📄 Data"] + end + + %% Connections + data -->|"1\. Insert objects"| core + core -->|"2\. Request vector"| vectorizer + vectorizer -->|"3\. Request vector"| inference + inference -->|"4\. Vector"| vectorizer + vectorizer -->|"5\. Vector"| core + + %% Apply styles + class user systemBox + class weaviate weaviateBox + class provider providerBox + class data,core,vectorizer,inference component +``` + +Weaviate がオブジェクトの埋め込みを生成する手順は次のとおりです。 + +- スキップ設定されていない限り、データ型が `text` または `text[]` のプロパティを選択する +- 値を連結する前に、プロパティをアルファベット順 (a-z) に並べ替える +- 設定されている場合はコレクション名を先頭に付加する + +:::note 大文字小文字の扱い +Weaviate バージョン `v1.27` より前では、上記で作成された文字列はモデル プロバイダーに送信される前にすべて小文字化されます。`v1.27` 以降では、変換せずそのまま送信されます。 + +テキストを小文字化したい場合は、環境変数 `LOWERCASE_VECTORIZATION_INPUT` を設定してください。 +`text2vec-contextionary` 統合では、常に小文字化されます。 +::: + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/_category_.json new file mode 100644 index 000000000..a00c10e36 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Jina AI", + "position": 240 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings-colbert.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings-colbert.md new file mode 100644 index 000000000..8cd8a391a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings-colbert.md @@ -0,0 +1,366 @@ +--- +title: ColBERT エンベディング +sidebar_position: 23 +image: og/docs/integrations/provider_integrations_jinaai.jpg +# tags: ['model providers', 'jinaai', 'embeddings'] +--- + +:::info `v1.29` で追加 +::: + +# Weaviate と Jina AI ColBERT エンベディング + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate の Jina AI API との統合により、Jina AI のモデル機能を Weaviate から直接利用できます。 + +[Jina AI ColBERT エンベディングモデルを使用するように Weaviate ベクトルインデックスを設定](#configure-the-vectorizer)すると、指定したモデルと Jina AI API キーを使って Weaviate が各種操作のためにエンベディングを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import)には、Weaviate がテキストオブジェクトのエンベディングを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search)検索や[ハイブリッド](#hybrid-search)検索操作では、Weaviate がテキストクエリをエンベディングに変換します。 + +![エンベディング統合の図](../_includes/integration_jinaai_embedding.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、Jina AI ColBERT ベクトライザー統合(`text2colbert-jinaai`)モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターのメタデータ](/deploy/configuration/meta.md)をチェックしてください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定方法](../../configuration/modules.md)ガイドをご覧ください。 + +
+ +### API 認証情報 + +この統合を利用するには、有効な Jina AI API キーを Weaviate に提供する必要があります。登録と API キーの取得は [Jina AI](https://jina.ai/embeddings/) で行えます。 + +API キーは次のいずれかの方法で Weaviate に渡してください。 + +- Weaviate が参照可能な環境変数 `JINAAI_APIKEY` を設定する +- 以下の例のように、実行時に API キーを渡す + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +Jina AI ColBERT エンベディングモデルを使用するために、以下のように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer)します。 + + + + + + + + + + + + + + + + + + +### モデルの選択 + +次の設定例のように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + + + + + +[指定](#vectorizer-parameters) により、 Weaviate で使用する [利用可能なモデル](#available-models) のいずれかを選択できます。モデルを指定しない場合、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +### ベクトライザーのパラメーター + +以下の例は、 Jina AI 固有のオプションを設定する方法を示しています。 + +`dimensions` は `jina-colbert-v1` モデルには適用できない点にご注意ください。 + + + + + + + + + + + + + + + + +## データのインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。指定したモデルを使用して、テキストオブジェクトの埋め込みが生成されます。 + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデルのベクトルを既にお持ちの場合は、それを直接 Weaviate に渡すことができます。同じモデルで生成済みの埋め込みを Weaviate で再利用したい場合、例えば他のシステムからデータを移行するときなどに便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、 Weaviate は指定した Jina AI モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合の図](../_includes/integration_jinaai_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を行うと、 Weaviate はクエリのテキストを指定したモデルで埋め込みに変換し、データベースからもっとも類似したオブジェクトを返します。 + +以下のクエリは、 `limit` で指定した数 `n` のもっとも類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索はベクトル検索とキーワード (BM25) 検索を実行し、 [結果を融合](../../search/hybrid.md#change-the-fusion-method) してデータベースからもっとも適合するオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を行うと、 Weaviate はクエリのテキストを指定したモデルで埋め込みに変換し、データベースからもっともスコアの高いオブジェクトを返します。 + +以下のクエリは、 `limit` で指定した数 `n` のもっともスコアの高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +- `jina-colbert-v2` + - デフォルトでは、 Weaviate は `128` dimensions を使用します +- `jina-colbert-v1` + +`dimensions` は `jina-colbert-v1` モデルには適用されません。 + +## さらに学ぶ + +### 他の統合 + +- [Jina AI 埋め込みモデル + Weaviate](./embeddings.md) +- [Jina AI マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) +- [Jina AI リランカーモデル + Weaviate](./reranker.md) + +### コード例 + +コレクションで統合を設定すると、 Weaviate のデータ管理および検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) および [How-to: Manage objects](../../manage-objects/index.mdx) ガイドでは、データ操作 (コレクションとその中のオブジェクトの作成、読み取り、更新、削除) の方法を示しています。 +- [How-to: Query & Search](../../search/index.mdx) ガイドでは、ベクトル、キーワード、ハイブリッド検索に加えて検索拡張生成の実行方法を説明しています。 + +### 外部リソース + +- Jina AI [Embeddings API documentation](https://jina.ai/embeddings/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings-multimodal.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings-multimodal.md new file mode 100644 index 000000000..0a6912296 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings-multimodal.md @@ -0,0 +1,334 @@ +--- +title: マルチモーダル埋め込み +sidebar_position: 25 +image: og/docs/integrations/provider_integrations_jinaai.jpg +# tags: ['model providers', 'jinaai', 'embeddings'] +--- + +# Weaviate での Jina AI マルチモーダル埋め込み + +:::info `1.25.26`、`1.26.11`、`v1.27.5` で追加されました +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate と Jina AI の API の統合により、Weaviate から直接 Jina AI のモデル機能を利用できます。 + +[Weaviate ベクトルインデックスを設定](#configure-the-vectorizer)して Jina AI の埋め込みモデルを使用すると、指定したモデルとお持ちの Jina AI API キーを用いて、Weaviate がさまざまな操作向けに埋め込みを生成します。この機能を *ベクトライザー* と呼びます。 + +[インポート時](#data-import)には、Weaviate がマルチモーダルオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) と [ハイブリッド](#hybrid-search) の検索操作では、1 つ以上のモダリティからなるクエリを埋め込みに変換します。[マルチモーダル検索操作](#vector-near-media-search) にも対応しています。 + +![埋め込み統合のイラスト](../_includes/integration_jinaai_embedding.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、Jina AI マルチモーダルベクトライザー統合 (`multi2vec-jinaai`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効になっているか確認してください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定の方法](../../configuration/modules.md) をご覧ください。 + +
+ +### API 認証情報 + +この統合を使用するには、有効な Jina AI API キーを Weaviate に提供する必要があります。サインアップして API キーを取得するには、[Jina AI](https://jina.ai/embeddings/) へアクセスしてください。 + +次のいずれかの方法で Weaviate に API キーを渡します。 + +- Weaviate が参照できる `JINAAI_APIKEY` 環境変数を設定する +- 以下の例のように実行時に API キーを渡す + + + + + + + + + + + + + +## ベクトライザーの設定 + +Jina AI の埋め込みモデルを使用するように、[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer)します。 + + + + + + + + + + + + +### モデルの選択 + +[利用可能なモデル](#available-models) のいずれかを指定して、ベクトライザーに使用させることができます。以下の設定例をご覧ください。 + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを [指定](#vectorizer-parameters) できます。モデルを指定しない場合は[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +### ベクトライザーのパラメーター + +以下の例では、Jina AI 固有のオプションの設定方法を示します。 + + + + + + + + + + + +### ベクトライザーのパラメーター + +- `model`: モデル名。 +- `dimensions`: モデルの次元数。 + - [すべてのモデル](#available-models) がこのパラメーターをサポートしているわけではありません。 + +## データインポート + +ベクトライザーを設定したら、Weaviate に[データをインポート](../../manage-objects/import.mdx)します。Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込み (embedding) を生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +すでに互換性のあるモデルベクトルをお持ちの場合は、それを Weaviate に直接渡すことができます。同じモデルで埋め込みを生成済みの場合や、他システムからデータを移行する際に便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した Jina AI モデルを用いてベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合の図](../_includes/integration_jinaai_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索では、ベクトル検索とキーワード (BM25) 検索を行い、その結果を[組み合わせ](../../search/hybrid.md)てデータベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースからスコアの高いオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` の最もスコアの高いオブジェクトを返します。 + + + + + + + + + + + + + + + +### ベクトル( near media )検索 + +[ near image 検索](../../search/similarity.md#search-with-image) のようなメディア検索を実行すると、 Weaviate は指定されたモデルを使用してクエリを埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +near image search のような near media 検索を実行するには、メディアクエリを base64 文字列に変換し、それを検索クエリに渡します。 + +以下のクエリは、`limit` で設定された数 `n` 件の、入力画像に最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参考 + +### 利用可能なモデル + +- `jina-clip-v2` + - このモデルは [Matryoshka Representation Learning](https://arxiv.org/abs/2205.13147) を使用した多言語・マルチモーダルモデルです。 + - このモデルは `dimensions` パラメーターを受け取り、 64 から 1024 まで(両端を含む)の整数を指定できます。デフォルト値は 1024 です。 +- `jina-clip-v1` + - このモデルは常に 768 次元の埋め込みを返します。 + +## 追加リソース + +### その他のインテグレーション + +- [ Jina AI テキスト埋め込みモデル + Weaviate](./embeddings.md). +- [ Jina AI ColBERT 埋め込みモデル + Weaviate](./embeddings-colbert.md). +- [ Jina AI reranker モデル + Weaviate](./reranker.md). + +### コード例 + +コレクションでインテグレーションを設定すると、 Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください: + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) のガイドでは、データ操作 (例: コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除) の方法を示しています。 +- [How-to: Query & Search](../../search/index.mdx) のガイドでは、検索操作 (例: ベクトル、キーワード、ハイブリッド) と 検索拡張生成 の方法を示しています。 + +### 外部リソース + +- Jina AI [Embeddings API ドキュメント](https://jina.ai/embeddings/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings.md new file mode 100644 index 000000000..e3b531f4f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/embeddings.md @@ -0,0 +1,366 @@ +--- +title: テキスト 埋め込み +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_jinaai.jpg +# tags: ['model providers', 'jinaai', 'embeddings'] +--- + +# Weaviate での Jina AI 埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate の Jina AI API との統合により、モデルの機能に Weaviate から直接アクセスできます。 + +[Jina AI 埋め込みモデルを使用するよう Weaviate の ベクトル インデックスを設定](#configure-the-vectorizer) すると、指定したモデルとお客様の Jina AI API キーを使用して、さまざまな操作のために Weaviate が埋め込みを生成します。この機能は *vectorizer* と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はテキスト オブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate はテキスト クエリを埋め込みに変換します。 + +![埋め込み統合のイメージ](../_includes/integration_jinaai_embedding.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、Jina AI ベクトライザー統合 (`text2vec-jinaai`) モジュールが有効化されている必要があります。 + +
+ Weaviate Cloud (WCD) 利用者向け + +この統合は、Weaviate Cloud (WCD) のサーバーレス インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスティング利用者向け + +- モジュールが有効になっているかどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) をご確認ください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定の手順](../../configuration/modules.md) を参照してください。 + +
+ +### API 資格情報 + +この統合を利用するには、Weaviate に有効な Jina AI API キーを提供する必要があります。API キーは [Jina AI](https://jina.ai/embeddings/) でサインアップして取得してください。 + +以下のいずれかの方法で Weaviate に API キーを渡します。 + +- Weaviate が参照できる環境変数 `JINAAI_APIKEY` を設定する +- 下記の例のように、実行時に API キーを渡す + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +以下のように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) して、Jina AI 埋め込みモデルを使用します: + + + + + + + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + + + + + +Weaviate で使用する [利用可能なモデル](#available-models) のいずれかを[指定](#vectorizer-parameters)できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ +### ベクトライザーのパラメーター + +以下の例では、Jina AI 固有のオプションを設定する方法を示します。 + +`dimensions` は `jina-embeddings-v2` モデルには適用されない点にご注意ください。 + + + + + + + + + + + + + + + + +## データのインポート + +ベクトライザーを設定したら、Weaviate に[データをインポート](../../manage-objects/import.mdx)します。Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデルベクトルがすでにある場合、それを直接 Weaviate に渡すことができます。同じモデルで既に埋め込みを生成している場合や、他のシステムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、 Weaviate は指定された Jina AI モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索時の Embedding 統合の図](../_includes/integration_jinaai_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、 Weaviate はテキストクエリを指定されたモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、 `limit` で設定された `n` 件の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索はベクトル検索とキーワード( BM25 )検索を行い、[結果を組み合わせて](../../search/hybrid.md)データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、 Weaviate はテキストクエリを指定されたモデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +以下のクエリは、 `limit` で設定された `n` 件の最もスコアが高いオブジェクトを返します。 + + + + + + + + + + + + + + + + + +## 参考 + +### 利用可能なモデル + +- `jina-embeddings-v3`( Weaviate `v1.26.5` と `v1.27` で追加) + - このモデルを使用すると、 Weaviate は自動的に適切な `task` タイプを使用し、エントリの埋め込みには `retrieval.passage` を、クエリには `retrieval.query` を適用します。 + - デフォルトで Weaviate は `1024` 次元を使用します +- `jina-embeddings-v2-base-en`(デフォルト) +- `jina-embeddings-v2-small-en` + +`jina-embeddings-v2` モデルでは `dimensions` は適用されませんのでご注意ください。 + +## 追加情報 + +### その他の統合 + +- [Jina AI ColBERT Embedding モデル + Weaviate](./embeddings-colbert.md) +- [Jina AI マルチモーダル Embedding モデル + Weaviate](./embeddings-multimodal.md) +- [Jina AI リランカー(reranker)モデル + Weaviate](./reranker.md) + +### コード例 + +統合がコレクションで設定されると、 Weaviate のデータ管理および検索操作は他のコレクションと同一の方法で動作します。モデルに依存しない以下の例をご覧ください。 + +- [How-to: コレクション管理](../../manage-collections/index.mdx) と [How-to: オブジェクト管理](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除)の方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作(ベクトル・キーワード・ハイブリッド)および検索拡張生成の方法を示しています。 + +### 外部リソース + +- Jina AI [Embeddings API ドキュメント](https://jina.ai/embeddings/) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/index.md new file mode 100644 index 000000000..6ade73767 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/index.md @@ -0,0 +1,50 @@ +--- +title: Jina AI と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_jinaai.jpg +# tags: ['model providers', 'jinaai'] +--- + + + +Jina AI は自然言語処理のための幅広いモデルを提供しています。 Weaviate は Jina AI の API とシームレスに統合され、ユーザーは Weaviate Database から直接 Jina AI のモデルを活用できます。 + +これらの統合により、開発者は高度な AI 主導のアプリケーションを簡単に構築できます。 + +## Jina AI との統合 + +### ベクトル検索向け埋め込みモデル + +![埋め込み統合の図](../_includes/integration_jinaai_embedding.png) + +Jina AI の埋め込みモデルはテキスト データをベクトル埋め込みに変換し、意味とコンテキストを捉えます。 + +[Weaviate は Jina AI の埋め込みモデルと統合](./embeddings.md) し、データのシームレスなベクトル化を可能にします。これにより、追加の前処理やデータ変換ステップなしで意味検索やハイブリッド検索を実行できます。 + +[Jina AI 埋め込み統合ページ](./embeddings.md) +[Jina AI ColBERT 埋め込み統合ページ](./embeddings-colbert.md) +[Jina AI マルチモーダル埋め込み統合ページ](./embeddings-multimodal.md) + +## 概要 + +これらの統合により、開発者は Weaviate 内で直接 Jina AI の強力なモデルを活用できます。 + +その結果、AI 主導のアプリケーション開発が簡素化され、開発プロセスが加速するため、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を利用するには、Weaviate に有効な Jina AI API キーを設定する必要があります。 [Jina AI](https://jina.ai/embeddings/) にアクセスしてサインアップし、API キーを取得してください。 + +次に、該当する統合ページで Jina AI モデルを用いた Weaviate の設定方法を確認し、アプリケーションで利用を開始してください。 + +- [テキスト埋め込み](./embeddings.md) +- [ColBERT 埋め込み](./embeddings-colbert.md) +- [マルチモーダル埋め込み](./embeddings-multimodal.md) +- [リランカー](./reranker.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/reranker.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/reranker.md new file mode 100644 index 000000000..16a796afc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/jinaai/reranker.md @@ -0,0 +1,205 @@ +--- +title: リランカー +sidebar_position: 70 +image: og/docs/integrations/provider_integrations_jinaai.jpg +# tags: ['model providers', 'jinaai', 'reranking'] +--- + +# Weaviate との Jina AI リランカー モデル + +:::info `v1.26.1` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.reranker.py'; +import TSCode from '!!raw-loader!../_includes/provider.reranker.ts'; + + Weaviate と Jina AI の API を統合することで、Jina AI モデルの機能を Weaviate から直接利用できます。 + +[リランカーを設定](#configure-the-reranker) して Jina AI リランカー モデルを使用すると、 Weaviate は指定したモデルとお持ちの Jina AI API キーを用いて検索結果をリランクします。 + +この 2 ステップのプロセスでは、まず Weaviate が検索を実行し、その後に指定したモデルで結果をリランクします。 + +![Reranker integration illustration](../_includes/integration_jinaai_reranker.png) + +## 要件 + +### Weaviate の構成 + +ご利用の Weaviate インスタンスには、JinaAI リランカー統合(`reranker-jinaai`)モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は Weaviate Cloud (WCD) のサーバーレス インスタンスでデフォルトで有効になっています。 + +
+ +
+ セルフホスト ユーザーの場合 + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効かどうかを確認してください。 +- Weaviate でモジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 資格情報 + +この統合を利用するには、有効な JinaAI API キーを Weaviate に提供する必要があります。Jina AI の [公式サイト](https://jina.ai/embeddings/) でサインアップし、API キーを取得してください。 + +以下のいずれかの方法で Weaviate に API キーを渡します。 + +- `JINAAI_APIKEY` 環境変数を設定し、 Weaviate から参照できるようにする。 +- 下記の例のように、実行時に API キーを渡す。 + + + + + + + + + + + + + +## リランカーを設定する + +import MutableRerankerConfig from '/_includes/mutable-reranker-config.md'; + + + +Jina AI リランカー モデルを使用するように Weaviate コレクションを設定する方法は次のとおりです。 + + + + + + + + + + + + +### モデルを選択する + +以下の設定例のように、 Weaviate で使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + +モデルを指定しない場合は [デフォルトモデル](#available-models) が使用されます。 + + + +## リランキングクエリ + +リランカーが設定されると、 Weaviate は指定した Jina AI モデルを使用して[リランキング操作](../../search/rerank.md)を実行します。 + +具体的には、 Weaviate は最初に検索を行い、その結果を指定したモデルでリランキングします。 + +Weaviate のどの検索でもリランカーと組み合わせてリランキングを実行できます。 + +![リランカー統合のイメージ](../_includes/integration_jinaai_reranker.png) + + + + + + + + + + + + + +## 参考 + +### 利用可能なモデル + +- `jina-reranker-v2-base-multilingual` (default) +- `jina-reranker-v1-base-en` +- `jina-reranker-v1-turbo-en` +- `jina-reranker-v1-tiny-en` +- `jina-colbert-v1-en` + +## 追加リソース + +### その他の統合 + +- [Jina AI テキスト埋め込みモデル + Weaviate](./embeddings.md) +- [Jina AI ColBERT 埋め込みモデル + Weaviate](./embeddings-colbert.md) +- [Jina AI マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) + +### コード例 + +統合がコレクションに設定されると、 Weaviate におけるデータ管理と検索操作は他のコレクションと同様に動作します。以下のモデル非依存の例をご覧ください: + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションやその中のオブジェクトの作成、読み取り、更新、削除)方法を説明しています。 +- [How-to: Query & Search](../../search/index.mdx) ガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索、検索拡張生成などの検索方法を紹介しています。 + +### 参考 + +- Jina AI [Reranker ドキュメント](https://jina.ai/reranker/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/_category_.json new file mode 100644 index 000000000..a2c5ceb93 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "KubeAI (Locally hosted)", + "position": 320 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/embeddings.md new file mode 100644 index 000000000..395e5ba5e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/embeddings.md @@ -0,0 +1,246 @@ +--- +title: テキスト Embeddings +description: Weaviate で KubeAI Embeddings を実装し、コンテキスト ベクトル でデータを強化します。 +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_kubeai.jpg +# tags: ['model providers', 'openai', 'embeddings'] +--- + +# Weaviate における KubeAI Embeddings + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate と OpenAI スタイルの API の統合により、Weaviate から直接 KubeAI モデル にアクセスできます。 + +[ベクトルインデックスを構成](#configure-the-vectorizer) して KubeAI の Embedding モデルを使用すると、指定したモデルで各種操作の Embedding が生成されます。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はテキストオブジェクトの Embedding を生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索では、Weaviate がテキストクエリを Embedding に変換します。 + +![Embedding integration illustration](../_includes/integration_kubeai_embedding.png) + +## 前提条件 + +### KubeAI 設定 + +KubeAI は、Embedding モデルを備えた Kubernetes クラスター内にデプロイされている必要があります。詳しくは、この [KubeAI デプロイ ガイド](https://www.kubeai.org/tutorials/weaviate/#kubeai-configuration) を参照してください。 + +### Weaviate 設定 + +ご利用の Weaviate インスタンスに `text2vec-openai` モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレス インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスト ユーザー向け + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効かどうかを確認します。 +- Weaviate でモジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 認証情報 + +OpenAI 統合には API キーが必要です。KubeAI を使用する場合、この値は KubeAI では使用されないため、任意の値を設定してください。 + +以下のいずれかの方法で Weaviate に API キーを提供します。 + +- Weaviate から参照できる `OPENAI_APIKEY` 環境変数を設定する +- 以下の例のように、実行時に API キーを渡す + + + + + + + + + + + + + +## ベクトライザーの設定 + +KubeAI Embedding モデルを使用するように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します。 + + + + + + + + + + + + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ +### ベクトライザーのパラメーター + +- `model`: KubeAI モデル名 +- `dimensions`: モデルの次元数 +- `baseURL`: KubeAI が提供する OpenAI スタイルのエンドポイント + - 通常、`baseURL` は `http://kubeai/openai` です。異なるクラスターや名前空間で Weaviate をデプロイしている場合を除きます。 + + + +## データインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。Weaviate は、指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルを再利用する +すでに互換性のあるモデルベクトルをお持ちの場合は、それを直接 Weaviate に渡すことができます。これは、同じモデルで既に埋め込みを生成しており、別のシステムからデータを移行する際などに Weaviate で再利用したい場合に便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、Weaviate は指定された KubeAI モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索における埋め込み統合の図](../_includes/integration_kubeai_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、Weaviate はテキストクエリを指定されたモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` 件の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード( BM25 )検索を実行し、その結果を[組み合わせて](../../search/hybrid.md) データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、Weaviate はテキストクエリを指定されたモデルで埋め込みに変換し、データベースから最高スコアのオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` 件の最高スコアのオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参照 + +## 追加リソース + +### その他のインテグレーション + +- [KubeAI 生成モデル + Weaviate](./generative.md) + +### コード例 + +インテグレーションがコレクションで設定されると、Weaviate のデータ管理および検索操作は他のコレクションと同様に動作します。モデル非依存の例は次のとおりです。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) では、データ操作(コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除)の方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) では、検索操作(ベクトル、キーワード、ハイブリッド)や検索拡張生成の方法を示しています。 + +### 外部リソース + +- [KubeAI documentation](https://www.kubeai.org/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/generative.md new file mode 100644 index 000000000..9147d2bcc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/generative.md @@ -0,0 +1,226 @@ +--- +title: 生成 AI +description: Weaviate で KubeAI を使用して創造的なデータ出力を行う生成モデルを設定します。 +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_kubeai.jpg +# tags: ['model providers', 'openai', 'generative', 'rag'] +--- + +# Weaviate での KubeAI 生成 AI + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate の OpenAI-style API との統合により、KubeAI モデルを Weaviate から直接利用できます。 + +[コレクションを設定](#configure-collection) して、KubeAI で生成 AI モデルを使用します。Weaviate は 検索拡張生成 (RAG) を、指定したモデルで実行します。 + +具体的には、Weaviate が検索を実行して最も関連性の高いオブジェクトを取得し、それらを KubeAI の生成モデルに渡して出力を生成します。 + +![RAG integration illustration](../_includes/integration_kubeai_rag.png) + +## 要件 + +### KubeAI の設定 + +KubeAI は埋め込みモデルを備えた Kubernetes クラスターにデプロイされている必要があります。詳細な手順については、この [KubeAI デプロイ ガイド](https://www.kubeai.org/tutorials/weaviate/#kubeai-configuration) を参照してください。 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、OpenAI 生成 AI 統合 (`generative-openai`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は Weaviate Cloud (WCD) のサーバーレス インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にする方法については、[モジュールの設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 認証情報 + +OpenAI 統合には API キー値が必要です。KubeAI を使用する場合、この値は KubeAI では使用されないため、任意の値を設定してください。 + +以下のいずれかの方法で Weaviate に API キーを渡します。 + +- Weaviate から参照できる `OPENAI_APIKEY` 環境変数を設定する +- 下記の例のように実行時に API キーを渡す + + + + + + + + + + + + + +## コレクションの設定 {#configure-collection} + +Weaviate で KubeAI 生成 AI モデルを使用するように設定します。 + + + + + + + + + + + + +vLLM または Ollama がサポートするモデルはすべて KubeAI で使用できます。 + +利用可能なモデルおよびその設定方法の詳細は、[KubeAI のモデル管理に関するドキュメント](https://www.kubeai.org/how-to/install-models/) を参照してください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するだけでなく、クエリ時に上書きすることもできます。 + + + + + + + + + + + + +## 検索拡張生成 + +生成 AI インテグレーションを設定したら、[単一プロンプト](#single-prompt)方式または[グループタスク](#grouped-task)方式で RAG 操作を実行します。 + +### 単一プロンプト + +![単一プロンプトの RAG インテグレーションは検索結果ごとに個別の出力を生成します](../_includes/integration_kubeai_rag_single.png) + +検索結果内の各オブジェクトに対してテキストを生成するには、単一プロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +単一プロンプトクエリを作成する際は、`{}` を使用して、言語モデルに渡したいオブジェクトプロパティを挿入します。たとえば、オブジェクトの `title` プロパティを渡したい場合は、クエリに `{title}` を含めます。 + + + + + + + + + + + + + +### グループタスク + +![グループタスクの RAG インテグレーションは検索結果全体に対して 1 つの出力を生成します](../_includes/integration_kubeai_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成するには、グループタスク方式を使用します。 + +つまり、`n` 件の検索結果がある場合でも、生成モデルはグループ全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + +## 追加リソース + +### 他のインテグレーション + +- [KubeAI 埋め込みモデル + Weaviate](./embeddings.md). + +### コード例 + +インテグレーションがコレクションに設定されると、Weaviate のデータ管理および検索操作は他のコレクションと同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx)および[How-to: オブジェクトを管理する](../../manage-objects/index.mdx)ガイドでは、データ操作(コレクションとその内部のオブジェクトの作成・読み取り・更新・削除)の方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx)ガイドでは、ベクトル検索・キーワード検索・ハイブリッド検索に加えて検索拡張生成の実行方法を説明しています。 + +### 外部リソース + +- [KubeAI documentation](https://www.kubeai.org/) +- [KubeAI documentation on model management](https://www.kubeai.org/how-to/install-models/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/index.md new file mode 100644 index 000000000..0f7994af8 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/kubeai/index.md @@ -0,0 +1,57 @@ +--- +title: KubeAI と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_kubeai.jpg +# tags: ['model providers', 'openai'] +--- + + + +[KubeAI](https://github.com/substratusai/kubeai) は、OpenAI 形式の API エンドポイントを通じて自然言語処理および生成のための幅広いモデルを提供します。Weaviate は KubeAI の API とシームレスに統合され、ユーザーは KubeAI の任意のモデルを Weaviate Database から直接利用できます。 + +これらの統合により、開発者は高度な AI ドリブンアプリケーションを容易に構築できます。 + +## KubeAI との統合 + +### ベクトル検索のための埋め込みモデル + +![埋め込み統合の図解](../_includes/integration_kubeai_embedding.png) + +KubeAI の埋め込みモデルはテキストデータをベクトル埋め込みへと変換し、意味と文脈を捉えます。 + +[Weaviate は KubeAI の埋め込みエンドポイントと統合](./embeddings.md)しており、データのシームレスなベクトル化を実現します。この統合により、追加の前処理やデータ変換ステップを必要とせずにセマンティック検索やハイブリッド検索を実行できます。 + +[KubeAI 埋め込み統合ページ](./embeddings.md) + +### RAG 用の生成 AI モデル + +![単一プロンプト RAG の統合は検索結果ごとに個別の出力を生成します](../_includes/integration_kubeai_rag_single.png) + +KubeAI の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間らしいテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md)を使用すると、Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。これにより、Weaviate の効率的なストレージと高速検索能力に KubeAI の生成 AI モデルを組み合わせ、パーソナライズされた文脈に応じた応答を生成します。 + +[KubeAI 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は KubeAI の強力なモデルを Weaviate 内で直接活用できます。 + +その結果、AI ドリブンアプリケーションの構築プロセスが簡素化され、開発スピードが向上し、革新的なソリューションの創出に集中できます。 + +## 開始方法 + +Kubernetes クラスターに KubeAI をデプロイし、埋め込みモデルおよび生成モデルを用意します。詳細は、[KubeAI デプロイガイド](https://www.kubeai.org/tutorials/weaviate/#kubeai-configuration)をご覧ください。 + +その後、該当する統合ページに移動し、KubeAI モデルで Weaviate を設定してアプリケーションで利用を開始してください。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/_category_.json new file mode 100644 index 000000000..2b1d68d1e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Mistral", + "position": 245 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/embeddings.md new file mode 100644 index 000000000..4857e3352 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/embeddings.md @@ -0,0 +1,332 @@ +--- +title: テキスト埋め込み +description: Weaviate で Mistral の埋め込みを使用し、高品質な ベクトル 検索結果を取得します。 +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_mistral.jpg +# tags: ['model providers', 'mistral', 'embeddings'] +--- + +# Weaviate と Mistral の埋め込み + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate が Mistral の API と統合されているため、Weaviate から直接、そのモデルの機能にアクセスできます。 + +[Weaviate の ベクトル インデックスを設定](#configure-the-vectorizer)して Mistral の埋め込みモデルを使用すると、Weaviate は指定したモデルとお持ちの Mistral API キーを利用して、さまざまな操作に必要な埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import)に、Weaviate はテキストオブジェクトの埋め込みを生成し、インデックスに保存します。 [ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![埋め込み統合のイラスト](../_includes/integration_mistral_embedding.png) + +## 要件 + +### Weaviate の構成 + +お使いの Weaviate インスタンスは、Mistral ベクトライザー統合(`text2vec-mistral`)モジュールが設定されている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスター メタデータ](/deploy/configuration/meta.md) を確認します。 +- Weaviate でモジュールを有効にするには、[モジュールの設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 資格情報 + +この統合を使用するには、有効な Mistral API キーを Weaviate に提供する必要があります。 [Mistral](https://mistral.ai/) にアクセスしてサインアップし、API キーを取得してください。 + +次のいずれかの方法で、API キーを Weaviate に渡してください。 + +- Weaviate から参照できる `MISTRAL_APIKEY` 環境変数を設定します。 +- 以下の例のように、実行時に API キーを指定します。 + + + + + + + + + + + + + + + + + +## ベクトライザーを設定する + +[Weaviate のインデックスを以下のように設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer)して、Mistral の埋め込みモデルを使用します。 + + + + + + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + + + + + +モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +## ヘッダー パラメーター + +追加のヘッダーをリクエストに含めることで、実行時に API キーおよびいくつかのオプションパラメーターを指定できます。利用可能なヘッダーは次のとおりです: + +- `X-Mistral-Api-Key`: Mistral の API キー。 +- `X-Mistral-Baseurl`: 既定の Mistral URL の代わりに使用するベース URL (例: プロキシ)。 + +実行時に指定した追加ヘッダーは、 Weaviate の既存の設定を上書きします。 + +ヘッダーは上記の [API 資格情報の例](#api-credentials) のとおりに設定してください。 + +## データのインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。 Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデルのベクトルがすでに存在する場合は、それを直接 Weaviate に渡すことができます。これは、同じモデルで既に埋め込みを生成しており、他のシステムからの移行などで Weaviate で再利用したい場合に便利です。 +::: + +## 検索 + +ベクトライザーの設定が完了すると、 Weaviate は指定した Mistral モデルを使用して ベクトル検索およびハイブリッド検索を行います。 + +![検索時の埋め込み統合を示すイラスト](../_includes/integration_mistral_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、 Weaviate はクエリテキストを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で設定した数 (`n`) だけデータベースから最も類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、 ベクトル 検索とキーワード (BM25) 検索を実行し、その後で[結果を組み合わせ](../../search/hybrid.md)てデータベースから最も適合するオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、 Weaviate はテキストクエリを指定されたモデルでエンベディングに変換し、データベースからスコアが最も高いオブジェクトを返します。 + +以下のクエリは、 `limit` で設定された `n` 件のスコアが最も高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +2024 年 9 月現在、利用可能なモデルは `mistral-embed` のみです。 + +## 追加リソース + +### その他のインテグレーション + +- [Mistral 生成モデル + Weaviate](./generative.md) + +### コード例 + +コレクションでインテグレーションを設定すると、 Weaviate におけるデータ管理と検索操作は他のコレクションとまったく同じように機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) ガイドでは、データ操作 (作成、読み取り、更新、削除) を行う方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、 ベクトル 、キーワード、ハイブリッド検索に加えて検索拡張生成を実行する方法を示しています。 + +### 外部リソース + +- Mistral [Embeddings documentation](https://docs.mistral.ai/capabilities/embeddings/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/generative.md new file mode 100644 index 000000000..b96fd47d5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/generative.md @@ -0,0 +1,300 @@ +--- +title: 生成 AI +description: "Weaviate と Mistral の API の統合により、Weaviate から直接モデルの機能を利用できます。" +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_mistral.jpg +# tags: ['model providers', 'mistral', 'generative', 'rag'] +--- + +# Weaviate と Mistral の 生成 AI + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate と Mistral の API の統合により、Weaviate から直接モデルの機能を利用できます。 + +[Mistral を使用する生成 AI モデルを設定](#configure-collection)すると、Weaviate は 指定したモデルとお客様の Mistral API キーを使って 検索拡張生成 (RAG) を実行します。 + +より具体的には、Weaviate が検索を行い、最も関連性の高いオブジェクトを取得してから、それらを Mistral の生成モデルに渡して出力を生成します。 + +![RAG 統合の図](../_includes/integration_mistral_rag.png) + +## 必要条件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、Mistral 生成 AI 統合 (`generative-mistral`) モジュールを有効にしている必要があります。 + +
+ Weaviate Cloud (WCD) 利用者向け + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスでデフォルトで有効になっています。 + +
+ +
+ セルフホスト利用者向け + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にする手順は、[モジュール設定方法](../../configuration/modules.md) をご覧ください。 + +
+ +### API 認証情報 + +この統合には、有効な Mistral API キーを Weaviate に提供する必要があります。API キーは [Mistral](https://mistral.ai/) でサインアップし、取得してください。 + +Weaviate には次のいずれかの方法で API キーを渡せます。 + +- Weaviate から参照可能な `MISTRAL_APIKEY` 環境変数を設定する +- 以下の例のように、実行時に API キーを渡す + + + + + + + + + + + + + +## コレクションを設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +Mistral の生成モデルを使用するには、次のように [Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)してください。 + + + + + + + + + + + + +### モデルを選択 + +以下の設定例のように、Weaviate が使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + +Weaviate に使用させるモデルは、[生成パラメータ](#generative-parameters)で [利用可能なモデル](#available-models) のいずれかを指定できます。何も指定しない場合は [デフォルトモデル](#available-models) が使用されます。 + + + +### 生成パラメーター + +モデルの挙動をカスタマイズするため、次の生成パラメーターを設定します。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[Mistral API ドキュメント](https://docs.mistral.ai/api/) を参照してください。 + +## 実行時にモデルを選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## ヘッダーパラメーター + +追加のリクエストヘッダーを使って、実行時に API キーおよびオプションのパラメーターを渡すことができます。利用可能なヘッダーは次のとおりです: + +- `X-Mistral-Api-Key`: Mistral の API キー。 +- `X-Mistral-Baseurl`: 既定の Mistral URL の代わりに使用するベース URL(例: プロキシ)。 + +実行時に指定した追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +上記の [API 認証情報の例](#api-credentials) に示すとおりにヘッダーを指定してください。 + +## 検索拡張生成 + +生成 AI 連携を設定したら、単一プロンプト方式またはグループ化タスク方式のいずれかで RAG 操作を実行します。 + +### 単一プロンプト + +![単一プロンプトの RAG 連携は検索結果ごとに個別の出力を生成します](../_includes/integration_mistral_rag_single.png) + +検索結果に含まれる各オブジェクトごとにテキストを生成するには、単一プロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +単一プロンプトクエリを作成する際は、波括弧 `{}` を使用して、言語モデルに渡したいオブジェクトのプロパティを埋め込みます。たとえばオブジェクトの `title` プロパティを渡すには、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスクの RAG 連携は検索結果の集合に対して 1 つの出力を生成します](../_includes/integration_mistral_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成するには、グループ化タスク方式を使用します。 + +つまり、検索結果が `n` 件あっても、生成モデルは全体で 1 件の出力のみを生成します。 + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +* `open-mistral-7b` (aka `mistral-tiny-2312`) (default) +* `open-mixtral-8x7b` (aka `mistral-small-2312`) +* `mistral-tiny` +* `mistral-small` +* `mistral-small-latest` (aka `mistral-small-2402`) +* `mistral-medium` +* `mistral-medium-latest` (aka `mistral-medium-2312`) +* `mistral-large-latest` (aka `mistral-large-2402`) + +## 追加リソース + +### その他の統合 + +- [Mistral 埋め込みモデル + Weaviate](./embeddings.md). + +### コード例 + +統合がコレクションで設定されると、 Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように動作します。以下のモデル非依存の例をご覧ください: + +- [ How-to: コレクションを管理する ](../../manage-collections/index.mdx) および [ How-to: オブジェクトを管理する ](../../manage-objects/index.mdx) ガイドでは、データ操作(すなわち コレクション および その中のオブジェクトの作成・読み取り・更新・削除)の方法を説明しています。 +- [ How-to: クエリ & 検索 ](../../search/index.mdx) ガイドでは、検索操作(つまり ベクトル、キーワード、ハイブリッド)および 検索拡張生成 の実行方法を説明しています。 + +### 参考情報 + +- Mistral [ AI API ドキュメント ](https://docs.mistral.ai/api/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/index.md new file mode 100644 index 000000000..99fe4b79a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/mistral/index.md @@ -0,0 +1,57 @@ +--- +title: Mistral + Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_mistral.jpg +# tags: ['model providers', 'mistral'] +--- + + + +Mistral は、自然言語処理と生成のための幅広いモデルを提供しています。 Weaviate は Mistral の API とシームレスに統合されており、ユーザーは Weaviate Database から直接 Mistral のモデルを活用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## Mistral との統合 + +### ベクトル検索向け埋め込みモデル + +![Embedding integration illustration](../_includes/integration_mistral_embedding.png) + +Mistral の埋め込みモデルは、テキストデータを意味と文脈を捉えた ベクトル 埋め込みに変換します。 + +[Weaviate は Mistral の埋め込みモデルと統合](./embeddings.md)しており、データのシームレスなベクトル化を実現します。これにより、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[Mistral 埋め込み統合ページ](./embeddings.md) + +### RAG 向け生成 AI モデル + +![Single prompt RAG integration generates individual outputs per search result](../_includes/integration_mistral_rag_single.png) + +Mistral の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間らしいテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md)により、 Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。これにより、 Weaviate の効率的なストレージと高速検索機能に、 Mistral の生成 AI モデルを組み合わせて、パーソナライズされた文脈に応じた応答を生成します。 + +[Mistral 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は Weaviate 内で直接 Mistral の強力なモデルを活用できます。 + +その結果、 AI 駆動アプリケーションの構築が簡素化され、開発プロセスを加速し、革新的なソリューションの創出に注力できます。 + +## はじめに + +これらの統合を利用するには、 Weaviate に有効な Mistral API キーを提供する必要があります。 [Mistral](https://mistral.ai/) にアクセスして登録し、 API キーを取得してください。 + +次に、該当する統合ページで、 Mistral モデルを使用するための Weaviate の設定方法をご確認ください。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/_category_.json new file mode 100644 index 000000000..8f8d4ff1e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "GPT4All (locally hosted)", + "position": 320 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/embeddings.md new file mode 100644 index 000000000..674fbe673 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/embeddings.md @@ -0,0 +1,315 @@ +--- +title: テキスト埋め込み +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_model2vec.jpg +# tags: ['model providers', 'model2vec', 'embeddings'] +--- + +:::info `v1.31.0` で追加 +::: + +# Weaviate との Model2Vec 埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.local.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.local.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate と Model2Vec のモデル統合により、Weaviate から直接それらのモデル機能を利用できます。 + +[Weaviate のベクトルインデックスを設定](#configure-the-vectorizer)して Model2Vec の埋め込みモデルを使用すると、Weaviate は Model2Vec 推論コンテナを介して指定したモデルで各種操作のための埋め込みを生成します。この機能は *vectorizer* と呼ばれます。 + +[インポート時](#data-import)には、Weaviate がテキストオブジェクトの埋め込みを生成してインデックスに保存します。[ベクトル](#vector-near-text-search) や [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![埋め込み統合の概要図](../_includes/integration_model2vec_embedding.png) + +## 要件 + +### Weaviate の設定 + +Weaviate インスタンスには、Model2Vec ベクトライザー統合(`text2vec-model2vec`)モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合はローカルで動作する Model2Vec インスタンスを必要とするため、Weaviate Cloud (WCD) のサーバーレスインスタンスでは利用できません。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには [クラスターメタデータ](/deploy/configuration/meta.md) をご覧ください。 +- Weaviate でモジュールを有効化するには、[モジュール設定方法](../../configuration/modules.md) を参照してください。 + +
+ +#### 統合の設定 + +この統合を使用するには、Model2Vec モデルのコンテナーイメージと、そのコンテナー化されたモデルの推論エンドポイントを設定する必要があります。 + +次の例は、Weaviate で Model2Vec 統合を設定する方法を示しています。 + + + + +#### Docker オプション 1: 事前設定済み `docker-compose.yml` ファイルを使用 + +[Weaviate Docker インストールコンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator) の手順に従い、選択したモデルが設定済みの `docker-compose.yml` ファイルをダウンロードします +
+ +#### Docker オプション 2: 手動で設定を追加 + +または、以下の例のように `docker-compose.yml` ファイルへ手動で設定を追加します。 + +```yaml +services: + weaviate: + # Other Weaviate configuration + environment: + MODEL2VEC_INFERENCE_API: http://text2vec-model2vec:8080 # Set the inference API endpoint + text2vec-model2vec: # Set the name of the inference container + image: cr.weaviate.io/semitechnologies/model2vec-inference:minishlab-potion-base-32M +``` + +- `MODEL2VEC_INFERENCE_API` 環境変数は推論 API エンドポイントを設定します +- `text2vec-model2vec` は推論コンテナーの名前です +- `image` はコンテナーイメージです + +
+ + +Weaviate の Helm チャート values ファイルの `modules` セクションに `text2vec-model2vec` モジュールを追加または更新して、Model2Vec 統合を設定します。たとえば、`values.yaml` ファイルを次のように変更します。 + +```yaml +modules: + + text2vec-model2vec: + + enabled: true + tag: minishlab-potion-base-8M + repo: semitechnologies/model2vec-inference + registry: cr.weaviate.io +``` + +より多くの設定オプションを含む `values.yaml` ファイルの例については、[Weaviate Helm チャート](https://github.com/weaviate/weaviate-helm/blob/master/weaviate/values.yaml) を参照してください。 + + +
+ +### 認証情報 + +この統合はローカルの Model2Vec コンテナーに接続するため、追加の認証情報(例: API キー)は不要です。以下の例のように通常どおり Weaviate へ接続してください。 + + + + + + + + + + + + + +## ベクトライザーの設定 + +[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer)して、Model2Vec の埋め込みモデルを使用するには次のようにします。 + + + + + + + + + + + + +この統合では、使用するモデルを Weaviate の設定ファイル内で指定します。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ + + +## データのインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。 Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデル ベクトル がすでにある場合は、それを直接 Weaviate に渡せます。すでに同じモデルで埋め込みを生成しており、別のシステムからデータを移行する際などに Weaviate で再利用したい場合に便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、 Weaviate は指定した Model2Vec モデルを使用して ベクトル 検索とハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイラスト](../_includes/integration_model2vec_embedding_search.png) + +### ベクトル(ニアテキスト)検索 + +ベクトル検索を実行すると、 Weaviate は指定されたモデルを使用してテキストクエリを埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で設定した `n` 件の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索では、ベクトル検索とキーワード(BM25)検索を行い、[結果を結合](../../search/hybrid.md) してデータベースから最適な一致オブジェクトを返します。 +::: + +ハイブリッド検索を実行すると、 Weaviate は指定されたモデルを使用してテキストクエリを埋め込みに変換し、データベースから最高スコアのオブジェクトを返します。 + +以下のクエリは、`limit` で設定した `n` 件の最高スコアのオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参考資料 + + + + + + + + + +### 利用可能なモデル + +最新のモデル一覧については、 Docker Hub の [model2vec-inference](https://hub.docker.com/r/semitechnologies/model2vec-inference/tags) コンテナのタグをご覧ください。 + +## 追加リソース + +### コード例 + +コレクションでインテグレーションが設定されると、 Weaviate のデータ管理および検索操作は他のコレクションと同様に機能します。以下のモデル非依存の例をご確認ください。 + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) の各ガイドでは、データ操作(コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除)の方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作(ベクトル、キーワード、ハイブリッド)に加えて検索拡張生成の実行方法を説明しています。 + +### 外部リソース + +- [Model2Vec ドキュメント](https://minish.ai/packages/model2vec/introduction) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/index.md new file mode 100644 index 000000000..e5444fe9a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/model2vec/index.md @@ -0,0 +1,47 @@ +--- +title: Model2Vec と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_model2vec.jpg +# tags: ['model providers', 'model2vec'] +--- + + + +Model2Vec ライブラリを利用すると、軽量でスタティックなモデルとして、さまざまな埋め込みモデルをローカルデバイス上で簡単に実行できます。Weaviate は Model2Vec ライブラリとシームレスに統合されており、互換性のあるモデルを Weaviate Database から直接活用できます。 + +これらの統合により、開発者は高度な AI ドリブンアプリケーションを簡単に構築できます。 + +## Model2Vec との統合 + +Weaviate は、ローカルでホストされている Model2Vec API にアクセスすることで、互換性のある Model2Vec モデルと統合します。 + +### ベクトル検索用埋め込みモデル + +![埋め込み統合のイメージ](../_includes/integration_model2vec_embedding.png) + +Model2Vec の埋め込みモデルは、テキストデータをベクトル 埋め込みに変換し、高速なスタティック版の sentence transformer モデルを使用します。 + +[Weaviate は Model2Vec の埋め込みモデルと統合](./embeddings.md) し、データのベクトル化を容易にします。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[Model2Vec 埋め込み統合ページ](./embeddings.md) + +## まとめ + +これらの統合により、開発者は Weaviate から直接強力な Model2Vec モデルを活用できます。 + +その結果、AI ドリブンアプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を利用するには、Model2Vec モデルをホストできるローカルホストの Weaviate インスタンスが必要です。 + +該当する統合ページで、Weaviate を Model2Vec モデルと連携させる方法を学び、アプリケーションで活用してください。 + +- [テキスト埋め込み](./embeddings.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/_category_.json new file mode 100644 index 000000000..b814517ea --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "NVIDIA", + "position": 246 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/embeddings-multimodal.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/embeddings-multimodal.md new file mode 100644 index 000000000..9ccc25f02 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/embeddings-multimodal.md @@ -0,0 +1,326 @@ +--- +title: マルチモーダル埋め込み +description: "Weaviate と NVIDIA の API を連携することで、Weaviate から直接 NVIDIA モデルの機能にアクセスできます。" +sidebar_position: 25 +image: og/docs/integrations/provider_integrations_nvidia.jpg +# tags: ['model providers', 'nvidia', 'embeddings'] +--- + +# Weaviate による NVIDIA マルチモーダル埋め込み + +:::info `v1.28.5`、`v1.29.0` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate と NVIDIA の API の統合により、Weaviate から直接 NVIDIA モデルの機能にアクセスできます。 + +[Weaviate ベクトルインデックスを設定](#configure-the-vectorizer) して NVIDIA の埋め込みモデルを使用すると、Weaviate は指定したモデルとお客様の NVIDIA NIM API キーを用いて、さまざまな操作のための埋め込みを生成します。この機能は *vectorizer* と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はマルチモーダルオブジェクトの埋め込みを生成し、インデックスに保存します。[vector](#vector-near-text-search) 検索および [hybrid](#hybrid-search) 検索では、Weaviate がテキストクエリを埋め込みに変換します。[マルチモーダル検索](#vector-near-media-search) にも対応しています。 + +![埋め込み統合のイメージ図](../_includes/integration_nvidia_embedding.png) + +## 要件 + +### Weaviate の構成 + +お使いの Weaviate インスタンスには、NVIDIA ベクトライザー統合(`multi2vec-nvidia`)モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターのメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### API 認証情報 + +この統合を利用するには、有効な NVIDIA NIM API キーを Weaviate に提供する必要があります。API キーは [NVIDIA](https://build.nvidia.com/) にサインアップして取得してください。 + +以下のいずれかの方法で Weaviate に API キーを渡します。 + +- Weaviate にアクセス可能な環境変数 `NVIDIA_APIKEY` を設定する +- 後述の例のように、実行時に API キーを渡す + + + + + + + + + + + + + +## Vectorizer の設定 + +NVIDIA の埋め込みモデルを使用するように、以下のように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します。 + + + + + + + + + + + + +### モデルの選択 + +次の設定例のように、[利用可能なモデル](#available-models) のいずれかを Vectorizer に指定できます。 + + + + + + + + + + + + +[Vectorizer のパラメーター](#vectorizer-parameters) で [利用可能なモデル](#available-models) のいずれかを指定できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化動作 + + + +
+ +### ベクトライザーのパラメーター + +次の例では、 NVIDIA 固有のオプションを設定する方法を示します。 + + + + + + + + + + + +モデルのパラメーターの詳細については、[ NVIDIA NIM API ドキュメント](https://docs.api.nvidia.com/nim/reference/retrieval-apis) を参照してください。 + +## データのインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。 Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +すでに互換性のあるモデル ベクトルがある場合は、それを直接 Weaviate に渡すことができます。同じモデルで埋め込みをすでに生成しており、別のシステムからデータを移行する際などに Weaviate で再利用したい場合に便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、 Weaviate は指定した NVIDIA モデルを使用して ベクトル 検索とハイブリッド検索を実行します。 + +![検索時の埋め込み統合の図](../_includes/integration_nvidia_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、 Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で設定した件数に基づき、データベースから `n` 件の最も類似したオブジェクトを返します。 + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード( BM25 )検索を実行し、その結果を[融合](../../search/hybrid.md#change-the-fusion-method)して、データベースから最も一致するオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、 Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースからスコアが最も高いオブジェクトを返します。 + +以下のクエリは、`limit` で設定した件数に基づき、データベースから `n` 件の最高スコアのオブジェクトを返します。 + + + + + + + + + + + + + + +### ベクトル(near media)検索 + +[near image 検索](../../search/similarity.md#search-with-image) などのメディア検索を実行すると、 Weaviate は指定したモデルを使用してクエリを埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +near image 検索などの near media 検索を行うには、メディアクエリを base64 文字列に変換し、それを検索クエリに渡します。 + +以下のクエリは、 `limit` で設定した数だけ、入力画像に最も類似した `n` 件のオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +Weaviate では、 [NVIDIA NIM APIs](https://build.nvidia.com/models) 上の任意のマルチモーダル埋め込みモデルを使用できます。 + +デフォルトモデルは `nvidia/nvclip` です。 + +## さらなるリソース + +### その他の統合 + +- [NVIDIA テキスト埋め込みモデル + Weaviate](./embeddings.md). +- [NVIDIA 生成モデル + Weaviate](./generative.md). +- [NVIDIA リランキングモデル + Weaviate](./reranker.md). + +### コード例 + +コレクションで統合を設定すると、 Weaviate のデータ管理および検索操作は他のコレクションと同じ方法で機能します。モデルに依存しない例については、以下を参照してください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) では、データ操作(作成・読み取り・更新・削除)の方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) では、ベクトル、キーワード、ハイブリッド検索、および検索拡張生成の実行方法を説明しています。 + +### 外部リソース + +- [NVIDIA NIM API documentation](https://docs.api.nvidia.com/nim/) + +## ご質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/embeddings.md new file mode 100644 index 000000000..90095e969 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/embeddings.md @@ -0,0 +1,370 @@ +--- +title: テキスト埋め込み +description: Weaviate と NVIDIA API の統合により、モデルの機能を Weaviate から直接利用できます。 +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_nvidia.jpg +# tags: ['model providers', 'nvidia', 'embeddings'] +--- + +# Weaviate における NVIDIA 埋め込み + +:::info `v1.28.5` と `v1.29.0` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate と NVIDIA API の統合により、NVIDIA モデルの機能を Weaviate から直接利用できます。 + +[NVIDIA で埋め込みモデルを使用するように Weaviate のベクトルインデックスを設定](#configure-the-vectorizer)すると、指定したモデルとお客様の NVIDIA NIM API キーを用いて、さまざまな操作のための埋め込みを Weaviate が生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import)には、Weaviate がテキストオブジェクトの埋め込みを生成してインデックスに保存します。[vector](#vector-near-text-search) や [hybrid](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![Embedding integration illustration](../_includes/integration_nvidia_embedding.png) + +## 前提条件 + +### Weaviate の構成 + +お使いの Weaviate インスタンスには、NVIDIA ベクトライザー統合モジュール (`text2vec-nvidia`) が有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) を確認してください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### API 資格情報 + +この統合を利用するには、有効な NVIDIA NIM API キーを Weaviate に提供する必要があります。[NVIDIA](https://build.nvidia.com/) にアクセスしてサインアップし、API キーを取得してください。 + +API キーは次のいずれかの方法で Weaviate に提供します。 + +- Weaviate が参照できる `NVIDIA_APIKEY` 環境変数を設定する +- 以下の例のように、実行時に API キーを渡す + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +NVIDIA の埋め込みモデルを使用するために、次のように Weaviate インデックスを設定します: + + + + + + + + + + + + + + + + + + +### モデルの選択 + +次の設定例に示すように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを [指定](#vectorizer-parameters) して、 Weaviate が使用するモデルを設定できます。モデルを指定しない場合は、 [デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +### ベクトライザーのパラメーター + +以下の例では、 NVIDIA 固有のオプションを設定する方法を示します。 + + + + + + + + + + + + + + + +モデルパラメーターの詳細については、 [NVIDIA NIM API ドキュメント](https://docs.api.nvidia.com/nim/reference/retrieval-apis) をご覧ください。 + +## データのインポート + +ベクトライザーを設定したら、 [データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。 Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存のベクトルを再利用 +互換性のあるモデルのベクトルが既にある場合は、それを直接 Weaviate に渡すことができます。同じモデルで既に埋め込みを生成しており、別のシステムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーの設定が完了すると、 Weaviate は指定した NVIDIA モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイラスト](../_includes/integration_nvidia_embedding_search.png) + +### ベクトル (near text) 検索 + +ベクトル検索を実行すると、 Weaviate は指定したモデルを使ってテキストクエリを埋め込みへ変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、 `limit` で指定した `n` 件の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索はベクトル検索とキーワード (BM25) 検索を実行し、 [結果を結合](../../search/hybrid.md#change-the-fusion-method) してデータベースから最も適合するオブジェクトを返します。 +::: + +ハイブリッド検索を実行すると、 Weaviate は指定したモデルを使ってテキストクエリを埋め込みへ変換し、データベースから最高スコアのオブジェクトを返します。 + +以下のクエリは、 `limit` で指定した `n` 件の最高スコアのオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +Weaviate では、 NVIDIA NIM APIs 上の任意のテキスト埋め込みモデルを利用できます。 + +デフォルトモデルは `nvidia/nv-embed-v1` です。 + +## さらなるリソース + +### その他の統合 + +- [NVIDIA マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) +- [NVIDIA 生成モデル + Weaviate](./generative.md) +- [NVIDIA リランカーモデル + Weaviate](./reranker.md) + +### コード例 + +コレクションで統合設定を済ませれば、 Weaviate におけるデータ管理および検索操作は他のコレクションと同様に動作します。モデルに依存しない次の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) のガイドでは、データ操作 (つまりコレクションおよびその中のオブジェクトの作成・読み取り・更新・削除) の方法を説明しています。 +- [How-to: クエリと検索](../../search/index.mdx) のガイドでは、ベクトル・キーワード・ハイブリッドなどの検索操作および 検索拡張生成 の実行方法を説明しています。 + +### 外部リソース + +- [NVIDIA NIM API ドキュメント](https://docs.api.nvidia.com/nim/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/generative.md new file mode 100644 index 000000000..b6a6a6eec --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/generative.md @@ -0,0 +1,285 @@ +--- +title: 生成 AI +sidebar_position: 51 +image: og/docs/integrations/provider_integrations_nvidia.jpg +# tags: ['model providers', 'nvidia', 'generative', 'rag'] +--- + +# Weaviate での NVIDIA 生成 AI + +:::info `v1.28.5`、`v1.29.0` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate の NVIDIA NIM API 連携を利用すると、Weaviate から直接 NVIDIA のモデル機能にアクセスできます。 + +[Weaviate コレクションを設定](#configure-collection)して NVIDIA の生成 AI モデルを使用すると、Weaviate が 検索拡張生成 (RAG) を行います。指定したモデルとお客様の NVIDIA NIM API キーを用いて処理します。 + +具体的には、Weaviate が検索を実行して最も関連性の高いオブジェクトを取得し、それらを NVIDIA の生成モデルに渡して出力を生成します。 + +![RAG 連携のイメージ](../_includes/integration_nvidia_rag.png) + +## Requirements + +### Weaviate の設定 + +ご利用の Weaviate インスタンスには NVIDIA 生成モジュール (`generative-nvidia`) が有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この連携は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効です。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定ガイド](../../configuration/modules.md) をご覧ください。 + +
+ +### API 資格情報 + +この連携を利用するには、有効な API キーを Weaviate に提供する必要があります。登録とキー取得は [NVIDIA](https://build.nvidia.com/) で行えます。 + +以下のいずれかの方法で Weaviate に API キーを渡してください。 + +- `NVIDIA_APIKEY` 環境変数を設定し、Weaviate から参照できるようにする。 +- 以降の例のように、実行時にトークンを渡す。 + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +[NVIDIA の生成 AI モデルを使用するために Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)するには、次のようにします。 + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、Weaviate に使用させる[利用可能なモデル](#available-models)のいずれかを指定できます。 + + + + + + + + + + + + +[利用可能なモデル](#available-models)のいずれかを[指定](#generative-parameters)できます。モデルを指定しない場合は[デフォルトモデル](#available-models)が使用されます。 + + + +### 生成パラメーター + +以下の生成パラメーターを設定して、モデルの挙動をカスタマイズします。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[NVIDIA API ドキュメント](https://docs.api.nvidia.com/nim/reference/llm-apis) を参照してください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するほか、クエリ時に上書きすることも可能です。 + + + + + + + + + + +## 検索拡張生成 + +生成 AI 連携を設定した後、単一プロンプト方式またはグループ化タスク方式で RAG 操作を実行します。 + +### 単一プロンプト + +![単一プロンプトの RAG 連携は検索結果ごとに個別の出力を生成します](../_includes/integration_nvidia_rag_single.png) + +検索結果内の各オブジェクトに対してテキストを生成するには、単一プロンプト方式を使用します。 + +次の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +単一プロンプトクエリを作成する際、波かっこ `{}` を使用して、言語モデルに渡したいオブジェクトのプロパティをインターポレートします。たとえばオブジェクトの `title` プロパティを渡したい場合は、クエリに `{title}` を含めます。 + + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスクの RAG 連携は検索結果全体に対して 1 つの出力を生成します](../_includes/integration_nvidia_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成するには、グループ化タスク方式を使用します。 + +つまり、`n` 件の検索結果がある場合でも、生成モデルはグループ全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +Weaviate では、[NVIDIA NIM APIs](https://build.nvidia.com/models) 上の任意の生成モデルを利用できます。 + +デフォルトのモデルは `nvidia/llama-3.1-nemotron-51b-instruct` です。 + +## 参考リソース + +### その他のインテグレーション + +- [ NVIDIA テキスト埋め込みモデル + Weaviate ](./embeddings.md). +- [ NVIDIA マルチモーダル埋め込みモデル + Weaviate ](./embeddings-multimodal.md) +- [ NVIDIA リランカーモデル + Weaviate ](./reranker.md). + +### コード例 + +コレクションでインテグレーションを設定すると、 Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように動作します。以下のモデル非依存の例をご覧ください。 + +- [ハウツー: コレクションの管理](../../manage-collections/index.mdx) と [ハウツー: オブジェクトの管理](../../manage-objects/index.mdx) のガイドでは、データ操作(つまりコレクションとその中のオブジェクトの作成・読み取り・更新・削除)の方法を紹介しています。 +- [ハウツー: クエリと検索](../../search/index.mdx) のガイドでは、検索操作(ベクトル、キーワード、ハイブリッド)および 検索拡張生成 を実行する方法を説明しています。 + +### リファレンス + +- [ NVIDIA NIM API ドキュメント](https://docs.api.nvidia.com/nim/reference/llm-apis) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/index.md new file mode 100644 index 000000000..36c64e002 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/index.md @@ -0,0 +1,70 @@ +--- +title: NVIDIA と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_nvidia.jpg +# tags: ['model providers', 'nvidia'] +--- + + + +NVIDIA NIM マイクロサービスは、自然言語処理および生成のための幅広いモデルを提供します。Weaviate は NVIDIA とシームレスに統合されており、Weaviate Database 内で推論エンジンを活用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## NVIDIA との統合 + +### ベクトル検索用埋め込みモデル + +![埋め込み統合のイラスト](../_includes/integration_nvidia_embedding.png) + +NVIDIA の埋め込みモデルは、テキストデータを高次元の ベクトル 表現へ変換し、意味と文脈を捉えます。 + +[Weaviate は NVIDIA の埋め込みモデルと統合](./embeddings.md)しており、データのシームレスなベクトル化を実現します。これにより、追加の前処理やデータ変換ステップを行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[NVIDIA 埋め込み統合ページ](./embeddings.md) +[NVIDIA マルチモーダル埋め込み統合ページ](./embeddings-multimodal.md) + +### RAG 向け生成 AI モデル + +![シングルプロンプト RAG 統合では検索結果ごとに個別の出力を生成](../_includes/integration_nvidia_rag_single.png) + +NVIDIA 上の生成 AI モデルは、与えられたプロンプトとコンテキストに基づき、人間らしいテキストを生成します。 + +[Weaviate の生成 AI 統合](./generative.md)により、Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。Weaviate の高効率なストレージと高速検索機能を、NVIDIA の生成 AI モデルと組み合わせて、パーソナライズされた文脈適応型の応答を生成します。 + +[NVIDIA 生成 AI 統合ページ](./generative.md) + +### リランカー モデル + +![リランカー統合のイラスト](../_includes/integration_nvidia_reranker.png) + +NVIDIA のリランカーモデルは、検索結果の関連度と順位付けを改善するために設計されています。 + +[Weaviate のリランカー統合](./reranker.md)を利用すると、NVIDIA のリランカーモデルで検索結果を簡単に洗練できます。 + +[NVIDIA リランカー統合ページ](./reranker.md) + +## 概要 + +この統合により、開発者は Weaviate 内で NVIDIA の推論エンジンのパワーを活用できます。 + +結果として、AI 駆動アプリケーションの構築プロセスが簡素化され、開発スピードが向上し、革新的なソリューションの創出に集中できます。 + +## 開始方法 + +この統合を利用するには、有効な NVIDIA API キーを Weaviate に提供する必要があります。[NVIDIA](https://build.nvidia.com/) にアクセスしてサインアップし、API キーを取得してください。 + +次に、該当する統合ページに移動し、Cohere モデルで Weaviate を設定してアプリケーションで使用する方法を学びましょう。 + +- [テキスト埋め込み](./embeddings.md) +- [マルチモーダル埋め込み](./embeddings-multimodal.md) +- [生成 AI](./generative.md) + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/reranker.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/reranker.md new file mode 100644 index 000000000..e5e1d0848 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/nvidia/reranker.md @@ -0,0 +1,205 @@ +--- +title: Reranker +description: NVIDIA Reranker モデルプロバイダー +sidebar_position: 70 +image: og/docs/integrations/provider_integrations_nvidia.jpg +# tags: ['model providers', 'nvidia', 'reranking'] +--- + +# Weaviate での NVIDIA Reranker モデル + +:::info Added in `v1.28.5`, `v1.29.0` +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.reranker.py'; +import TSCode from '!!raw-loader!../_includes/provider.reranker.ts'; + +Weaviate と NVIDIA の API を統合することで、NVIDIA のモデル機能を Weaviate から直接利用できます。 + +[Weaviate コレクションを設定](#configure-the-reranker)して NVIDIA のリランカーモデルを使用すると、指定したモデルとお持ちの NVIDIA NIM API キーを使って検索結果がリランキングされます。 + +この 2 段階プロセスでは、まず Weaviate が検索を実行し、その後指定したモデルで結果をリランキングします。 + +![Reranker integration illustration](../_includes/integration_nvidia_reranker.png) + +## 要件 + +### Weaviate の構成 + +お使いの Weaviate インスタンスには、NVIDIA リランカー統合モジュール (`reranker-nvidia`) が有効化されている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効です。 + +
+ +
+ セルフホストユーザーの場合 + +- モジュールが有効かどうかは [クラスターのメタデータ](/deploy/configuration/meta.md) で確認できます。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定の手順](../../configuration/modules.md) をご覧ください。 + +
+ +### API 資格情報 + +この統合を利用するには、有効な NVIDIA NIM API キーを Weaviate に提供する必要があります。API キーの取得は [NVIDIA](https://build.nvidia.com/) でサインアップしてください。 + +以下のいずれかの方法で Weaviate に API キーを渡します。 + +- `NVIDIA_APIKEY` 環境変数を設定し、Weaviate から参照できるようにする。 +- 例に示すように、実行時に API キーを渡す。 + + + + + + + + + + + + + +## リランカーの設定 + +import MutableRerankerConfig from '/_includes/mutable-reranker-config.md'; + + + +次のように Weaviate コレクションを設定し、NVIDIA のリランカーモデルを使用します。 + + + + + + + + + + + + +### モデルの選択 + +Weaviate に使用させる [利用可能なモデル](#available-models) を指定できます。以下はその設定例です。 + + + + + + + + + + + + +モデルを指定しない場合、[デフォルトモデル](#available-models) が使用されます。 + + + +## リランキングクエリ + +リランカーを設定すると、 Weaviate は指定した NVIDIA モデルを使用して [リランキング操作](../../search/rerank.md) を実行します。 + +具体的には、 Weaviate が初回検索を行った後、指定したモデルで結果をリランキングします。 + +Weaviate のあらゆる検索はリランカーと組み合わせて、リランキング操作を実行できます。 + +![Reranker integration illustration](../_includes/integration_nvidia_reranker.png) + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +Weaviate では、 NVIDIA NIM APIs 上の任意のリランカーモデルを利用できます。 +[モデル一覧はこちら](https://build.nvidia.com/models) + +デフォルトモデルは `nnvidia/rerank-qa-mistral-4b` です。 + +## 追加リソース + +### その他の統合 + +- [NVIDIA text embedding models + Weaviate](./embeddings.md) +- [NVIDIA multimodal embedding embeddings models + Weaviate](./embeddings-multimodal.md) +- [NVIDIA generative models + Weaviate](./generative.md) + +### コード例 + +コレクションで統合を設定済みであれば、 Weaviate のデータ管理および検索操作は他のコレクションと同一の手順で行えます。モデルに依存しない以下の例をご覧ください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) ガイドでは、コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除といったデータ操作方法を紹介しています。 +- [How-to: Query & Search](../../search/index.mdx) ガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索、そして 検索拡張生成 の実行方法を解説しています。 + +### 参考文献 + +- [NVIDIA NIM API documentation](https://docs.api.nvidia.com/nim/) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/_category_.json new file mode 100644 index 000000000..42d4b1b3a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "OctoAI (Deprecated)", + "position": 247 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/_includes/octoai_deprecation.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/_includes/octoai_deprecation.md new file mode 100644 index 000000000..19a00d975 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/_includes/octoai_deprecation.md @@ -0,0 +1,71 @@ +:::warning Deprecated integrations + +### OctoAI インテグレーションの非推奨 + + + +OctoAI は 2024 年 10 月 31 日 までに商用サービスの提供を終了すると発表しました。これに伴い、Weaviate の OctoAI インテグレーションは非推奨となります。新しいプロジェクトではこれらのインテグレーションを使用しないでください。 +
+ +OctoAI インテグレーションを使用しているコレクションをお持ちの場合、埋め込みモデルを利用しているか([検討事項](#for-collections-with-octoai-embedding-integrations))、生成モデルを利用しているか([検討事項](#for-collections-with-octoai-generative-ai-integrations))に応じて対応をご検討ください。 + +#### OctoAI 埋め込みインテグレーションを使用するコレクション + +OctoAI は `thenlper/gte-large` を埋め込みモデルとして提供していました。このモデルは [Hugging Face API](../../huggingface/embeddings.md) からも利用できます。 + +
+ +サービス終了日以降、このモデルは OctoAI からは利用できなくなります。このインテグレーションをご利用の場合、次の選択肢があります。 +
+ +**Option 1: 既存のコレクションを使用し、独自の ベクトル を提供する** +
+ +既存のコレクションをそのまま使い、新しいデータやクエリに必要な埋め込みは別の方法でご自身で生成できます。「bring your own ベクトル」方式に慣れていない場合は、[スターターガイド](../../../starter-guides/custom-vectors.mdx) をご参照ください。 +
+ +**Option 2: 別のモデルプロバイダーを用いた新しいコレクションへ移行する** + +あるいは、データを新しいコレクションに移行することもできます([手順はこちら](#how-to-migrate))。この際、既存の埋め込みを再利用することも、新しいモデルを選択することも可能です。 +
+ +- **既存の埋め込みを再利用する** ことで、時間と推論コストを節約できます。 +- **新しいモデルを選択する** と、最新モデルを試せるほか、アプリケーション性能を向上できる可能性があります。 + +既存の埋め込みを再利用する場合は、同じ埋め込みモデルを提供しているモデルプロバイダー(例: [Hugging Face API](../../huggingface/embeddings.md))を選択してください。 +
+ +任意の埋め込みモデルプロバイダーで新しいモデルを選択することもできます。その場合は既存の埋め込みと互換性がないため、データの埋め込みを再生成する必要があります。 +
+ +#### OctoAI 生成 AI インテグレーションを使用するコレクション + +生成 AI インテグレーションのみを使用している場合、データを新しいコレクションへ移行する必要はありません。 +
+ +[このハウツー](../../../manage-collections/generative-reranker-models.mdx#update-the-generative-model-integration) に従い、新しい生成 AI モデルプロバイダーでコレクションを再設定してください。これは Weaviate `v1.25.23`、`v1.26.8`、`v1.27.1` 以降が必要です。 +
+ +生成 AI モデルを提供している任意のモデルプロバイダーを選択できます。 +
+ +OctoAI で使用していたのと同じモデルを継続利用したい場合は、[Anyscale](../../anyscale/generative.md)、[FriendliAI](../../friendliai/generative.md)、[Mistral](../../mistral/generative.md)、あるいは [Ollama](../../ollama/generative.md) を用いたローカルモデルなどで、OctoAI が提供していたモデル群の一部を利用できます。 +
+ +#### 移行方法 + +移行プロセスの概要は次のとおりです。 +
+ +- 希望するモデルプロバイダーのインテグレーションを使って、新しいコレクションを作成します。 +- 既存のコレクションからデータをエクスポートします。 + - (任意)既存の埋め込みを再利用する場合は、埋め込みを含めてエクスポートします。 +- データを新しいコレクションにインポートします。 + - (任意)既存の埋め込みを再利用する場合は、埋め込みを含めてインポートします。 +- アプリケーションを更新して、新しいコレクションを使用するようにします。 +
+ +データオブジェクトをコレクション間で移行する例については、[How-to manage data: migrate data](../../../manage-collections/migrate.mdx) をご覧ください。 + +::: + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/embeddings.md new file mode 100644 index 000000000..e32bf86d1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/embeddings.md @@ -0,0 +1,306 @@ +--- +title: テキスト埋め込み(非推奨) +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_octoai.jpg +# tags: ['model providers', 'octoai', 'embeddings'] +--- + +import OctoAIDeprecationNote from './_includes/octoai_deprecation.md'; + + + +# Weaviate での OctoAI 埋め込み + +:::info `v1.25.0` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate が OctoAI の API と統合されているため、OctoAI のモデル機能を Weaviate から直接利用できます。 + +OctoAI の埋め込みモデルを利用するように [Weaviate の ベクトル index を設定](#configure-the-vectorizer) すると、Weaviate は指定したモデルとお客様の OctoAI API キーを用いてさまざまな操作のための埋め込みを生成します。この機能を *vectorizer* と呼びます。 + +[インポート時](#data-import) に、Weaviate はテキストオブジェクトの埋め込みを生成し、index に保存します。[ベクトル](#vector-near-text-search) 検索および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate はテキストクエリを埋め込みに変換します。 + +![埋め込み統合のイラスト](../_includes/integration_octoai_embedding.png) + +## 要件 + +### Weaviate の構成 + +ご利用の Weaviate インスタンスには、OctoAI ベクトライザー統合(`text2vec-octoai`)モジュールが設定されている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) を確認してください。 +- Weaviate でモジュールを有効にするには、[モジュールの設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 認証情報 + +この統合を利用するには、有効な OctoAI API キーを Weaviate に提供する必要があります。[OctoAI](https://octo.ai/) にアクセスしてサインアップし、API キーを取得してください。 + +以下のいずれかの方法で API キーを Weaviate に渡します: + +- Weaviate から参照できる環境変数 `OCTOAI_APIKEY` を設定する。 +- 下記の例のように、実行時に API キーを渡す。 + + + + + + + + + + + + + +## ベクトライザーの設定 + +OctoAI の埋め込みモデルを利用するには、次のように [Weaviate の index を設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します: + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + +Weaviate で利用するモデルは、[ベクトライザーのパラメーター](#vectorizer-parameters) で [利用可能なモデル](#available-models) のいずれかを指定できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ + + +### ベクトライザーのパラメーター + +- `model`: モデル名。デフォルト - `"thenlper/gte-large"`。 +- `vectorize_collection_name`: コレクション名をベクトル化するかどうか。デフォルト - `True`。 +- `base_url`: デフォルトの OctoAI URL である `"https://text.octoai.run"` の代わりに使用する URL(プロキシなど)。 + +以下の例は、OctoAI 固有のオプションを設定する方法を示します。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[OctoAI API ドキュメント](https://octo.ai/docs/text-gen-solution/getting-started) をご覧ください。 + +## データのインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx)して Weaviate に取り込みます。Weaviate は、指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +すでに互換性のあるモデルのベクトルをお持ちの場合は、それを直接 Weaviate に渡すことができます。同じモデルで埋め込みを生成済みの場合や、別のシステムからデータを移行する際に便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、Weaviate は指定した OctoAI モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイラスト](../_includes/integration_octoai_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で指定した数 n 件の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を行い、その結果を[組み合わせて](../../search/hybrid.md)データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +次のクエリは、`limit` で指定した数 n 件の最高スコアのオブジェクトを返します。 + + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +`text2vec-octoai` を使用すると、 OctoAI がホストする任意の埋め込みモデルを利用できます。 + +現在 OctoAI が [公開している](https://octo.ai/docs/text-gen-solution/getting-started) 埋め込みモデルは次のとおりです: + +* `thenlper/gte-large` + +## 追加リソース + +### その他の統合 + +- [OctoAI 生成モデル + Weaviate](./generative.md). + +### コード例 + +コレクションで統合を設定すると、 Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように動作します。モデルに依存しない以下の例をご覧ください: + +- [ 操作方法: コレクションを管理する ](../../manage-collections/index.mdx) および [ 操作方法: オブジェクトを管理する ](../../manage-objects/index.mdx) ガイドでは、データ操作 (すなわちコレクションおよびその中のオブジェクトの作成・参照・更新・削除) の方法を説明しています。 +- [ 操作方法: クエリ & 検索 ](../../search/index.mdx) ガイドでは、 ベクトル ・キーワード・ハイブリッド検索に加え、 検索拡張生成 の実行方法を説明しています。 + +### 外部リソース + +- OctoAI [ Embed API ドキュメント](https://octo.ai/docs/text-gen-solution/getting-started) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/generative.md new file mode 100644 index 000000000..fa2004ad0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/generative.md @@ -0,0 +1,276 @@ +--- +title: 生成 AI(非推奨) +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_octoai.jpg +# tags: ['model providers', 'octoai', 'generative', 'rag'] +--- + +import OctoAIDeprecationNote from './_includes/octoai_deprecation.md'; + + + +# Weaviate と OctoAI の生成 AI + + +:::info `v1.25.0` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate と OctoAI の API を統合することで、オープンソースと OctoAI のモデル機能に Weaviate から直接アクセスできます。 + +[Weaviate コレクションを設定](#configure-collection)して OctoAI の生成 AI モデルを使用すると、Weaviate は指定したモデルとお持ちの OctoAI API キーを用いて検索拡張生成 (RAG) を実行します。 + +具体的には、Weaviate が検索を行い、最も関連性の高いオブジェクトを取得したうえで、それらを OctoAI の生成モデルに渡して出力を生成します。 + +![RAG integration illustration](../_includes/integration_octoai_rag.png) + +## 要件 + +### Weaviate 構成 + +ご利用の Weaviate インスタンスには、OctoAI 生成 AI 統合モジュール (`generative-octoai`) が有効化されている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザーの場合 + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効です。 + +
+ +
+ セルフホストユーザーの場合 + +- モジュールが有効かどうかは [クラスターメタデータ](/deploy/configuration/meta.md) を確認してください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定ガイド](../../configuration/modules.md) をご覧ください。 + +
+ +### API 認証情報 + +この統合を使用するには、有効な OctoAI API キーを Weaviate に渡す必要があります。サインアップして API キーを取得するには、[OctoAI](https://octo.ai/docs/getting-started/how-to-create-an-octoai-access-token) にアクセスしてください。 + +Weaviate への API キーの渡し方は次のいずれかです。 + +- Weaviate から参照可能な環境変数 `OCTOAI_APIKEY` を設定する +- 下記の例のように実行時に API キーを渡す + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +[Weaviate インデックスの設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)を以下のように行い、OctoAI の生成 AI モデルを使用します。 + + + + + + + + + + + + +### モデルの選択 + +Weaviate に使用させる [利用可能なモデル](#available-models) のいずれかを、次の設定例のように指定できます。 + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを [指定](#generative-parameters) できます。指定しない場合は [デフォルトモデル](#available-models) が使用されます。 + + + +### 生成パラメーター + +モデルの挙動をカスタマイズするには、以下の生成パラメーターを設定します。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[OctoAI API documentation](https://octo.ai/docs/text-gen-solution/rest-api) を参照してください。 + +## 検索拡張生成 + +生成 AI 統合を設定したら、[シングルプロンプト](#single-prompt) または [グループタスク](#grouped-task) の方法で RAG 操作を実行します。 + +### シングルプロンプト + +![Single prompt RAG integration generates individual outputs per search result](../_includes/integration_octoai_rag_single.png) + +検索結果の各オブジェクトに対してテキストを生成する場合は、シングルプロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定された `n` 件の検索結果それぞれに対し出力を生成します。 + +シングルプロンプトクエリを作成する際、Weaviate から言語モデルへ渡したいオブジェクトプロパティを波かっこ `{}` で囲んでインターポレーションします。たとえば、オブジェクトの `title` プロパティを渡す場合はクエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループタスク + +![Grouped task RAG integration generates one output for the set of search results](../_includes/integration_octoai_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成する場合は、グループタスク方式を使用します。 + +言い換えると、`n` 件の検索結果がある場合でも、生成モデルはグループ全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +* `qwen1.5-32b-chat` +* `meta-llama-3-8b-instruct` +* `meta-llama-3-70b-instruct` +* `mixtral-8x22b-instruct` +* `nous-hermes-2-mixtral-8x7b-dpo` +* `mixtral-8x7b-instruct` +* `mixtral-8x22b-finetuned` +* `hermes-2-pro-mistral-7b` +* `mistral-7b-instruct` (default) +* `codellama-7b-instruct` +* `codellama-13b-instruct` +* `codellama-34b-instruct` +* `llama-2-13b-chat` +* `llama-2-70b-chat` + +## 追加リソース + +### その他の統合 + +- [OctoAI embedding models + Weaviate](./embeddings.md) + +### コード例 + +コレクションで統合を設定すると、Weaviate のデータ管理および検索操作は他のコレクションと同様に動作します。以下のモデル非依存の例を参照してください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) および [How-to: Manage objects](../../manage-objects/index.mdx) ガイドでは、データ操作 (コレクションおよびその中のオブジェクトの作成、読み取り、更新、削除) 方法を示しています。 +- [How-to: Query & Search](../../search/index.mdx) ガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索に加え、検索拡張生成の実行方法を示しています。 + +### 参考資料 + +- OctoAI [API ドキュメント](https://octo.ai/docs/getting-started/inference-models) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/index.md new file mode 100644 index 000000000..d2aa7d18f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/octoai/index.md @@ -0,0 +1,63 @@ +--- +title: OctoAI + Weaviate(非推奨) +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_octoai.jpg +# tags: ['model providers', 'octoai'] +--- + + + +import OctoAIDeprecationNote from './_includes/octoai_deprecation.md'; + + + +:::info `v1.25.0` で追加 +::: + +OctoAI は自然言語処理と生成のための幅広いモデルを提供しています。 Weaviate は OctoAI の API とシームレスに統合されており、ユーザーは Weaviate Database から直接 OctoAI のモデルを活用できます。 + +これらの統合により、開発者は高度な AI ドリブンアプリケーションを簡単に構築できます。 + +## OctoAI との統合 + +### ベクトル検索の埋め込みモデル + +![埋め込み統合のイメージ](../_includes/integration_octoai_embedding.png) + +OctoAI の埋め込みモデルはテキストデータをベクトル埋め込みに変換し、意味と文脈を捉えます。 + +[Weaviate は OctoAI の埋め込みモデルと統合しています](./embeddings.md) ので、データをシームレスにベクトライゼーションできます。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[OctoAI 埋め込み統合ページ](./embeddings.md) + +### RAG 用生成 AI モデル + +![単一プロンプト RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_octoai_rag_single.png) + +OctoAI の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間のようなテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md) を使用すると、検索拡張生成 (RAG) を Weaviate Database から直接実行できます。これにより、Weaviate の効率的なストレージと高速検索機能が OctoAI の生成 AI モデルと組み合わさり、パーソナライズされた文脈に沿った応答を生成します。 + +[OctoAI 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は Weaviate 内で直接 OctoAI の強力なモデルを活用できます。 + +その結果、AI ドリブンアプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を使用するには、有効な OctoAI API キーを Weaviate に提供する必要があります。 [OctoAI](https://octo.ai/) にアクセスしてサインアップし、API キーを取得してください。 + +次に、該当する統合ページで OctoAI モデルを使用するための Weaviate の設定方法を確認し、アプリケーションで活用しましょう。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/_category_.json new file mode 100644 index 000000000..3e8a45ab2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Ollama (locally hosted)", + "position": 370 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/embeddings.md new file mode 100644 index 000000000..689329abd --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/embeddings.md @@ -0,0 +1,282 @@ +--- +title: テキスト埋め込み +description: Ollama 埋め込みプロバイダー +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_ollama.jpg +# tags: ['model providers', 'ollama', 'embeddings'] +--- + +# Weaviate との Ollama 埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.local.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.local.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + + Weaviate の Ollama モデル統合を使用すると、Weaviate から直接モデルの機能にアクセスできます。 + +[ベクトルインデックスを設定](#configure-the-vectorizer) して Ollama の埋め込みモデルを指定すると、Weaviate がローカルの Ollama インスタンス経由で指定したモデルを使用して各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はテキストオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![Embedding integration illustration](../_includes/integration_ollama_embedding.png) + +## 要件 + +### Ollama + +この統合には、選択したモデルが使用可能なローカル実行中の Ollama インスタンスが必要です。インストールおよびモデルダウンロードの手順については、[Ollama のドキュメント](https://ollama.com/) を参照してください。 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスは、Ollama ベクトライザー統合 ( `text2vec-ollama` ) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud ( WCD ) ユーザー向け + +この統合は Weaviate Cloud ( WCD ) のサーバーレスインスタンスではデフォルトで有効になっています。 +
+ +Ollama を Weaviate Cloud で使用するには、Ollama サーバーが起動しており、Weaviate Cloud インスタンスからアクセス可能であることを確認してください。ご自身のマシンで Ollama を実行している場合、インターネットに公開する必要があるかもしれません。Ollama サーバーをインターネットに公開する際は、セキュリティへの影響を慎重に検討してください。 +
+ +このようなユースケースでは、自己ホスト型の Weaviate インスタンスや、他の API ベースの統合方法の利用を検討してください。 + +
+ +
+ 自己ホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効化する手順は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### 資格情報 + +この統合はローカルの Ollama コンテナに接続するため、追加の資格情報 (例:API キー) は不要です。以下の例のように通常どおり Weaviate へ接続してください。 + + + + + + + + + + + + + +## ベクトライザーの設定 + +Ollama 埋め込みモデルを使用するには、以下のように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します。 + + + + + + + + + + + + +モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import APIEndpoint from '/docs/weaviate/model-providers/_includes/ollama/api-endpoint.mdx'; + + + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ + + +## データ インポート + +ベクトライザーの設定後、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。Weaviate は、指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +すでに互換性のあるモデルベクトルをお持ちの場合は、それを直接 Weaviate に渡すこともできます。同じモデルでエンベディングを生成済みで、それらを Weaviate で利用したい場合、たとえば別システムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した Ollama モデルを用いてベクトル検索とハイブリッド検索を実行します。 + +![検索時のエンベディング統合の図](../_includes/integration_ollama_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、Weaviate はクエリテキストを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` 件の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を実行し、その結果を[組み合わせて](../../search/hybrid.md) データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、Weaviate はクエリテキストを指定したモデルで埋め込みに変換し、データベースから最も高スコアのオブジェクトを返します。 + +以下のクエリは、`limit` で指定した数 `n` 件の最高スコアのオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## 参考 + + + + + + + + + +### 利用可能なモデル + +利用可能なモデルの一覧については、[Ollama ドキュメント](https://ollama.com/library) をご覧ください。この一覧には大規模言語モデルと埋め込みモデルの両方が含まれています。埋め込みモデルを識別するには、名前または説明に `embed` が含まれているかを確認してください。 + +`ollama pull ` で目的のモデルをダウンロードします。 + +モデルを指定しない場合、デフォルトモデル (`nomic-embed-text`) が使用されます。 + +## 参考リソース + +### その他の統合 + +- [Ollama 生成モデル + Weaviate](./generative.md) + +### コード例 + +統合をコレクションで設定すると、 Weaviate のデータ管理および検索操作は他のコレクションとまったく同じように動作します。以下のモデル非依存の例をご覧ください: + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) のガイドでは、データ操作 (コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除) の方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) のガイドでは、ベクトル・キーワード・ハイブリッド検索や 検索拡張生成 を実行する方法を示しています。 + +### 外部リソース + +- [Ollama モデル](https://ollama.com/library) +- [Ollama リポジトリ](https://github.com/ollama/ollama) +- [Ollama サーバーのホストとポートを変更する方法](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-expose-ollama-on-my-network) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/generative.md new file mode 100644 index 000000000..3ff99de3a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/generative.md @@ -0,0 +1,288 @@ +--- +title: 生成 AI +description: Ollama 生成モデルプロバイダー +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_ollama.jpg +# tags: ['model providers', 'ollama', 'generative', 'rag'] +--- + +# Weaviate と Ollama の生成 AI + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.local.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.local.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + + Weaviate と Ollama のモデルを統合すると、 Weaviate から直接それらのモデル機能にアクセスできます。 + +[ Weaviate コレクションを設定](#configure-collection)して、 Ollama の生成 AI モデルを利用します。 Weaviate は指定したモデルを介してローカルの Ollama インスタンスと連携し、検索拡張生成 ( RAG ) を実行します。 + +具体的には、 Weaviate が検索を実行し、最も関連性の高いオブジェクトを取得した後、それらを Ollama の生成モデルに渡して出力を生成します。 + +![RAG integration illustration](../_includes/integration_ollama_rag.png) + +## 要件 + +### Ollama + +この統合には、選択したモデルが利用可能なローカル実行中の Ollama インスタンスが必要です。インストールとモデルのダウンロード方法については、[ Ollama ドキュメント](https://ollama.com/)を参照してください。 + +### Weaviate 設定 + +お使いの Weaviate インスタンスには、 Ollama 生成 AI 統合 ( `generative-ollama` ) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud ( WCD ) ユーザーの方へ + +この統合は Weaviate Cloud ( WCD ) の serverless インスタンスでデフォルトで有効になっています。 +
+ + Weaviate Cloud で Ollama を使用するには、 Ollama サーバーが稼働しており、 Weaviate Cloud インスタンスからアクセス可能であることを確認してください。ご自身のマシンで Ollama を実行している場合は、インターネットに公開する必要があるかもしれません。 Ollama サーバーをインターネットに公開する際のセキュリティ上の影響を慎重にご検討ください。 +
+ +このようなユースケースでは、セルフホストの Weaviate インスタンスや、その他の API ベースの統合方法の利用をご検討ください。 + +
+ +
+ セルフホストユーザーの方へ + +- [クラスターメタデータ](/deploy/configuration/meta.md)を確認し、モジュールが有効かどうかを確かめてください。 +- Weaviate でモジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md)ガイドに従ってください。 + +
+ +お使いの Weaviate インスタンスから Ollama エンドポイントへアクセスできる必要があります。 Docker を使用している場合は、コンテナ内からホストマシンへアクセスするために、[ `host.docker.internal` を使用して Ollama エンドポイントを指定](#configure-collection)してください。 + +### 資格情報 + +この統合はローカルの Ollama コンテナに接続するため、追加の資格情報 (例: API キー) は不要です。以下の例のように通常どおり Weaviate へ接続してください。 + + + + + + + + + + + + + +## コレクションの設定 {#configure-collection} + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +[ Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)して、 Ollama 生成モデルを使用するには以下のようにします。 + + + + + + + + + + + + +import APIEndpoint from '/docs/weaviate/model-providers/_includes/ollama/api-endpoint.mdx'; + + + +モデルを指定しない場合は、[デフォルトモデル](#available-models)が使用されます。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## 検索拡張生成 (RAG) + +生成 AI 連携を設定したら、RAG 操作を [単一プロンプト](#single-prompt) 方法または [グループ化タスク](#grouped-task) 方法で実行できます。 + +### 単一プロンプト + +![単一プロンプト RAG 連携により検索結果ごとに個別の出力を生成](../_includes/integration_ollama_rag_single.png) + +検索結果内の各オブジェクトに対してテキストを生成するには、単一プロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +単一プロンプトクエリを作成する際、Weaviate が言語モデルに渡すオブジェクトのプロパティを中括弧 `{}` で挿入します。たとえばオブジェクトの `title` プロパティを渡したい場合、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスク RAG 連携により検索結果全体に対して 1 つの出力を生成](../_includes/integration_ollama_rag_grouped.png) + +検索結果の集合全体に対して 1 つのテキストを生成するには、グループ化タスク方式を使用します。 + +言い換えると、`n` 件の検索結果があっても、生成モデルはその全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + +### 画像を含む RAG + +単一プロンプトとグループ化タスクのどちらでも、入力の一部として画像を渡すことができます。 + + + + + + + + + + + +## 参考資料 + + + + +### 利用可能なモデル + +[ Ollama ドキュメント](https://ollama.com/library) で利用可能なモデルの一覧をご覧いただけます。 この一覧には生成モデルと埋め込みモデルの両方が含まれている点にご注意ください。 `generative-ollama` モジュールには生成モデルを指定してください。 + +目的のモデルは `ollama pull ` でダウンロードできます。 + +モデルを指定しない場合は、デフォルトで `llama3` が使用されます。 + +## 追加リソース + +### その他の統合 + +- [ Ollama 埋め込みモデル + Weaviate](./embeddings.md). + +### コード例 + +コレクションで統合を設定すると、 Weaviate でのデータ管理および検索操作は他のコレクションと同様に動作します。 以下のモデル非依存の例をご覧ください: + +- [How-to: コレクションの管理](../../manage-collections/index.mdx) と [How-to: オブジェクトの管理](../../manage-objects/index.mdx) ガイドでは、データ操作 (つまり、コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除) の方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、ベクトル、キーワード、ハイブリッド検索に加えて 検索拡張生成 を実行する方法を説明しています。 + +### 参考資料 + +- [ Ollama モデル](https://ollama.com/library) +- [ Ollama レポジトリ](https://github.com/ollama/ollama) +- [ Ollama サーバーのホストとポートを変更する方法](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-can-i-expose-ollama-on-my-network) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/index.md new file mode 100644 index 000000000..fd1f7096a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/ollama/index.md @@ -0,0 +1,58 @@ +--- +title: Ollama と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_ollama.jpg +# tags: ['model providers', 'ollama'] +--- + + + +Ollama ライブラリを使用すると、幅広いモデルを自身のデバイス上で簡単に実行できます。Weaviate は Ollama ライブラリとシームレスに統合されており、ユーザーは Weaviate Database から直接互換性のあるモデルを活用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを容易に構築できます。 + +## Ollama との統合 + +Weaviate は、ローカルでホストされている Ollama API にアクセスすることで、互換性のある Ollama モデルと統合します。 + +### ベクトル検索向け埋め込みモデル + +![Embedding integration illustration](../_includes/integration_ollama_embedding.png) + +Ollama の埋め込みモデルはテキストデータをベクトル埋め込みに変換し、意味とコンテキストを捉えます。 + +[Weaviate は Ollama の埋め込みモデルと統合](./embeddings.md)してデータのシームレスなベクトル化を実現します。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[Ollama 埋め込み統合ページ](./embeddings.md) + +### RAG 向け生成 AI モデル + +![Single prompt RAG integration generates individual outputs per search result](../_includes/integration_ollama_rag_single.png) + +Ollama の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間らしいテキストを生成します。 + +[Weaviate の生成 AI 統合](./generative.md)により、Weaviate Database から直接検索拡張生成 (RAG) を実行できます。これにより、Weaviate の効率的なストレージと高速検索機能を、Ollama の生成 AI モデルと組み合わせて、パーソナライズされたコンテキスト認識の応答を生成します。 + +[Ollama 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は Weaviate 内から強力な Ollama モデルを活用できます。 + +その結果、AI 駆動アプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創出に集中できます。 + +## はじめる + +これらの統合を利用するには、Ollama モデルをホストするためにローカルで Weaviate インスタンスを起動する必要があります。 + +該当する統合ページに進み、Ollama モデルを使用するための Weaviate の設定方法を確認してください。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/_category_.json new file mode 100644 index 000000000..52a4fbc22 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Azure OpenAI", + "position": 251 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/embeddings.md new file mode 100644 index 000000000..4e1adbc0c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/embeddings.md @@ -0,0 +1,343 @@ +--- +title: テキスト 埋め込み +description: "Weaviate の Azure OpenAI API 連携により、Weaviate から直接モデルの機能を利用できます。" +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_openai_azure.jpg +# tags: ['model providers', 'azure', 'openai', 'embeddings'] +--- + +# Weaviate での Azure OpenAI 埋め込み + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate の Azure OpenAI API 連携により、Weaviate から直接モデルの機能を利用できます。 + +[Weaviate ベクトル インデックスを設定](#configure-the-vectorizer) して Azure OpenAI の埋め込みモデルを使用すると、指定したモデルとお持ちの Azure OpenAI API キーを使って、Weaviate が各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート 時](#data-import) には、Weaviate がテキスト オブジェクトの埋め込みを生成し、インデックスに保存します。また、[ベクトル](#vector-near-text-search) と [ハイブリッド](#hybrid-search) 検索時には、Weaviate がテキスト クエリを埋め込みに変換します。 + +![Embedding integration illustration](../_includes/integration_openai_azure_embedding.png) + +## 要件 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスには、Azure OpenAI ベクトライザー連携 (`text2vec-openai`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この連携は、Weaviate Cloud (WCD) のサーバーレス インスタンスでデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスタ メタデータ](/deploy/configuration/meta.md) をご確認ください。 +- Weaviate でモジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 認証情報 + +この連携を利用するには、有効な Azure OpenAI API キーを Weaviate に提供する必要があります。API キーを取得するには、[Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-foundry/models/openai/) にアクセスしてサインアップしてください。 + +以下のいずれかの方法で Weaviate に API キーを渡します。 + +- Weaviate が参照できる `AZURE_APIKEY` 環境変数を設定する +- 下記の例のように、実行時に API キーを渡す + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) し、Azure OpenAI の埋め込みモデルを使用する方法を以下に示します。 + +モデルを選択するには、Azure リソース名を指定します。 + + + + + + + + + + + + + + + + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ + + +### ベクトライザーのパラメーター + +以下の例では、Azure OpenAI 固有のオプションを設定する方法を示します。 + +- `resource_name` (必須): 使用する Azure OpenAI リソースの名前。 +- `deployment_id` (必須): Azure OpenAI リソースのデプロイメント ID。 +- `base_url` (任意): Azure OpenAI API のベース URL。 + + + + + + + + + + + + + + + + +これらのパラメーターの詳細については、[Azure OpenAI API ドキュメント](https://learn.microsoft.com/en-us/azure/ai-services/openai/) を参照してください。 + +## ヘッダー パラメーター + +追加のヘッダーをリクエストに含めることで、 API キーやいくつかの任意パラメーターを実行時に指定できます。利用可能なヘッダーは次のとおりです。 + +- `X-Azure-Api-Key`: Azure API キー。 +- `X-Azure-Deployment-Id`: Azure デプロイメント ID。 +- `X-Azure-Resource-Name`: Azure リソース名。 + +実行時に指定した追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +上記の [API 資格情報の例](#api-credentials) のとおりにヘッダーを指定してください。 + +## データのインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。Weaviate は指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存のベクトルを再利用 +すでに互換性のあるモデルベクトルがある場合は、それを直接 Weaviate に渡すことができます。同じモデルで既に埋め込みを生成しており、それらを Weaviate で利用したい場合、たとえば他のシステムからデータを移行する際に便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した Azure OpenAI モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![Embedding integration at search illustration](../_includes/integration_openai_azure_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で指定した件数 `n` 件の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info What is a hybrid search? +ハイブリッド検索は、ベクトル検索とキーワード (BM25) 検索を実行し、その後 [結果を組み合わせて](../../search/hybrid.md) データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、 Weaviate はテキストクエリを指定されたモデルで埋め込みに変換し、データベースからスコアが最も高いオブジェクトを返します。 + +以下のクエリは、 `limit` で設定した `n` 件の最上位オブジェクトを返します。 + + + + + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +利用可能なモデルとリージョンごとの提供状況については、 [Azure OpenAI のドキュメント](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#embeddings-models) を参照してください。 + +## 追加リソース + +### その他のインテグレーション + +- [Azure OpenAI 生成モデル + Weaviate](./generative.md) + +### コード例 + +インテグレーションがコレクションに設定されると、 Weaviate のデータ管理および検索操作は他のコレクションと同様に機能します。モデルに依存しない以下の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) ガイドでは、データ操作 (作成、読み取り、更新、削除) の方法を示しています。 +- [How-to: クエリと検索](../../search/index.mdx) ガイドでは、ベクトル、キーワード、ハイブリッド検索や検索拡張生成の方法を説明しています。 + +### 外部リソース + +- Azure OpenAI [API ドキュメント](https://learn.microsoft.com/en-us/azure/ai-services/openai/) +- Azure OpenAI [モデルと提供状況](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#embeddings-models) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/generative.md new file mode 100644 index 000000000..a09a2f662 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/generative.md @@ -0,0 +1,245 @@ +--- +title: 生成 AI +description: OpenAI-Azure 生成モデルプロバイダー +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_openai_azure.jpg +# tags: ['model providers', 'azure', 'openai', 'generative', 'rag'] +--- + +# Weaviate を用いた Azure OpenAI 生成 AI + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate と Azure OpenAI の API を統合することで、モデルの機能に Weaviate から直接アクセスできます。 + +[コレクションを設定](#configure-collection)して Azure OpenAI の 生成 AI モデルを使用すると、Weaviate は指定したモデルとお持ちの Azure OpenAI API キーを用いて 検索拡張生成 (RAG) を実行します。 + +具体的には、Weaviate が検索を行い、最も関連性の高いオブジェクトを取得し、それらを Azure OpenAI の 生成モデルに渡して出力を生成します。 + +![RAG 統合のイメージ](../_includes/integration_openai_azure_rag.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、Azure OpenAI 生成 AI 統合モジュール(`generative-openai`)が有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- [クラスターメタデータ](/deploy/configuration/meta.md)を確認して、モジュールが有効かどうか検証してください。 +- Weaviate でモジュールを有効化する方法は、[モジュール設定方法](../../configuration/modules.md)をご覧ください。 + +
+ +### API 資格情報 + +この統合を使用するには、有効な Azure OpenAI API キーを Weaviate に提供する必要があります。API キーの取得については [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-foundry/models/openai/) にアクセスしてください。 + +以下のいずれかの方法で API キーを Weaviate に渡します。 + +- Weaviate から参照可能な `AZURE_APIKEY` 環境変数を設定する +- 例に示すように、実行時に API キーを渡す + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +OpenAI Azure の 生成モデルを使用するには、以下のように [Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)してください。 + +モデルを選択するには、Azure のリソース名を指定します。 + + + + + + + + + + + + +### 生成パラメーター + +以下の生成パラメーターを設定して、モデルの動作をカスタマイズできます。 + + + + + + + + + + + + +これらのパラメーターの詳細については、[Azure OpenAI API ドキュメント](https://learn.microsoft.com/en-us/azure/ai-services/openai/)を参照してください。 + +## ヘッダー パラメーター + +実行時にリクエストの追加ヘッダーを通じて、API キーといくつかのオプションパラメーターを指定できます。利用可能なヘッダーは次のとおりです。 + +- `X-Azure-Api-Key`: Azure API キー +- `X-Azure-Deployment-Id`: Azure デプロイメント ID +- `X-Azure-Resource-Name`: Azure リソース名 + +実行時に指定された追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +ヘッダーは上記の [API 資格情報の例](#api-credentials) のとおりに指定してください。 + +## 検索拡張生成 + +生成 AI 連携を設定した後、[シングル プロンプト](#single-prompt) または [グループ化タスク](#grouped-task) のいずれかの方法で RAG 操作を実行します。 + +### シングル プロンプト + +![シングル プロンプトの RAG 連携は検索結果ごとに個別の出力を生成します](../_includes/integration_openai_azure_rag_single.png) + +検索結果に含まれる各オブジェクトごとにテキストを生成するには、シングル プロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +シングル プロンプト クエリを作成する際は、Weaviate が言語モデルに渡すオブジェクトのプロパティを波かっこ `{}` でインターポレートします。たとえば、オブジェクトの `title` プロパティを渡すには、クエリ内に `{title}` を含めます。 + + + + + + + + + + + + + +### グループ化タスク + +![グループ化タスクの RAG 連携は検索結果の集合に対して 1 つの出力を生成します](../_includes/integration_openai_azure_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成するには、グループ化タスク方式を使用します。 + +言い換えると、`n` 件の検索結果がある場合でも、生成モデルはその集合に対して 1 つの出力のみを生成します。 + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +利用可能なモデルとリージョンごとの提供状況については、[Azure OpenAI ドキュメント](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models) を参照してください。 + +## 追加リソース + +### そのほかのインテグレーション + +- [Azure OpenAI 埋め込みモデル + Weaviate](./embeddings.md) + +### コード例 + +インテグレーションがコレクションに対して設定されると、Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じ方法で動作します。モデルに依存しない次の例をご覧ください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) のガイドでは、データ操作(コレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)の方法を説明しています。 +- [How-to: Query & Search](../../search/index.mdx) のガイドでは、ベクトル、キーワード、ハイブリッドなどの検索操作および検索拡張生成の実行方法を説明しています。 + +### 参考リンク + +- Azure OpenAI [API documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/) +- Azure OpenAI [models and availability](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/index.md new file mode 100644 index 000000000..60d5dc7fc --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai-azure/index.md @@ -0,0 +1,56 @@ +--- +title: Azure OpenAI と Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_openai_azure.jpg +# tags: ['model providers', 'azure', 'openai'] +--- + + + +Microsoft Azure は自然言語処理と生成のために幅広い OpenAI モデルを提供しています。Weaviate は Microsoft Azure の API とシームレスに統合し、ユーザーは OpenAI のモデルを Weaviate データベースから直接活用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを容易に構築できます。 + +## Azure OpenAI との統合 + +### ベクトル検索用の埋め込みモデル + +![埋め込み統合の図](../_includes/integration_openai_azure_embedding.png) + +Azure OpenAI の埋め込みモデルは、テキストデータを意味と文脈を捉えたベクトル埋め込みへと変換します。 + +[Weaviate は Azure OpenAI の埋め込みモデルと統合](./embeddings.md)し、データのシームレスなベクトル化を実現します。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実施できます。 + +[Azure OpenAI 埋め込み統合ページ](./embeddings.md) + +### RAG 用の生成 AI モデル + +![シングルプロンプト RAG 統合は検索結果ごとに個別の出力を生成](../_includes/integration_openai_azure_rag_single.png) + +Azure OpenAI の生成 AI モデルは、与えられたプロンプトとコンテキストに基づき、人間らしいテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md)を使用すると、Weaviate データベースから直接 Retrieval augmented generation を実行できます。これは、Weaviate の効率的なストレージと高速検索機能を Azure OpenAI の生成 AI モデルと組み合わせ、個別で文脈に合った応答を生成します。 + +[Azure OpenAI 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は Azure OpenAI の強力なモデルを Weaviate 内で直接利用できます。 + +その結果、AI 駆動アプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創造に集中できます。 + +## はじめる + +これらの統合を利用するには、有効な Azure OpenAI API キーを Weaviate に提供する必要があります。[Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-foundry/models/openai/) にアクセスして登録し、API キーを取得してください。 + +その後、該当する統合ページで、Azure OpenAI モデルを Weaviate に設定する方法を確認し、アプリケーションで利用を開始しましょう。 + +- [テキスト埋め込み](./embeddings.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/_category_.json new file mode 100644 index 000000000..c82e66afa --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "OpenAI", + "position": 250 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/embeddings.md new file mode 100644 index 000000000..31aedea3f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/embeddings.md @@ -0,0 +1,449 @@ +--- +title: テキスト埋め込み +description: OpenAI 埋め込みモデルプロバイダー +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_openai.jpg +# tags: ['model providers', 'openai', 'embeddings'] +--- + +# Weaviate での OpenAI 埋め込み + +:::info Azure OpenAI 連携ドキュメントをお探しですか? +Azure OpenAI 連携ドキュメントについては、代わりに [こちらのページ](../openai-azure/embeddings.md) をご覧ください。 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +Weaviate の OpenAI API 連携により、Weaviate から直接 OpenAI モデルの機能にアクセスできます。 + +[Weaviate ベクトルインデックスを設定](#configure-the-vectorizer) して OpenAI 埋め込みモデルを使用すると、Weaviate は指定したモデルとお客様の OpenAI API キーを用いて各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) に、Weaviate はテキストオブジェクトの埋め込みを生成し、インデックスに保存します。また、[vector](#vector-near-text-search) 検索や [hybrid](#hybrid-search) 検索を行う際には、Weaviate がテキストクエリを埋め込みへ変換します。 + +![Embedding integration illustration](../_includes/integration_openai_embedding.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスには、OpenAI ベクトライザー連携 (`text2vec-openai`) モジュールが有効化されている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この連携は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかは、[クラスターメタデータ](/deploy/configuration/meta.md) で確認できます。 +- Weaviate でモジュールを有効化するには、[モジュール設定方法](../../configuration/modules.md) ガイドを参照してください。 + +
+ + + +### API 資格情報 + +この連携を使用するには、有効な OpenAI API キーを Weaviate に提供する必要があります。API キーは [OpenAI](https://openai.com/) で取得できます。 + +以下のいずれかの方法で Weaviate に API キーを渡してください。 + +- `OPENAI_APIKEY` 環境変数を設定して Weaviate から参照できるようにする +- 下記の例のように、実行時に API キーを渡す + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 {#configure-the-vectorizer} + +[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) して OpenAI 埋め込みモデルを利用するには、以下のようにします。 + + + + + + + + + + + + + + + + +### モデルの選択 + +以下の設定例に示すように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + +#### `text-embedding-3` モデル ファミリーの場合 + +`text-embedding-3-large` などの `v3` モデルでは、モデル名と必要に応じて次元数(例: `1024`)を指定します。 + + + + + + + + + + + + + + + + +#### 旧モデル ファミリーの場合(例: `ada`) + +`text-embedding-ada-002` などの旧モデルでは、モデル名(`ada`)、タイプ(`text`)、モデル バージョン(`002`)を指定します。 + + + + + + + + + + + + + + + + +Weaviate が使用する [利用可能なモデル](#available-models) のいずれかを[指定](#vectorizer-parameters)できます。モデルを指定しない場合は、[既定のモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +### ベクトライザー パラメーター + +- `model`: OpenAI のモデル名またはファミリーです。 +- `dimensions`: モデルの次元数です。 +- `modelVersion`: モデルのバージョン文字列です。 +- `type`: モデルのタイプで、`text` か `code` のいずれかです。 +- `baseURL`: 既定の OpenAI URL の代わりに使用する URL(例: プロキシ)です。 + +#### (`model` & `dimensions`) または (`model` & `modelVersion`) + +`text-embedding-3-large` のような `v3` モデルでは、モデル名と必要に応じて次元数(例: `1024`)を指定します。 + +`text-embedding-ada-002` のような旧モデルでは、モデル名(`ada`)、タイプ(`text`)およびモデル バージョン(`002`)を指定します。 + +#### 設定例 + +以下の例では、OpenAI 固有のオプションの設定方法を示します。 + + + + + + + + + + + + + + + + +モデル パラメーターの詳細については、[OpenAI API ドキュメント](https://platform.openai.com/docs/api-reference/embeddings) を参照してください。 + +## ヘッダー・パラメーター + +実行時に追加ヘッダーをリクエストに含めることで、API キーやいくつかのオプションパラメーターを指定できます。使用可能なヘッダーは次のとおりです。 + +- `X-OpenAI-Api-Key`: OpenAI API キー +- `X-OpenAI-Baseurl`: 既定の OpenAI URL の代わりに使用するベース URL(例: プロキシ) +- `X-OpenAI-Organization`: OpenAI 組織 ID + +実行時に指定した追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +ヘッダーの指定方法は、上記の [API 資格情報の例](#api-credentials) をご覧ください。 + +## データインポート + +ベクトライザーを設定した後、Weaviate に [データをインポート](../../manage-objects/import.mdx) します。Weaviate は指定されたモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +既に互換性のあるモデルベクトルをお持ちの場合は、それを直接 Weaviate に渡すことができます。たとえば同じモデルで埋め込みを生成済みで、他のシステムからデータを移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、Weaviate は指定された OpenAI モデルを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイラスト](../_includes/integration_openai_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で指定した数 `n` の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を行い、その結果を [結合](../../search/hybrid.md) してデータベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +次のクエリは、`limit` で指定した数 `n` の最もスコアが高いオブジェクトを返します。 + + + + + + + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +`text2vec-openai` では、任意の OpenAI 埋め込みモデルを使用できます。ドキュメント埋め込みには、次の [埋め込みモデルファミリー](https://platform.openai.com/docs/models/embeddings) から選択してください。 + +* `text-embedding-3` + * 利用可能な次元: + * `text-embedding-3-large`: `256`, `1024`, `3072` (デフォルト) + * `text-embedding-3-small`: `512`, `1536` (デフォルト) +* `ada` +* `babbage` +* `davinci` + +
+ 非推奨モデル + +以下のモデルは利用可能ですが、非推奨です: +* Codex +* babbage-001 +* davinci-001 +* curie + +[出典](https://platform.openai.com/docs/deprecations) + +
+ +## 追加リソース + +### 他の統合 + +- [OpenAI 生成モデル + Weaviate](./generative.md) + +### コード例 + +コレクションで統合を設定すると、 Weaviate におけるデータ管理と検索操作は他のコレクションと同様に機能します。モデル非依存の例を以下に示します。 + +- [ハウツー: コレクションを管理](../../manage-collections/index.mdx) および [ハウツー: オブジェクトを管理](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションとその内部のオブジェクトの作成・読み取り・更新・削除)方法を説明しています。 +- [ハウツー: クエリ & 検索](../../search/index.mdx) ガイドでは、検索操作( ベクトル 、キーワード、ハイブリッド)および 検索拡張生成 の実行方法を説明しています。 + +### 外部リソース + +- OpenAI [Embed API ドキュメント](https://platform.openai.com/docs/api-reference/embeddings) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/generative.md new file mode 100644 index 000000000..290c95209 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/generative.md @@ -0,0 +1,339 @@ +--- +title: 生成 AI +description: OpenAI 生成モデルプロバイダー +sidebar_position: 50 +image: og/docs/integrations/provider_integrations_openai.jpg +# tags: ['model providers', 'openai', 'generative', 'rag'] +--- + +# Weaviate と OpenAI 生成 AI + +:::info Azure OpenAI の統合ドキュメントをお探しですか? +Azure OpenAI の統合ドキュメントについては[こちらのページ](../openai-azure/generative.md)をご覧ください。 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate が OpenAI の API と統合されているため、Weaviate から直接これらのモデルの機能にアクセスできます。 + +OpenAI の生成 AI モデルを使用するには、[Weaviate コレクションを設定](#configure-collection)してください。Weaviate は指定したモデルとお客様の OpenAI API キーを用いて検索拡張生成 (RAG) を実行します。 + +具体的には、Weaviate が検索を実行し、最も関連性の高いオブジェクトを取得した後、それらを OpenAI の生成モデルに渡して出力を生成します。 + +![検索拡張生成 (RAG) 統合のイメージ](../_includes/integration_openai_rag.png) + +## 要件 + +### Weaviate の設定 + +お使いの Weaviate インスタンスは、OpenAI 生成 AI 統合 (`generative-openai`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かを確認するには、[クラスタメタデータ](/deploy/configuration/meta.md)をチェックしてください。 +- モジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md)ガイドに従ってください。 + +
+ + + +### API 資格情報 + +この統合を利用するには、有効な OpenAI API キーを Weaviate に提供する必要があります。[OpenAI](https://openai.com/) でサインアップし、API キーを取得してください。 + +次のいずれかの方法で API キーを Weaviate に渡します。 + +- Weaviate が参照できる `OPENAI_APIKEY` 環境変数を設定する +- 以下の例のように、実行時に API キーを渡す + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +OpenAI 生成 AI モデルを使用するには、次のように[Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration)します。 + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、Weaviate で使用する[利用可能なモデル](#available-models)のいずれかを指定できます。 + + + + + + + + + + + + +[利用可能なモデル](#available-models)のいずれかを[指定](#generative-parameters)することができます。モデルを指定しない場合は[デフォルトモデル](#available-models)が使用されます。 + +### 生成パラメーター + +モデルの挙動をカスタマイズするために、以下の生成パラメーターを設定します。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[OpenAI API ドキュメント](https://platform.openai.com/docs/api-reference/chat) をご覧ください。 + +## 実行時のモデル選択 + +コレクション作成時にデフォルトのモデルプロバイダーを設定する以外に、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## ヘッダーパラメーター + +リクエストの追加ヘッダーを介して、実行時に API キーおよびいくつかのオプションパラメーターを渡すことができます。利用可能なヘッダーは次のとおりです。 + +- `X-OpenAI-Api-Key`: OpenAI の API キー。 +- `X-OpenAI-Baseurl`: デフォルトの OpenAI URL の代わりに使用するベース URL (たとえばプロキシ)。 +- `X-OpenAI-Organization`: OpenAI の組織 ID。 + +実行時に指定された追加ヘッダーは、既存の Weaviate 設定を上書きします。 + +上記の [API 資格情報の例](#api-credentials) に示すようにヘッダーを渡してください。 + +## 検索拡張生成 + +生成 AI 統合を設定した後、[シングル プロンプト](#single-prompt) または [グループ タスク](#grouped-task) の方法で RAG 操作を実行します。 + +### シングル プロンプト + +![シングル プロンプト RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_openai_rag_single.png) + +検索結果に含まれる各オブジェクトに対してテキストを生成する場合は、シングル プロンプト方式を使用します。 + +以下の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれについて出力を生成します。 + +シングル プロンプト クエリを作成する際は、波かっこ `{}` を使用して、Weaviate から言語モデルへ渡したいオブジェクトプロパティを差し込みます。たとえばオブジェクトの `title` プロパティを渡したい場合、クエリ内に `{title}` を含めてください。 + + + + + + + + + + + + + +### グループ タスク + +![グループ タスク RAG 統合は検索結果の集合に対して 1 つの出力を生成します](../_includes/integration_openai_rag_grouped.png) + +検索結果全体に対して 1 つのテキストを生成する場合は、グループ タスク方式を使用します。 + +言い換えれば、`n` 件の検索結果がある場合でも、生成モデルはそのグループ全体に対して 1 つの出力を生成します。 + + + + + + + + + + + + + + +### 画像を用いた RAG + +単一プロンプトでもグループタスクでも、検索拡張生成を行う際に入力の一部として画像を渡すことができます。 + + + + + + + + + + + +## 参考 + +### 利用可能なモデル + +* [gpt-3.5-turbo](https://platform.openai.com/docs/models/gpt-3-5) (デフォルト) +* [gpt-3.5-turbo-16k](https://platform.openai.com/docs/models/gpt-3-5) +* [gpt-3.5-turbo-1106](https://platform.openai.com/docs/models/gpt-3-5) +* [gpt-4](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) +* [gpt-4-1106-preview](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) +* [gpt-4-32k](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) +* [gpt-4o](https://platform.openai.com/docs/models#gpt-4o) +* [gpt-4o-mini](https://platform.openai.com/docs/models#gpt-4o-mini) (v1.26.7 で追加) + +
+ 旧モデル + +以下のモデルも利用可能ですが、推奨されません。 + +* [davinci 002](https://platform.openai.com/docs/models/overview) +* [davinci 003](https://platform.openai.com/docs/models/overview) + +
+ +## 追加リソース + +### その他の統合 + +- [OpenAI 埋め込みモデル + Weaviate](./embeddings.md) + +### コード例 + +コレクションでインテグレーションを設定すると、Weaviate におけるデータ管理および検索操作は他のコレクションと同様に機能します。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) では、データ操作(コレクションやその内部のオブジェクトの作成・読み取り・更新・削除)の方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) では、 ベクトル・キーワード・ハイブリッド検索のほか、検索拡張生成の方法を説明しています。 + +### 参考 + +- OpenAI [Chat API ドキュメント](https://platform.openai.com/docs/api-reference/chat) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/index.md new file mode 100644 index 000000000..a45f6d6b1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/openai/index.md @@ -0,0 +1,61 @@ +--- +title: OpenAI と Weaviate +description: "OpenAI は、自然言語処理と生成のために幅広いモデルを提供しています。Weaviate は OpenAI の API とシームレスに統合され、ユーザーは Weaviate Database から直接 OpenAI のモデルを活用できます。" +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_openai.jpg +# tags: ['model providers', 'openai'] +--- + + + +:::info Azure OpenAI 統合ドキュメントをお探しですか? +Azure OpenAI の統合ドキュメントについては、代わりに [こちらのページ](../openai-azure/index.md) をご覧ください。 +::: + +OpenAI は、自然言語処理と生成のために幅広いモデルを提供しています。Weaviate は OpenAI の API とシームレスに統合されており、ユーザーは Weaviate Database から直接 OpenAI のモデルを活用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## OpenAI との統合 + +### ベクトル検索用 Embedding モデル + +![Embedding 統合のイラスト](../_includes/integration_openai_embedding.png) + +OpenAI の embedding モデルは、テキストデータを意味とコンテキストを捉えたベクトル埋め込みへ変換します。 + +[Weaviate は OpenAI の embedding モデルと統合](./embeddings.md) しており、データのシームレスなベクトライゼーションを実現します。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[OpenAI embedding 統合ページ](./embeddings.md) + +### RAG 用生成 AI モデル + +![単一プロンプト RAG 統合では検索結果ごとに個別の出力を生成](../_includes/integration_openai_rag_single.png) + +OpenAI の生成 AI モデルは、与えられたプロンプトとコンテキストに基づき、人間らしいテキストを生成します。 + +[Weaviate の生成 AI 統合](./generative.md) を利用すると、Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。これにより、Weaviate の効率的なストレージと高速検索機能に OpenAI の生成 AI モデルを組み合わせ、パーソナライズされたコンテキスト重視の応答を生成できます。 + +[OpenAI 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は Weaviate 内で直接 OpenAI の強力なモデルを活用できます。 + +その結果、AI 駆動アプリケーションの構築プロセスが簡素化され、開発スピードが向上し、革新的なソリューションの創出に専念できます。 + +## 開始方法 + +これらの統合を利用するには、有効な OpenAI API キーを Weaviate に提供する必要があります。OpenAI に [サインアップ](https://openai.com/) して API キーを取得してください。 + +その後、該当する統合ページに移動し、OpenAI モデルを Weaviate に設定してアプリケーションで利用する方法を学びましょう。 + +- [テキスト Embeddings](./embeddings.md) +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/_category_.json new file mode 100644 index 000000000..128f129b1 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Hugging Face (locally hosted)", + "position": 350 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-custom-image.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-custom-image.md new file mode 100644 index 000000000..d25ba8b03 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-custom-image.md @@ -0,0 +1,156 @@ +--- +title: テキスト埋め込み(カスタム) +description: Transformers カスタムイメージ埋め込み +sidebar_position: 25 +image: og/docs/integrations/provider_integrations_transformers.jpg +# tags: ['model providers', 'huggingface', 'embeddings', 'transformers'] +--- + +# ローカルホスト Transformers 埋め込み + Weaviate(カスタムイメージ) + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate と Hugging Face Transformers ライブラリの統合により、Transformers のモデル機能を Weaviate から直接利用できます。 + +Weaviate ベクトルインデックスを Transformers 統合で構成し、[Weaviate インスタンスを設定](#configure-the-weaviate-instance)してモデルイメージを指定すると、Weaviate は Transformers 推論コンテナ内の指定モデルを使用して各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +本ページでは、[カスタム Transformers モデルイメージを作成](#build-a-custom-transformers-model-image)し、それを Weaviate で利用する方法を紹介します。これは、ご希望のモデルが[事前構築済みイメージ](./embeddings.md#available-models)に含まれていない場合に役立ちます。 + +カスタムイメージを構築して設定すれば、利用方法は事前構築済みイメージと同一です。 + +## カスタム Transformers モデルイメージの作成 + +Weaviate で使用するカスタム Transformers モデルイメージを作成できます。これは Hugging Face モデル Hub の公開モデルでも、プライベートまたはローカルの互換モデルでも構いません。 + +[Hugging Face モデル Hub](https://huggingface.co/models) にある埋め込み(feature extraction)モデルは、カスタム Docker イメージを構築することで Weaviate で使用できます。 + +カスタムイメージを作成する手順は次のとおりです。 + +- [`Dockerfile` を作成](#create-a-dockerfile)してモデルをダウンロードします。 +- [`Dockerfile` をビルドしてタグ付け](#build-and-tag-the-dockerfile)します。 +- [イメージを Weaviate インスタンスで使用](#use-the-image)します。 + +#### `Dockerfile` の作成 + +作成する `Dockerfile` は、Hugging Face モデル Hub の公開モデルを使うか、プライベートまたはローカルモデルを使うかで異なります。 + + + + +以下の例では [`distilroberta-base` モデル](https://huggingface.co/distilbert/distilroberta-base) 用のカスタムイメージを作成します。`distilroberta-base` を使用したいモデル名に置き換えてください。 +
+ +Hugging Face Hub のモデルでイメージを構築するには、次のような `Dockerfile` を新規作成します。 +
+ +`Dockerfile` を `my-inference-image.Dockerfile` という名前(任意)で保存します。 +
+ +```yaml +FROM semitechnologies/transformers-inference:custom +RUN MODEL_NAME=distilroberta-base ./download.py +``` + +
+ + +Transformers ライブラリの `AutoModel` と `AutoTokenizer` クラスに対応する任意のモデルでもカスタムイメージを作成できます。 +
+ +ローカルのカスタムモデルでイメージを構築するには、次のような `Dockerfile` を新規作成し、`./my-model` をモデルフォルダーのパスに置き換えます。 +
+ +`Dockerfile` を `my-inference-image.Dockerfile` という名前(任意)で保存します。 +
+ +これは、ローカルフォルダー `my-model` に保存されているモデル用のカスタムイメージを作成します。 +
+ +```yaml +FROM semitechnologies/transformers-inference:custom +COPY ./my-model /app/models/model +``` +
+ +アプリケーションがモデルを探すパスは `/app/models/model` ですので、変更しないでください。 + +
+
+ +#### `Dockerfile` のビルドとタグ付け + +たとえば `my-inference-image` という名前で `Dockerfile` にタグを付けます: + +```shell +docker build -f my-inference-image.Dockerfile -t my-inference-image . +``` + +#### (オプション)イメージをレジストリへプッシュ + +別の環境でイメージを使用する場合は、Docker レジストリへプッシュできます: + +```shell +docker push my-inference-image +``` + +#### イメージの使用 + +`docker-compose.yml` などの [Weaviate 設定](./embeddings.md#weaviate-configuration)で、ローカルの Docker タグ(例: `my-inference-image`)またはレジストリのイメージ名を `image` パラメーターに指定します。 + +#### (オプション)`sentence-transformers` ベクトライザーの使用 + +:::caution 実験的機能 +This is an experimental feature. Use with caution. +::: + +カスタムイメージを使用する際、環境変数 `USE_SENTENCE_TRANSFORMERS_VECTORIZER` を設定すると、デフォルトの `transformers` ライブラリではなく [`sentence-transformers` ベクトライザー](https://sbert.net/)を利用できます。 + +## Weaviate インスタンスの設定 + +カスタム Transformers モデルイメージを構築・設定したら、[Transformers 埋め込み統合](./embeddings.md)ガイドに従って Weaviate でモデルを使用してください。 + +上記の例では、`text2vec-transformers` サービスの `image` パラメーターにカスタムイメージ名(例: `my-inference-image`)を設定します。 + +## (オプション)推論コンテナのテスト + +推論コンテナが設定されて稼働したら、直接クエリを送信して機能をテストできます。 + +まず、推論コンテナを公開します。Docker でデプロイしている場合は、`docker-compose.yml` の `text2vec-transformers` サービスに次を追加してポートをフォワードします: + +```yaml +services: + weaviate: + # Additional settings not shown + text2vec-transformers: + # Additional settings not shown + ports: + - "9090:8080" # Add this line to expose the container +``` + +コンテナが稼働して公開されたら、次のように REST リクエストを直接送信できます: + +```shell +curl localhost:9090/vectors -H 'Content-Type: application/json' -d '{"text": "foo bar"}' +``` + +コンテナが正しく稼働・設定されていれば、入力テキストのベクトル埋め込みを含むレスポンスが返されます。 + + + +### 外部リソース + +- Hugging Face [Model Hub](https://huggingface.co/models) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-multimodal-custom-image.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-multimodal-custom-image.md new file mode 100644 index 000000000..59d762bf5 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-multimodal-custom-image.md @@ -0,0 +1,150 @@ +--- +title: マルチモーダル埋め込み(カスタム) +description: Transformers カスタムイメージ マルチモーダル埋め込み +sidebar_position: 35 +image: og/docs/integrations/provider_integrations_transformers.jpg +# tags: ['model providers', 'huggingface', 'embeddings', 'clip'] +--- + +# ローカルホスト CLIP 埋め込み + Weaviate(カスタム画像) + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate の Hugging Face Transformers ライブラリとの統合により、CLIP モデルの機能を Weaviate から直接利用できます。 + +Weaviate の ベクトル インデックスを CLIP 連携で構成し、[Weaviate インスタンスを設定](#configure-the-weaviate-instance) してモデルイメージを指定すると、CLIP 推論コンテナ内の指定モデルを用いて各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +このページでは、[カスタム CLIP モデル イメージを作成](#build-a-custom-clip-model-image) し、それを Weaviate で利用する方法を説明します。これは、使用したいモデルが[事前構築イメージ](./embeddings-multimodal.md#available-models)に含まれていない場合に役立ちます。 + +カスタムイメージを作成して設定すると、利用方法は事前構築イメージと同一です。 + +## カスタム CLIP モデル イメージの作成 + +Weaviate で使用するためのカスタム CLIP モデル イメージを作成できます。これは Hugging Face Model Hub の公開モデルでも、互換性のある非公開またはローカルモデルでもかまいません。 + +[Hugging Face Model Hub](https://huggingface.co/models) にある **公開 SBERT CLIP** モデルは、カスタム Docker イメージを作成することで Weaviate で利用できます。 + +カスタムイメージを作成する手順は次のとおりです。 + +- [モデルをダウンロードする `Dockerfile` を作成](#create-a-dockerfile) +- [Dockerfile をビルドしてタグ付け](#build-and-tag-the-dockerfile) +- [イメージを Weaviate インスタンスで利用](#use-the-image) + +#### `Dockerfile` の作成 + +作成する `Dockerfile` は、Hugging Face Model Hub からの公開モデルを使用するか、非公開またはローカルモデルを使用するかによって異なります。 + + + + +以下の例では、[`clip-ViT-B-32` モデル](https://huggingface.co/sentence-transformers/clip-ViT-B-32) 用のカスタムイメージを作成します。使用したいモデル名に `clip-ViT-B-32` を置き換えてください。 +
+ +Hugging Face Hub のモデルでイメージをビルドするには、次のような新しい `Dockerfile` を作成します。 +
+ +`Dockerfile` を `my-inference-image.Dockerfile` として保存します。(任意の名前でかまいません。) +
+ +```yaml +FROM semitechnologies/multi2vec-clip:custom +RUN CLIP_MODEL_NAME=clip-ViT-B-32 TEXT_MODEL_NAME=clip-ViT-B-32 ./download.py +``` + +
+ + +Transformers ライブラリの `SentenceTransformers` と `ClIPModel` クラスに互換性のあるモデルであれば、どのモデルでもカスタムイメージを作成できます。テキスト埋め込みと画像埋め込みで互換性のある ベクトル を出力するために、必ず CLIP 用に特別に学習されたモデルのみを使用してください。(CLIP モデルは実際にはテキスト用と画像用の 2 つのモデルで構成されています。) +
+ +ローカルのカスタムモデルでイメージを作成するには、次のような新しい `Dockerfile` を作成し、`./my-test-model` と `./my-clip-model` をモデルフォルダーへのパスに置き換えてください。 +
+ +`Dockerfile` を `my-inference-image.Dockerfile` として保存します。(任意の名前でかまいません。) +
+ +この例では、ローカルマシンのフォルダー `my-model` に保存されたモデル用のカスタムイメージを作成します。 +
+ +```yaml +FROM semitechnologies/multi2vec-clip:custom +COPY ./my-text-model /app/models/text +COPY ./my-clip-model /app/models/clip +``` +
+ +アプリケーションはモデルファイルを `/app/models/text` と `/app/models/clip` に配置されていることを前提としていますので、これらのパスは変更しないでください。 + +
+
+ +#### Dockerfile のビルドとタグ付け + +Dockerfile を例えば `my-inference-image` という名前でタグ付けします: + +```shell +docker build -f my-inference-image.Dockerfile -t my-inference-image . +``` + +#### (任意)イメージをレジストリへプッシュ + +別の環境でこのイメージを使用したい場合は、Docker レジストリへプッシュできます: + +```shell +docker push my-inference-image +``` + +#### イメージの利用 + +`docker-compose.yml` などの [Weaviate 設定](./embeddings.md#weaviate-configuration) で、ローカル Docker タグ(例: `my-inference-image`)またはレジストリのイメージを `image` パラメーターに指定してください。 + +## Weaviate インスタンスの設定 + +カスタム Transformers モデルイメージを作成して設定したら、[CLIP 埋め込み連携](./embeddings-multimodal.md) ガイドに従って Weaviate でモデルを使用します。 + +上記の例では、`multi2vec-clip` サービスの `image` パラメーターにカスタムイメージ名(例: `my-inference-image`)を設定します。 + +## (任意)推論コンテナのテスト + +推論コンテナを設定して起動したら、その機能を直接テストするためにクエリを送信できます。 + +まず、推論コンテナを公開します。Docker でデプロイしている場合、`docker-compose.yml` の `multi2vec-clip` サービスに次を追加してポートをフォワードします: + +```yaml +services: + weaviate: + # Additional settings not shown + multi2vec-clip: + # Additional settings not shown + ports: + - "9090:8080" # Add this line to expose the container +``` + +コンテナが起動して公開されたら、次のように REST リクエストを直接送信できます: + +```shell +curl localhost:9090/vectors -H 'Content-Type: application/json' -d '{"text": "foo bar"}' +``` + +コンテナが正しく稼働・設定されていれば、入力テキストの ベクトル 埋め込みがレスポンスとして返ってきます。 + +### 参考リソース + +- Hugging Face [Model Hub](https://huggingface.co/models) + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-multimodal.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-multimodal.md new file mode 100644 index 000000000..a0745044b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings-multimodal.md @@ -0,0 +1,396 @@ +--- +title: マルチモーダル (CLIP) 埋め込み +description: Transformers マルチモーダル埋め込み +sidebar_position: 30 +image: og/docs/integrations/provider_integrations_transformers.jpg +# tags: ['model providers', 'transformers', 'embeddings'] +--- + +# ローカルホスト CLIP 埋め込み + Weaviate + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.local.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.local.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate と Hugging Face Transformers ライブラリの連携により、CLIP モデルの機能を Weaviate から直接利用できます。 + +[Weaviate ベクトルインデックスを設定](#configure-the-vectorizer)し、[Weaviate インスタンスを設定](#weaviate-configuration)してモデルイメージを指定すると、CLIP 推論コンテナ内の指定モデルを用いて各種操作の埋め込みを生成します。この機能は *vectorizer* と呼ばれます。 + +[インポート時](#data-import) に Weaviate はマルチモーダルオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、1 つ以上のモダリティを含むクエリを埋め込みに変換します。[マルチモーダル検索操作](#vector-near-media-search) にも対応しています。 + +![Embedding integration illustration](../_includes/integration_transformers_embedding.png) + +## 要件 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスは、CLIP マルチモーダル ベクトライザー統合 (`multi2vec-clip`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は Hugging Face モデルを含むコンテナを起動する必要があるため、Weaviate Cloud (WCD) のサーバーレスインスタンスでは利用できません。 + +
+ +#### 統合モジュールを有効化する + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効になっているか確認します。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +#### 統合を設定する + +本統合を使用するには、CLIP モデルのコンテナイメージと、そのコンテナ化モデルの推論エンドポイントを設定します。 + +以下の例は、Weaviate で CLIP 統合を設定する方法を示しています。 + + + + +#### Docker オプション 1: 事前構成済み `docker-compose.yml` ファイルを使用 + +[Weaviate Docker インストールコンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator) の手順に従い、選択したモデルを含む事前構成済み `docker-compose.yml` ファイルをダウンロードしてください。 +
+ +#### Docker オプション 2: 手動で設定を追加 + +または、以下の例のように `docker-compose.yml` ファイルへ手動で設定を追加します。 + +```yaml +services: + weaviate: + # Other Weaviate configuration + environment: + CLIP_INFERENCE_API: http://multi2vec-clip:8080 # Set the inference API endpoint + multi2vec-clip: # Set the name of the inference container + image: cr.weaviate.io/semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1 + environment: + ENABLE_CUDA: 0 # Set to 1 to enable +``` + +- `CLIP_INFERENCE_API` 環境変数は推論 API エンドポイントを指定します +- `multi2vec-clip` は推論コンテナの名前です +- `image` はコンテナイメージです +- `ENABLE_CUDA` 環境変数で GPU 使用を有効化します + +使用するモデルを指定するには、`image` に [利用可能なモデル一覧](#available-models) の中からイメージを設定してください。 + +
+ + +Weaviate Helm チャートの values ファイルの `modules` セクションに `multi2vec-clip` モジュールを追加または更新して、Hugging Face Transformers 連携を設定します。たとえば、`values.yaml` ファイルを次のように変更します。 + +```yaml +modules: + + multi2vec-clip: + + enabled: true + tag: sentence-transformers-clip-ViT-B-32-multilingual-v1 + repo: semitechnologies/multi2vec-clip + registry: cr.weaviate.io + envconfig: + enable_cuda: true +``` + +より多くの設定オプションを含む `values.yaml` ファイルの例は、[Weaviate Helm チャート](https://github.com/weaviate/weaviate-helm/blob/master/weaviate/values.yaml) を参照してください。 + +使用するモデルを指定するには、`tag` に [利用可能なモデル一覧](#available-models) の中からタグを設定してください。 + + +
+ +### 認証情報 + +本統合は CLIP モデルを含むローカルコンテナを実行するため、追加の認証情報 (例: API キー) は不要です。以下の例のように通常どおり Weaviate へ接続してください。 + + + + + + + + + + + + + +## ベクトライザーの設定 + +CLIP 埋め込みモデルを使用するには、次のように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します。 + + + + + + + + + + + + +:::note コンテナイメージを選択してモデルを指定 +モデルを選択するには、それをホストする [コンテナイメージ](#configure-the-integration) を指定してください。 +::: + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ + + +### ベクトライザーのパラメーター + +#### 推論 URL パラメーター + +オプションとして、スタックに複数の推論コンテナが含まれている場合は、コレクションで使用する推論コンテナを指定できます。 + +パラメーターを指定しない場合、 Weaviate の設定で定義されたデフォルトの推論 URL が使用されます。 + +単一の推論コンテナを指定する場合は、 `inferenceUrl` を設定してください。 + + + + + + + + + + + +## データインポート + +ベクトライザーを設定したら、 Weaviate に [データをインポート](../../manage-objects/import.mdx) します。 Weaviate は指定されたモデルを使用してオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存のベクトルを再利用する +すでに互換性のあるモデルベクトルをお持ちの場合は、それを直接 Weaviate に渡すことができます。同じモデルで既に埋め込みを生成しており、データを他のシステムから移行する際などに便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、 Weaviate は指定した CLIP モデルを使ってベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイラスト](../_includes/integration_transformers_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、 Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、 `limit` で設定した数 `n` の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索はベクトル検索とキーワード(BM25)検索を行い、その結果を [組み合わせて](../../search/hybrid.md) データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、 Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +以下のクエリは、 `limit` で設定した数 `n` の最もスコアの高いオブジェクトを返します。 + + + + + + + + + + + + + +### ベクトル(near media)検索 + +[近傍画像検索](../../search/similarity.md#search-with-image) のようなメディア検索を実行すると、Weaviate は指定されたモデルを用いてクエリを埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +near image 検索などの near media 検索を行う場合は、メディアクエリを base64 文字列に変換し、検索クエリに渡してください。 + +次のクエリは、入力画像に最も類似したオブジェクトを `limit` で指定した数( n )だけ返します。 + + + + + + + + + + + + + +## 参考 + +### 利用可能なモデル + +このインテグレーション用にビルド済み Docker イメージの一覧を以下に示します。 + +| モデル名 | イメージ名 | 備考 | +| --- | --- | --- | +| google/siglip2-so400m-patch16-512 | `cr.weaviate.io/semitechnologies/multi2vec-clip:google-siglip2-so400m-patch16-512` | 512×512 入力サイズの SigLIP 2 モデル。`multi2vec-clip` `v1.4.0` で追加。(多言語、1152d) | +| google/siglip2-so400m-patch16-384 | `cr.weaviate.io/semitechnologies/multi2vec-clip:google-siglip2-so400m-patch16-384` | 384×384 入力サイズの SigLIP 2 モデル。`multi2vec-clip` `v1.4.0` で追加。(多言語、1152d) | +| sentence-transformers-clip-ViT-B-32 | `cr.weaviate.io/semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32` | テキストは英語である必要があります。(英語、768d) | +| sentence-transformers-clip-ViT-B-32-multilingual-v1 | `cr.weaviate.io/semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1` | テキストに多数の言語をサポート。詳細は sbert.net を参照。(多言語、768d) | +| openai-clip-vit-base-patch16 | `cr.weaviate.io/semitechnologies/multi2vec-clip:openai-clip-vit-base-patch16` | 画像エンコーダとして ViT-B/16 Transformer、テキストエンコーダとしてマスクド Self-Attention Transformer を使用するベースモデル。 | +| ViT-B-16-laion2b_s34b_b88k | `cr.weaviate.io/semitechnologies/multi2vec-clip:ViT-B-16-laion2b_s34b_b88k` | LAION-2B データセットで学習された ViT-B/16 Transformer 画像エンコーダを採用。OpenCLIP 使用。 | +| ViT-B-32-quickgelu-laion400m_e32 | `cr.weaviate.io/semitechnologies/multi2vec-clip:ViT-B-32-quickgelu-laion400m_e32` | LAION-400M データセットで学習された ViT-B/32 Transformer 画像エンコーダを採用。OpenCLIP 使用。 | +| xlm-roberta-base-ViT-B-32-laion5b_s13b_b90k | `cr.weaviate.io/semitechnologies/multi2vec-clip:xlm-roberta-base-ViT-B-32-laion5b_s13b_b90k` | LAION-5B データセットで学習された ViT-B/32 xlm-roberta ベースモデルを採用。OpenCLIP 使用。 | + +新しいモデルは随時追加されます。最新のモデル一覧は、[multi2vec-clip](https://hub.docker.com/r/semitechnologies/multi2vec-clip/tags) コンテナの Docker Hub タグをご覧ください。 + +## 高度な設定 + +### 推論コンテナを個別に実行する + +代替手段として、推論コンテナを Weaviate とは別に実行できます。以下の手順に従ってください。 + +- `multi2vec-clip` を有効にし、[Weaviate の設定](#weaviate-configuration) では `multi2vec-clip` コンテナのパラメータを省略します +- 推論コンテナを(Docker などで)別途起動します +- `CLIP_INFERENCE_API` または [`inferenceUrl`](#configure-the-vectorizer) で推論コンテナの URL を指定します + +例として、Docker でコンテナを起動します。 + +```shell +docker run -itp "8000:8080" semitechnologies/multi2vec-clip:sentence-transformers-clip-ViT-B-32-multilingual-v1 +``` + +その後、`CLIP_INFERENCE_API="http://localhost:8000"` を設定します。Weaviate が同じ `docker-compose.yml` 内の同一 Docker ネットワークに属している場合は、`CLIP_INFERENCE_API=http://multi2vec-clip:8080` のように Docker のネットワーク/DNS 名を使用できます。 + +## さらに詳しく + +### 他のインテグレーション + +- [Transformers テキスト埋め込みモデル + Weaviate](./embeddings.md) +- [Transformers reranker モデル + Weaviate](./reranker.md) + +### コード例 + +インテグレーションをコレクションに設定すると、Weaviate のデータ管理および検索操作は他のコレクションと同様に機能します。モデル非依存の例を以下に示します。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) および [How-to: Manage objects](../../manage-objects/index.mdx) ガイドでは、データ操作(コレクションおよびその内部オブジェクトの作成・取得・更新・削除)方法を説明しています。 +- [How-to: Query & Search](../../search/index.mdx) ガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索、検索拡張生成の実行方法を説明しています。 + +### モデルライセンス + +各対応モデルには独自のライセンスがあります。詳細は、使用するモデルの [Hugging Face Model Hub](https://huggingface.co/models) ページでライセンスを確認してください。 + +各ライセンスの条件がご自身の利用目的に適しているかどうかを判断する責任は、利用者にあります。 + +### 外部リソース + +- Hugging Face [Model Hub](https://huggingface.co/models) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings.md new file mode 100644 index 000000000..73337eefb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/embeddings.md @@ -0,0 +1,481 @@ +--- +title: テキスト埋め込み +description: "Weaviate が Hugging Face Transformers ライブラリと統合することで、モデルの機能を Weaviate から直接利用できます。" +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_transformers.jpg +# tags: ['model providers', 'huggingface', 'embeddings', 'transformers'] +--- + +# ローカルホスト Transformers テキスト埋め込み + Weaviate + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.local.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.local.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +Weaviate の Hugging Face Transformers ライブラリとの統合により、Weaviate からモデルの機能に直接アクセスできます。 + +[Weaviate ベクトル インデックスを構成する](#configure-the-vectorizer) で Transformers 統合を使用し、[Weaviate インスタンスを構成する](#weaviate-configuration) 際にモデル イメージを指定すると、Weaviate は Transformers 推論コンテナ内の指定モデルを用いて各種操作の埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) には、Weaviate がテキスト オブジェクトの埋め込みを生成してインデックスに保存します。また、[ベクトル](#vector-near-text-search) や [ハイブリッド](#hybrid-search) 検索では、Weaviate がテキスト クエリを埋め込みに変換します。 + +![Embedding integration illustration](../_includes/integration_transformers_embedding.png) + +## 要件 + +### Weaviate 構成 + +ご利用の Weaviate インスタンスには、Hugging Face Transformers ベクトライザー統合 (`text2vec-transformers`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) 利用者向け + +この統合は Hugging Face モデル用のコンテナを起動する必要があるため、Weaviate Cloud (WCD) のサーバーレス インスタンスでは利用できません。 + +
+ +#### 統合モジュールの有効化 + +- [クラスタ メタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効になっているかどうかを確認します。 +- [モジュールの設定方法](../../configuration/modules.md) ガイドに従い、Weaviate でモジュールを有効化します。 + +#### 統合の構成 + +この統合を使用するには、Hugging Face Transformers モデルのコンテナ イメージと、コンテナ化されたモデルの推論エンドポイントを構成します。 + +以下は、Weaviate で Hugging Face Transformers 統合を構成する例です。 + + + + +#### Docker オプション 1: 事前構成済み `docker-compose.yml` を使用 + +[Weaviate Docker インストール コンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator) の手順に従い、選択したモデル入りの事前構成済み `docker-compose.yml` ファイルをダウンロードしてください。 +
+ +#### Docker オプション 2: 手動で設定を追加 + +または、下記の例のように `docker-compose.yml` ファイルへ手動で設定を追加します。 + +```yaml +services: + weaviate: + # Other Weaviate configuration + environment: + ENABLE_MODULES: text2vec-transformers # Enable this module + TRANSFORMERS_INFERENCE_API: http://text2vec-transformers:8080 # Set the inference API endpoint + text2vec-transformers: # Set the name of the inference container + image: cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-multi-qa-MiniLM-L6-cos-v1 + environment: + ENABLE_CUDA: 0 # Set to 1 to enable +``` + +- `TRANSFORMERS_INFERENCE_API` 環境変数は推論 API エンドポイントを指定します +- `text2vec-transformers` は推論コンテナの名前です +- `image` はコンテナ イメージです +- `ENABLE_CUDA` 環境変数で GPU 使用を有効化します + +使用するモデルを指定するには、`image` を [利用可能なモデル一覧](#available-models) から選択してください。 + +
+ + +Weaviate Helm チャートの `values.yaml` ファイル内 `modules` セクションに `text2vec-transformers` モジュールを追加または更新して、Hugging Face Transformers 統合を構成します。例として、`values.yaml` を以下のように修正します。 + +```yaml +modules: + + text2vec-transformers: + + enabled: true + tag: sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2 + repo: semitechnologies/transformers-inference + registry: cr.weaviate.io + envconfig: + enable_cuda: true +``` + +[DPR](https://huggingface.co/docs/transformers/en/model_doc/dpr) モデルをご利用の場合は、`passageQueryServices` 以下のパラメーターも設定してください。 + +より多くの設定オプションを含む `values.yaml` の例については、[Weaviate Helm チャート](https://github.com/weaviate/weaviate-helm/blob/master/weaviate/values.yaml) を参照してください。 + +使用するモデルを指定するには、`tag` を [利用可能なモデル一覧](#available-models) から選択してください。 + + +
+ +### 資格情報 + +この統合はローカル コンテナで Transformers モデルを実行するため、追加の資格情報 (API キーなど) は不要です。以下の例のように通常どおり Weaviate に接続してください。 + + + + + + + + + + + + + +## ベクトライザーの構成 + +[Weaviate インデックスを構成](../../manage-collections/vector-config.mdx#specify-a-vectorizer) して、Transformer 推論コンテナを使用するには次のようにします。 + + + + + + + + + + + + +:::note コンテナ イメージを選択してモデルを指定 +モデルを選択するには、それをホストする [コンテナ イメージ](#configure-the-integration) を選択してください。 +::: + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化動作 + + + +
+ + + +### ベクトライザーのパラメーター + +以下の例では、Transformers 固有のオプションを設定する方法を示します。 + +#### 推論 URL のパラメーター + +スタックに複数の推論コンテナが含まれている場合、使用する推論コンテナをコレクションごとに指定できます。 + +パラメーターを指定しない場合は、Weaviate 構成で設定されたデフォルトの推論 URL が使用されます。 + +単一の推論コンテナを指定するには `inferenceUrl` を使用します。 + +[DPR](https://huggingface.co/docs/transformers/en/model_doc/dpr) モデルを使用している場合は、`passageInferenceUrl` と `queryInferenceUrl` を指定します。 + +#### 追加パラメーター + +- `poolingStrategy` – 入力がモデルのコンテキストウィンドウを超えた場合に使用するプーリング戦略。 + - デフォルト: `masked_mean`。許可される値: `masked_mean` または `cls`。([詳細はこちら](https://arxiv.org/abs/1908.10084)) + + + + + + + + + + + + +## データインポート + +ベクトライザーを設定したら、Weaviate に[データをインポート](../../manage-objects/import.mdx)します。Weaviate は指定されたモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +既に互換性のあるモデルベクトルをお持ちの場合、それを直接 Weaviate に渡すことができます。これは、同じモデルを使って既に埋め込みを生成しており、それらを Weaviate で利用したい場合、たとえば他のシステムからデータを移行するときに便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、Weaviate は Transformers 推論コンテナを使用してベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合の図](../_includes/integration_transformers_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で設定した数 `n` 件の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を実行し、その後[結果を組み合わせて](../../search/hybrid.md)データベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、Weaviate はテキストクエリを指定モデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +次のクエリは、`limit` で設定した数 `n` 件の最もスコアの高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + +## 参照 + +### 利用可能なモデル + +このインテグレーション用に事前構築された Docker イメージの一覧は、以下のタブに掲載されています。 GPU が利用できない場合は、 CPU 推論用に ONNX 対応イメージのご使用を推奨します。 + +[独自の Docker イメージをビルドすることもできます](./embeddings-custom-image.md) + + + + +:::info +これらのモデルは GPU アクセラレーションの恩恵を受けます。 利用可能な環境では、[ Docker もしくは Kubernetes の設定](#weaviate-configuration)で CUDA アクセラレーションを有効にしてください。 +::: + +
+ 全リストを表示 + +|モデル名|イメージ名| +|---|---| +|`distilbert-base-uncased` ([Info](https://huggingface.co/distilbert-base-uncased))|`cr.weaviate.io/semitechnologies/transformers-inference:distilbert-base-uncased`| +|`sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2` ([Info](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-paraphrase-multilingual-MiniLM-L12-v2`| +|`sentence-transformers/multi-qa-MiniLM-L6-cos-v1` ([Info](https://huggingface.co/sentence-transformers/multi-qa-MiniLM-L6-cos-v1))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-multi-qa-MiniLM-L6-cos-v1`| +|`sentence-transformers/multi-qa-mpnet-base-cos-v1` ([Info](https://huggingface.co/sentence-transformers/multi-qa-mpnet-base-cos-v1))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-multi-qa-mpnet-base-cos-v1`| +|`sentence-transformers/all-mpnet-base-v2` ([Info](https://huggingface.co/sentence-transformers/all-mpnet-base-v2))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-all-mpnet-base-v2`| +|`sentence-transformers/all-MiniLM-L12-v2` ([Info](https://huggingface.co/sentence-transformers/all-MiniLM-L12-v2))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-all-MiniLM-L12-v2`| +|`sentence-transformers/paraphrase-multilingual-mpnet-base-v2` ([Info](https://huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-paraphrase-multilingual-mpnet-base-v2`| +|`sentence-transformers/all-MiniLM-L6-v2` ([Info](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-all-MiniLM-L6-v2`| +|`sentence-transformers/multi-qa-distilbert-cos-v1` ([Info](https://huggingface.co/sentence-transformers/multi-qa-distilbert-cos-v1))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-multi-qa-distilbert-cos-v1`| +|`sentence-transformers/gtr-t5-base` ([Info](https://huggingface.co/sentence-transformers/gtr-t5-base))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-gtr-t5-base`| +|`sentence-transformers/gtr-t5-large` ([Info](https://huggingface.co/sentence-transformers/gtr-t5-large))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-gtr-t5-large`| +|`google/flan-t5-base` ([Info](https://huggingface.co/google/flan-t5-base))|`cr.weaviate.io/semitechnologies/transformers-inference:google-flan-t5-base`| +|`google/flan-t5-large` ([Info](https://huggingface.co/google/flan-t5-large))|`cr.weaviate.io/semitechnologies/transformers-inference:google-flan-t5-large`| +|`BAAI/bge-small-en-v1.5` ([Info](https://huggingface.co/BAAI/bge-small-en-v1.5))|`cr.weaviate.io/semitechnologies/transformers-inference:baai-bge-small-en-v1.5`| +|`BAAI/bge-base-en-v1.5` ([Info](https://huggingface.co/BAAI/bge-base-en-v1.5))|`cr.weaviate.io/semitechnologies/transformers-inference:baai-bge-base-en-v1.5`| + +
+ +
+ + +:::info +[DPR](https://huggingface.co/docs/transformers/en/model_doc/dpr) モデルでは、パッセージエンコーダー用とクエリーエンコーダー用の 2 つの推論コンテナを使用します。 これらのモデルは GPU アクセラレーションの恩恵を受けます。 利用可能な環境では、[ Docker もしくは Kubernetes の設定](#weaviate-configuration)で CUDA アクセラレーションを有効にしてください。 +::: + +
+ 全リストを表示 + +|モデル名|イメージ名| +|---|---| +|`facebook/dpr-ctx_encoder-single-nq-base` ([Info](https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base))|`cr.weaviate.io/semitechnologies/transformers-inference:facebook-dpr-ctx_encoder-single-nq-base`| +|`facebook/dpr-question_encoder-single-nq-base` ([Info](https://huggingface.co/facebook/dpr-question_encoder-single-nq-base))|`cr.weaviate.io/semitechnologies/transformers-inference:facebook-dpr-question_encoder-single-nq-base`| +|`vblagoje/dpr-ctx_encoder-single-lfqa-wiki` ([Info](https://huggingface.co/vblagoje/dpr-ctx_encoder-single-lfqa-wiki))|`cr.weaviate.io/semitechnologies/transformers-inference:vblagoje-dpr-ctx_encoder-single-lfqa-wiki`| +|`vblagoje/dpr-question_encoder-single-lfqa-wiki` ([Info](https://huggingface.co/vblagoje/dpr-question_encoder-single-lfqa-wiki))|`cr.weaviate.io/semitechnologies/transformers-inference:vblagoje-dpr-question_encoder-single-lfqa-wiki`| +|Bar-Ilan University NLP Lab Models| +|`biu-nlp/abstract-sim-sentence` ([Info](https://huggingface.co/biu-nlp/abstract-sim-sentence))|`cr.weaviate.io/semitechnologies/transformers-inference:biu-nlp-abstract-sim-sentence`| +|`biu-nlp/abstract-sim-query` ([Info](https://huggingface.co/biu-nlp/abstract-sim-query))|`cr.weaviate.io/semitechnologies/transformers-inference:biu-nlp-abstract-sim-query`| + +
+ +
+ + +:::info +Snowflake の [Arctic](https://huggingface.co/collections/Snowflake/arctic-embed-661fd57d50fab5fc314e4c18) 埋め込みモデルも利用できます。 これらのモデルは GPU アクセラレーションの恩恵を受けます。 利用可能な環境では、[ Docker もしくは Kubernetes の設定](#weaviate-configuration)で CUDA アクセラレーションを有効にしてください。 +::: + +
+ 全リストを表示 + +|モデル名|イメージ名| +|---|---| +|`Snowflake/snowflake-arctic-embed-xs` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-xs))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-xs`| +|`Snowflake/snowflake-arctic-embed-s` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-s))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-s`| +|`Snowflake/snowflake-arctic-embed-m` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-m))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-m`| +|`Snowflake/snowflake-arctic-embed-l` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-l))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-l`| + +
+ +
+ + +:::info +ONNX 対応イメージは、[ONNX Runtime](https://onnxruntime.ai/docs/) を使用して CPU 上で高速に推論を行います。 ARM64 と AMD64 (AVX2) ハードウェア向けに量子化されています。 + +イメージ名の末尾が `-onnx` であることが目印です。 +::: + +
+ 全リストを表示 + +|モデル名|イメージ名| +|---|---| +|`sentence-transformers/all-MiniLM-L6-v2` ([Info](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2))|`cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-all-MiniLM-L6-v2-onnx`| +|`BAAI/bge-small-en-v1.5` ([Info](https://huggingface.co/BAAI/bge-small-en-v1.5))|`cr.weaviate.io/semitechnologies/transformers-inference:baai-bge-small-en-v1.5-onnx`| +|`BAAI/bge-base-en-v1.5` ([Info](https://huggingface.co/BAAI/bge-base-en-v1.5))|`cr.weaviate.io/semitechnologies/transformers-inference:baai-bge-base-en-v1.5-onnx`| +|`BAAI/bge-m3` ([Info](https://huggingface.co/BAAI/bge-m3))|`cr.weaviate.io/semitechnologies/transformers-inference:baai-bge-m3-onnx`| +|`Snowflake/snowflake-arctic-embed-xs` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-xs))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-xs-onnx`| +|`Snowflake/snowflake-arctic-embed-s` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-s))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-s-onnx`| +|`Snowflake/snowflake-arctic-embed-m` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-m))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-m-onnx`| +|`Snowflake/snowflake-arctic-embed-l` ([Info](https://huggingface.co/Snowflake/snowflake-arctic-embed-l))|`cr.weaviate.io/semitechnologies/transformers-inference:snowflake-snowflake-arctic-embed-l-onnx`| + +
+ +
+
+ +新しいモデルは随時追加しています。 最新のモデル一覧については、[transformers-inference](https://hub.docker.com/r/semitechnologies/transformers-inference/tags) コンテナの Docker Hub タグをご覧ください。 + +## 高度な設定 + +### 推論コンテナを個別に実行する + +別の方法として、推論コンテナを Weaviate とは独立して実行することも可能です。 以下の手順に従ってください。 + +- `text2vec-transformers` を有効にし、[Weaviate の設定](#weaviate-configuration)では `text2vec-transformers` コンテナのパラメーターを省略します +- たとえば Docker を使用して推論コンテナを別プロセスで実行します +- 推論コンテナの URL を設定するために、`TRANSFORMERS_INFERENCE_API` または [`inferenceUrl`](#configure-the-vectorizer) を使用します + +たとえば、Docker でコンテナを実行します。 + +```shell +docker run -itp "8000:8080" semitechnologies/transformers-inference:sentence-transformers-multi-qa-MiniLM-L6-cos-v1 +``` + +その後、`TRANSFORMERS_INFERENCE_API="http://localhost:8000"` を設定します。 Weaviate が同じ Docker ネットワーク、つまり同じ `docker-compose.yml` の一部として実行されている場合は、`TRANSFORMERS_INFERENCE_API=http://text2vec-transformers:8080` のように Docker のネットワーク/DNS 名を利用できます。 + +## さらなるリソース + +### その他の統合 + +- [Transformers マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) +- [Transformers リランカーモデル + Weaviate](./reranker.md) + +### チャンク化 + +この統合では、モデルに渡す前にテキストがモデルの最大 token 長を超えている場合、自動的にチャンク化します。その後、プールされた ベクトル を返します。 + +具体的な実装については [HuggingFaceVectorizer.vectorizer()](https://github.com/weaviate/text2vec-transformers-models/blob/main/vectorizer.py) を参照してください。 + +### コード例 + +コレクションで統合を設定すると、Weaviate におけるデータ管理および検索操作は他のコレクションと同一の方法で動作します。モデルに依存しない以下の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) ガイドでは、データ操作(つまりコレクションとその内部のオブジェクトの作成、読み取り、更新、削除)の方法を示しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、 ベクトル 、キーワード、ハイブリッド検索のほか、検索拡張生成の実行方法を示しています。 + +### モデルライセンス + +互換性のある各モデルには、それぞれのライセンスがあります。詳細については、使用するモデルのライセンスを [Hugging Face Model Hub](https://huggingface.co/models) で確認してください。 + +使用目的に対してそのライセンス条件が適切かどうかを評価する責任は、利用者にあります。 + +### カスタムモデル + +カスタムモデルで統合を実行するには、[カスタムイメージガイド](./embeddings-custom-image.md) を参照してください。 + +### 外部リソース + +- Hugging Face [Model Hub](https://huggingface.co/models) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/index.md new file mode 100644 index 000000000..a79a359c2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/index.md @@ -0,0 +1,50 @@ +--- +title: ローカルホストされた Transformers + Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_transformers.jpg +# tags: ['model providers', 'huggingface', 'transformers'] +--- + + + +Hugging Face の Transformers ライブラリは、自然言語処理向けの幅広いモデルで利用できます。 Weaviate は Transformers ライブラリとシームレスに統合し、ユーザーは Weaviate Database から直接互換性のあるモデルを活用できます。 + +これらの統合により、開発者は高度な AI 駆動アプリケーションを簡単に構築できます。 + +## Hugging Face Transformers との統合 + +Weaviate は、互換性のある Hugging Face Transformers モデルをコンテナで起動することで統合します。 これにより、ユーザーは独自のモデルをホストし、 Weaviate と共に利用できます。 + +### ベクトル検索用エンベディングモデル + +![Embedding integration illustration](../_includes/integration_transformers_embedding.png) + +Transformers 互換のエンベディングモデルは、テキストデータを意味とコンテキストを捉えたベクトル埋め込みに変換します。 + +[Weaviate は Hugging Face Transformers のエンベディングモデルと統合しています](./embeddings.md) 。この統合により、追加の前処理やデータ変換を行うことなく、意味検索およびハイブリッド検索を実行できます。 + +[Hugging Face Transformers エンベディング統合ページ](./embeddings.md) + +## 概要 + +これらの統合により、開発者は Weaviate 内部から直接強力な Hugging Face Transformers モデルを活用できます。 + +その結果、 AI 駆動アプリケーションの構築プロセスが簡素化され、開発スピードが向上し、革新的なソリューションの創出に集中できます。 + +## 始める + +これらの統合を利用するには、ローカルでホストされた Weaviate インスタンスが必要です。 これにより、ご自身の Hugging Face Transformers モデルをホストできます。 + +関連する統合ページにアクセスして、 Hugging Face Transformers モデルを Weaviate で構成し、アプリケーションでの使用を開始してください。 + +- [テキストエンベディング](./embeddings.md) +- [テキストエンベディング(カスタムイメージ)](./embeddings-custom-image.md) +- [マルチモーダルエンベディング](./embeddings-multimodal.md) +- [マルチモーダルエンベディング(カスタムイメージ)](./embeddings-multimodal-custom-image.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/reranker.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/reranker.md new file mode 100644 index 000000000..d7e48951a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/transformers/reranker.md @@ -0,0 +1,232 @@ +--- +title: リランカー +description: Weaviate の Transformers リランカー モジュールで検索結果を強化します。 +sidebar_position: 80 +image: og/docs/integrations/provider_integrations_transformers.jpg +# tags: ['model providers', 'transformers', 'reranking'] +--- + +# Weaviate でのローカルホスト Transformers リランカー モデル + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.reranker.py'; +import TSCode from '!!raw-loader!../_includes/provider.reranker.ts'; + +Weaviate と Hugging Face の Transformers ライブラリを統合することで、そのモデルの機能を Weaviate から直接利用できます。 + +[Weaviate コレクションを設定](#configure-the-reranker) して Transformers 連携を有効にし、[Weaviate インスタンスを設定](#weaviate-configuration) してモデル イメージを指定すると、Transformers 推論コンテナー内の指定モデルを使用して検索結果をリランクします。 + +この 2 ステップの処理では、まず Weaviate が検索を実行し、その後で指定したモデルを使って結果をリランクします。 + +![Reranker integration illustration](../_includes/integration_transformers_reranker.png) + +## 要件 + +### Weaviate の構成 + +お使いの Weaviate インスタンスには、Transformers リランカー連携モジュール(`reranker-transformers`)が有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この連携は Hugging Face モデルを含むコンテナーを起動する必要があるため、Weaviate Cloud (WCD) のサーバーレス インスタンスでは利用できません。 + +
+ +#### 統合モジュールを有効化する + +- [クラスターメタデータ](/deploy/configuration/meta.md) を確認し、モジュールが有効になっているか調べます。 +- [モジュール設定方法](../../configuration/modules.md) のガイドに従い、Weaviate でモジュールを有効にします。 + +#### 統合の設定 + +この連携を利用するには、Hugging Face Transformers モデルのコンテナー イメージと、そのコンテナ化モデルの推論エンドポイントを設定します。 + +以下の例は、Weaviate で Hugging Face Transformers 連携を設定する方法を示しています。 + + + + +#### Docker オプション 1: 事前設定済み `docker-compose.yml` ファイルを使用 + +[Weaviate Docker インストール コンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator) の手順に従い、選択したモデルを含む事前設定済み `docker-compose.yml` ファイルをダウンロードします。 +
+ +#### Docker オプション 2: 手動で設定を追加 + +あるいは、下記例のように `docker-compose.yml` ファイルへ設定を手動で追加します。 + +```yaml +services: + weaviate: + # Other Weaviate configuration + environment: + RERANKER_INFERENCE_API: http://reranker-transformers:8080 # Set the inference API endpoint + reranker-transformers: # Set the name of the inference container + image: cr.weaviate.io/semitechnologies/reranker-transformers:cross-encoder-ms-marco-MiniLM-L-6-v2 + environment: + ENABLE_CUDA: 0 # Set to 1 to enable +``` + +- `RERANKER_INFERENCE_API` 環境変数は推論 API エンドポイントを設定します +- `reranker-transformers` は推論コンテナーの名前です +- `image` はコンテナー イメージです +- `ENABLE_CUDA` 環境変数で GPU 使用を有効化します + +特定のモデルを使用する場合は、`image` に [利用可能なモデル一覧](#available-models) から選択したイメージを設定してください。 + +
+ + +Weaviate Helm チャートの `values.yaml` ファイルの `modules` セクションに `reranker-transformers` モジュールを追加または更新して、Hugging Face Transformers 連携を設定します。例として、`values.yaml` を以下のように変更します。 + +```yaml +modules: + + reranker-transformers: + + enabled: true + tag: cross-encoder-ms-marco-MiniLM-L-6-v2 + repo: semitechnologies/reranker-transformers + registry: cr.weaviate.io + envconfig: + enable_cuda: true +``` + +より多くの設定オプションを含む `values.yaml` の例については、[Weaviate Helm チャート](https://github.com/weaviate/weaviate-helm/blob/master/weaviate/values.yaml) を参照してください。 + +特定のモデルを使用する場合は、`tag` に [利用可能なモデル一覧](#available-models) から選択したイメージを設定してください。 + + +
+ +### 認証情報 + +この連携はローカル コンテナーで Transformers モデルを実行するため、追加の認証情報(API キーなど)は不要です。以下の例のように通常どおり Weaviate に接続してください。 + + + + + + + + + + + + + +## リランカーの設定 + +import MutableRerankerConfig from '/_includes/mutable-reranker-config.md'; + + + +Transformers リランカー モデルを使用するように Weaviate コレクションを次のように設定します。 + + + + + + + + + + + + +:::note モデル選択用コンテナーイメージ +モデルを選択するには、それをホストする [コンテナー イメージ](#configure-the-integration) を選択してください。 +::: + + + +## リランキング クエリ + +リランカーを構成すると、 Weaviate は指定されたリランカー・モデルを使用して[ リランキング処理 ](../../search/rerank.md)を実行します。 + +より具体的には、 Weaviate は最初に検索を行い、その後に指定されたモデルを用いて結果をリランキングします。 + +Weaviate の任意の検索はリランカーと組み合わせることでリランキング処理を実行できます。 + +![リランカー統合のイメージ](../_includes/integration_transformers_reranker.png) + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +- `cross-encoder/ms-marco-MiniLM-L-6-v2` +- `cross-encoder/ms-marco-MiniLM-L-2-v2` +- `cross-encoder/ms-marco-TinyBERT-L-2-v2` + +これらの事前学習済みモデルは Hugging Face でオープンソース公開されています。たとえば、 `cross-encoder/ms-marco-MiniLM-L-6-v2` モデルは、 [ MS-MARCO ](https://microsoft.github.io/msmarco/) 上で評価した際に、最も大きいモデル (L-12) とほぼ同じベンチマーク性能 (39.01 vs. 39.02) を提供します。 + +モデルのサポートは随時追加しています。利用可能なモデルの最新リストは、 [ reranker-transformers ](https://hub.docker.com/r/semitechnologies/reranker-transformers/tags) コンテナの Docker Hub タグを参照してください。 + +## 追加リソース + +### その他の統合 + +- [Transformers 埋め込みモデル + Weaviate](./embeddings.md) +- [Transformers マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) + +### コード例 + +コレクションで統合を設定すると、 Weaviate におけるデータ管理および検索操作は他のコレクションと同様に機能します。モデル非依存の次の例をご覧ください。 + +- [ ハウツー: コレクションの管理 ](../../manage-collections/index.mdx) および [ ハウツー: オブジェクトの管理 ](../../manage-objects/index.mdx) ガイドでは、データ操作 (コレクションおよびその中のオブジェクトの作成・読み取り・更新・削除) の方法を紹介しています。 +- [ ハウツー: クエリ & 検索 ](../../search/index.mdx) ガイドでは、ベクトル、キーワード、ハイブリッド検索に加え、検索拡張生成の実行方法を説明しています。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/_category_.json new file mode 100644 index 000000000..67072b900 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Voyage AI", + "position": 270 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/embeddings-multimodal.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/embeddings-multimodal.md new file mode 100644 index 000000000..4fd9a2c0d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/embeddings-multimodal.md @@ -0,0 +1,344 @@ +--- +title: マルチモーダル埋め込み +description: "Weaviate と VoyageAI の API 連携により、Weaviate から直接モデルの機能へアクセスできます。" +sidebar_position: 25 +image: og/docs/integrations/provider_integrations_voyageai.jpg +# tags: ['model providers', 'voyageai', 'embeddings'] +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; + +# Weaviate での VoyageAI マルチモーダル埋め込み + +:::info `v1.25.28`、`v1.26.12`、`1.27.8` で追加 +::: + +Weaviate と VoyageAI の API 連携により、Weaviate から直接モデルの機能へアクセスできます。 + +[Weaviate ベクトルインデックスを構成](#configure-the-vectorizer) して VoyageAI の埋め込みモデルを使用すると、指定したモデルとお持ちの VoyageAI API キーを用いて、さまざまな操作のための埋め込みを Weaviate が生成します。この機能は *ベクトライザー* と呼ばれます。 + +この統合は VoyageAI の「interleaving」入力モードをサポートしていません。このタイプの利用方法では、[このガイド](../../starter-guides/custom-vectors.mdx) で示すようにオブジェクトと共に自己生成したベクトルをインポートしてください。 + +[インポート時](#data-import) に、Weaviate はマルチモーダルオブジェクト埋め込みを生成し、インデックスへ保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みへ変換します。[マルチモーダル検索操作](#vector-near-media-search) もサポートされています。 + +![Embedding integration illustration](../_includes/integration_voyageai_embedding.png) + +## 要件 + +### Weaviate の設定 + +ご利用の Weaviate インスタンスは VoyageAI ベクトライザー統合 (`multi2vec-voyageai`) モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) のユーザー向け + +この統合は Weaviate Cloud (WCD) のサーバーレスインスタンスでデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- モジュールが有効かどうかを確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) をご確認ください。 +- Weaviate でモジュールを有効化する手順は、[モジュール設定方法](../../configuration/modules.md) ガイドをご覧ください。 + +
+ +### API 資格情報 + +この統合には、有効な VoyageAI API キーを Weaviate に提供する必要があります。[VoyageAI](https://voyageai.com/) でサインアップし、API キーを取得してください。 + +次のいずれかの方法で Weaviate に API キーを渡します。 + +- Weaviate が参照できる `VOYAGEAI_APIKEY` 環境変数を設定する。 +- 以下の例のように実行時に API キーを渡す。 + + + + + + + + + + + + + +## ベクトライザーを構成する + +VoyageAI の埋め込みモデルを使用するように、[Weaviate インデックスを構成](../../manage-collections/vector-config.mdx#specify-a-vectorizer) します。 + + + + + + + + + + + + +### モデルを選択する + +以下の設定例のように、[利用可能なモデル](#available-models) のいずれかをベクトライザーに指定できます。 + + + + + + + + + + + + +Weaviate に使用させるモデルは、[ベクトライザーのパラメーター](#vectorizer-parameters) で [利用可能なモデル](#available-models) のいずれかを指定できます。指定がない場合は [デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の動作 + + + +
+ + + +### ベクトライザーのパラメーター + +以下の例は、 VoyageAI 固有のオプションを設定する方法を示します。 + + + + + + + + + + + + +モデル パラメーターの詳細については、[VoyageAI API ドキュメント](https://docs.voyageai.com/docs/multimodal-embeddings) を参照してください。 + + +## ヘッダー パラメーター + +リクエストの追加ヘッダーを使って、実行時に API キーと任意パラメーターを提供できます。 +利用可能なヘッダーは次のとおりです: + +- `X-VoyageAI-Api-Key`: VoyageAI の API キー。 +- `X-VoyageAI-Baseurl`: 既定の VoyageAI URL の代わりに使用するベース URL (例: プロキシ)。 + +実行時に追加ヘッダーを指定した場合、既存の Weaviate 設定を上書きします。 + +ヘッダーは上記の [API 資格情報の例](#api-credentials) のとおりに指定してください。 + +## データのインポート + +ベクトライザーを設定した後、 Weaviate に [データをインポート](../../manage-objects/import.mdx) します。 Weaviate は、指定したモデルを使用してテキスト オブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +すでに互換性のあるモデル ベクトルがある場合は、それを直接 Weaviate に渡すことができます。同じモデルで既に埋め込みを生成しており、それらを Weaviate で利用したい場合 (他システムからデータを移行する際など) に便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、 Weaviate は指定した VoyageAI モデルを使用してベクトル検索とハイブリッド検索を実行します。 + +![検索時の埋め込み統合のイメージ](../_includes/integration_voyageai_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、 Weaviate はテキスト クエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +次のクエリは、`limit` で指定した数 (`n`) の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは +ハイブリッド検索は、ベクトル検索とキーワード (BM25) 検索を実行し、その結果を [組み合わせる](../../search/hybrid.md) ことでデータベースから最適なオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md) を実行すると、 Weaviate はテキスト クエリを指定したモデルで埋め込みに変換し、データベースからスコアが最も高いオブジェクトを返します。 + +次のクエリは、`limit` で指定した数 (`n`) のスコアが最も高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + +### ベクトル (near media) 検索 + +[near image 検索](../../search/similarity.md#search-with-image) のようなメディア検索を実行すると、 Weaviate は指定したモデルを使用してクエリを埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +near image 検索などの near media 検索を行うには、メディアクエリを base64 文字列に変換し、それを検索クエリに渡します。 + +以下のクエリは、`limit` で設定した n 件の入力画像に最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + +## リファレンス + +### 利用可能なモデル + +- `voyage-multimodal-3` (デフォルト) + +## 追加リソース + +### その他の統合 + +- [VoyageAI テキスト埋め込みモデル + Weaviate](./embeddings.md). +- [VoyageAI reranker モデル + Weaviate](./reranker.md). + +### コード例 + +統合をコレクションに設定すると、 Weaviate でのデータ管理および検索操作は他のコレクションと同じ手順で行えます。以下のモデル非依存の例をご覧ください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) と [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) では、コレクションおよびその中のオブジェクトの作成、読み取り、更新、削除といったデータ操作方法を説明しています。 +- [How-to: クエリ & 検索](../../search/index.mdx) では、ベクトル検索、キーワード検索、ハイブリッド検索に加え、検索拡張生成の実行方法を説明しています。 + +### 外部リソース + +- VoyageAI [Multimodal Embed API ドキュメント](https://docs.voyageai.com/docs/multimodal-embeddings) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/embeddings.md new file mode 100644 index 000000000..f1e431875 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/embeddings.md @@ -0,0 +1,400 @@ +--- +title: テキスト埋め込み +description: "Weaviate と Voyage AI の API 統合により、Weaviate から直接モデルの機能にアクセスできます。" +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_voyageai.jpg +# tags: ['model providers', 'voyageai', 'embeddings'] +--- + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect/main.go'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; + +# Weaviate における Voyage AI 埋め込み + +Weaviate と Voyage AI の API 統合により、Weaviate から直接それらのモデルの機能にアクセスできます。 + +[Weaviate のベクトル インデックスを設定](#configure-the-vectorizer)して Voyage AI の埋め込みモデルを使用すると、指定したモデルとお持ちの Voyage AI API キーを使って、さまざまな操作向けに埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import)に、Weaviate はテキストオブジェクトの埋め込みを生成してインデックスに保存します。[ベクトル](#vector-near-text-search)および[ハイブリッド](#hybrid-search)検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![埋め込み統合のイメージ](../_includes/integration_voyageai_embedding.png) + +## 要件 + +### Weaviate の構成 + +ご利用の Weaviate インスタンスには、Voyage AI ベクトライザー統合(`text2vec-voyageai`)モジュールが有効になっている必要があります。 + +
+ Weaviate Cloud (WCD) ユーザー向け + +この統合は、Weaviate Cloud (WCD) のサーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホストユーザー向け + +- [クラスター メタデータ](/deploy/configuration/meta.md)を確認し、モジュールが有効になっているか確認してください。 +- Weaviate でモジュールを有効にする方法は、[モジュール設定ガイド](../../configuration/modules.md)をご覧ください。 + +
+ +### API 認証情報 + +この統合を利用するには、有効な Voyage AI API キーを Weaviate に提供する必要があります。API キーは [Voyage AI](https://www.voyageai.com/) でサインアップして取得できます。 + +以下のいずれかの方法で Weaviate に API キーを渡してください。 + +- Weaviate がアクセス可能な環境変数 `VOYAGEAI_APIKEY` を設定する +- 以下の例のように、実行時に API キーを渡す + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +Voyage AI 埋め込みモデルを使用するよう、[Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer)します。 + + + + + + + + + + + + + + + + + + +### モデルの選択 + +以下の設定例に示すように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + + + + + +[利用可能なモデル](#available-models) のいずれかを [指定](#vectorizer-parameters) して Weaviate で使用できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +### ベクトライザーのパラメーター + +以下の例は、 Voyage AI 固有のオプションを設定する方法を示しています。 + + + + + + + + + + + + + + + + +モデルパラメーターの詳細については、[Voyage AI Embedding API ドキュメント](https://docs.voyageai.com/docs/embeddings) を参照してください。 + +## ヘッダーパラメーター + +実行時にリクエストの追加ヘッダーを通じて、 API キーおよびいくつかのオプションパラメーターを渡すことができます。利用可能なヘッダーは次のとおりです。 + +- `X-VoyageAI-Api-Key`: Voyage AI の API キー。 +- `X-VoyageAI-Baseurl`: デフォルトの Voyage AI URL の代わりに使用するベース URL(例: プロキシ)。 + +実行時に指定された追加ヘッダーは、既存の Weaviate の設定を上書きします。 + +上記の [API 資格情報の例](#api-credentials) に示すようにヘッダーを指定してください。 + +## データインポート + +ベクトライザーを設定したら、[データをインポート](../../manage-objects/import.mdx) して Weaviate に取り込みます。 Weaviate は、指定したモデルを使用してテキストオブジェクトの埋め込みを生成します。 + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデルのベクトルが既にある場合は、それを直接 Weaviate に提供できます。同じモデルで既に埋め込みを生成しており、他のシステムからの移行などでそれらを Weaviate で使用したい場合に便利です。 +::: + +## 検索 + +ベクトライザーを設定すると、Weaviate は指定した Voyage AI モデルを用いて ベクトル検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合の図](../_includes/integration_voyageai_embedding_search.png) + +### ベクトル(near text)検索 + +[ベクトル検索](../../search/similarity.md#search-with-text)を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +以下のクエリは、`limit` で指定した件数 `n` の最も類似したオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索は、ベクトル検索とキーワード(BM25)検索を実行し、その後 [結果を結合](../../search/hybrid.md) してデータベースから最も一致するオブジェクトを返します。 +::: + +[ハイブリッド検索](../../search/hybrid.md)を実行すると、Weaviate はテキストクエリを指定したモデルで埋め込みに変換し、データベースから最もスコアの高いオブジェクトを返します。 + +以下のクエリは、`limit` で指定した件数 `n` の最もスコアの高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +- voyage-3.5 +- voyage-3.5-lite +- voyage-3-large +- voyage-3 (default) +- voyage-3-lite +- voyage-large-2 (default for <= `v1.24.24`, `v1.25.17`, `v1.26.4`) +- voyage-code-2 +- voyage-2 +- voyage-law-2 +- voyage-large-2-instruct +- voyage-finance-2 +- voyage-multilingual-2 + +
+ + モデルサポート履歴 + + +- `v1.24.25`, `v1.25.18`, `v1.26.5`: + - `voyage-3`, `voyage-3-lite` を追加 + - デフォルトモデルが `voyage-large-2` から `voyage-3` に変更 +- `v1.24.14`, `v1.25.1`: + - `voyage-large-2-instruct` を追加 + - `voyage-lite-02-instruct` を削除 +- `v1.24.9`: + - `voyage-law-2`, `voyage-lite-02-instruct` を追加 +- `v1.24.2`: + - `text2vec-voyage` を導入し、`voyage-large-2`, `voyage-code-2`, `voyage-2` をサポート + +
+ +## 追加リソース + +### その他のインテグレーション + +- [Voyage AI マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) +- [Voyage AI リランカー モデル + Weaviate](./embeddings.md). + +### コード例 + +コレクションでインテグレーションを設定すると、Weaviate におけるデータ管理および検索操作は他のコレクションとまったく同じように動作します。以下のモデル非依存の例をご覧ください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) の各ガイドでは、データ操作(コレクションおよびその内部のオブジェクトの作成、読み取り、更新、削除)を実行する方法を解説しています。 +- [How-to: Query & Search](../../search/index.mdx) ガイドでは、ベクトル検索、キーワード検索、ハイブリッド検索に加えて、検索拡張生成を実行する方法を説明しています。 + +### 外部リソース + +- Voyage AI [Embeddings API documentation](https://docs.voyageai.com/docs/embeddings) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/index.md new file mode 100644 index 000000000..21c73f6f6 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/index.md @@ -0,0 +1,58 @@ +--- +title: Voyage AI + Weaviate +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_voyageai.jpg +# tags: ['model providers', 'voyageai'] +--- + + + +Voyage AI は自然言語処理向けに幅広いモデルを提供しています。 Weaviate は Voyage AI の API とシームレスに統合されており、ユーザーは Weaviate Database から直接 Voyage AI のモデルを利用できます。 + +これらの統合により、開発者は高度な AI ドリブンアプリケーションを簡単に構築できます。 + +## Voyage AI との統合 + +### ベクトル検索向け埋め込みモデル + +![Embedding integration illustration](../_includes/integration_voyageai_embedding.png) + +Voyage AI の埋め込みモデルはテキストデータをベクトル埋め込みへ変換し、意味と文脈を捉えます。 + +[Weaviate は Voyage AI の埋め込みモデル](./embeddings.md) と [マルチモーダル埋め込みモデル](./embeddings-multimodal.md) に対応しており、データをシームレスにベクトル化できます。この統合により、追加の前処理やデータ変換を行わずにセマンティック検索やハイブリッド検索を実行できます。 + +- [Voyage AI 埋め込み統合ページ](./embeddings.md) +- [Voyage AI マルチモーダル埋め込み統合ページ](./embeddings-multimodal.md) + +### リランカー モデル + +![Reranker integration illustration](../_includes/integration_voyageai_reranker.png) + +Voyage AI のリランカーモデルは検索結果の関連性と順位を改善するよう設計されています。 + +[Weaviate のリランカー統合](./reranker.md) を利用すると、Voyage AI のリランカーモデルで検索結果を簡単に洗練できます。 + +[Voyage AI リランカー統合ページ](./reranker.md) + +## まとめ + +これらの統合により、開発者は Weaviate 内から直接 Voyage AI の強力なモデルを活用できます。 + +その結果、AI ドリブンアプリケーションの開発プロセスが簡素化され、開発スピードが向上し、革新的なソリューションの創出に専念できます。 + +## はじめに + +これらの統合を利用するには、有効な Voyage AI の API キーを Weaviate に設定する必要があります。 [Voyage AI](https://www.voyageai.com/) にアクセスしてサインアップし、API キーを取得してください。 + +その後、該当する統合ページで Voyage AI のモデルを Weaviate に設定する方法を確認し、アプリケーションで使い始めましょう。 + +- [テキスト埋め込み](./embeddings.md) +- [マルチモーダル埋め込み](./embeddings-multimodal.md) +- [リランカー](./reranker.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/reranker.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/reranker.md new file mode 100644 index 000000000..3680fc866 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/voyageai/reranker.md @@ -0,0 +1,202 @@ +--- +title: リランカー +description: VoyageAI リランカーモデルプロバイダー +sidebar_position: 70 +image: og/docs/integrations/provider_integrations_voyageai.jpg +# tags: ['model providers', 'voyageai', 'reranking'] +--- + + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.reranker.py'; +import TSCode from '!!raw-loader!../_includes/provider.reranker.ts'; + +# Weaviate と Voyage AI のリランカーモデル + + Weaviate と Voyage AI の API を統合することで、Weaviate から直接モデルの機能を利用できます。 + + Voyage AI のリランカーモデルを使用するように Weaviate コレクションを設定すると、Weaviate は指定したモデルとお客様の Voyage AI API キーを使用して検索結果を再ランキングします。 + + この 2 ステップのプロセスでは、まず Weaviate が検索を実行し、その後指定したモデルで結果を再ランキングします。 + +![リランカー統合のイメージ](../_includes/integration_voyageai_reranker.png) + +## 必要条件 + +### Weaviate の設定 + + お使いの Weaviate インスタンスは Voyage AI リランカー統合(`reranker-voyageai`)モジュールで設定されている必要があります。 + +
+ Weaviate Cloud (WCD) ご利用の方へ + + この統合は Weaviate Cloud (WCD) サーバーレスインスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスト環境の方へ + +- モジュールが有効になっていることを確認するために [クラスターメタデータ](/deploy/configuration/meta.md) をチェックしてください。 +- Weaviate でモジュールを有効にするには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 認証情報 + + この統合には、有効な Voyage AI API キーを Weaviate に提供する必要があります。[Voyage AI](https://www.voyageai.com/) にアクセスし、サインアップして API キーを取得してください。 + + 次のいずれかの方法で API キーを Weaviate に渡してください。 + +- `VOYAGEAI_APIKEY` という環境変数を設定し、Weaviate から参照できるようにします。 +- 以下の例のように、実行時に API キーを渡します。 + + + + + + + + + + + + + +## リランカーの設定 + +import MutableRerankerConfig from '/_includes/mutable-reranker-config.md'; + + + + 次のようにして、Voyage AI リランカーモデルを使用するように Weaviate コレクションを設定します。 + + + + + + + + + + + + + リランカーが使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +## ヘッダーパラメータ + + 実行時にリクエストヘッダーを追加することで、API キーおよびいくつかのオプションパラメータを渡せます。利用可能なヘッダーは次のとおりです。 + +- `X-VoyageAI-Api-Key`: Voyage AI API キー。 +- `X-VoyageAI-Baseurl`: デフォルトの Voyage AI URL の代わりに使用するベース URL(例: プロキシ)。 + + 実行時に追加されたヘッダーは、既存の Weaviate 設定を上書きします。 + + 上記の [API 認証情報の例](#api-credentials) に示すようにヘッダーを指定してください。 + +## リランキング クエリ + +リランカーが構成されると、 Weaviate は指定された Voyage AI モデルを使用して [リランキング操作](../../search/rerank.md) を実行します。 + +具体的には、 Weaviate が初期検索を行った後、その結果を指定されたモデルでリランキングします。 + +Weaviate では、任意の検索にリランカーを組み合わせてリランキング操作を実行できます。 + +![Reranker integration illustration](../_includes/integration_voyageai_reranker.png) + + + + + + + + + + + + + +## 参考 + +### 利用可能なモデル + +- rerank-2 +- rerank-2-lite +- rerank-1 +- rerank-lite-1 (default) + +
+ + モデルのサポート履歴 + + +- `v1.24.25`, `v1.25.18`, `v1.26.5`: + - `rerank-2`, `rerank-2-lite` を追加 +- `v1.24.18`, `v1.25.3`: + - `rerank-1` を追加 +- `1.24.7`: + - `reranker-voyageai` を導入し、 `rerank-lite-1` をサポート + +
+ +## 追加リソース + +### その他の統合 + +- [Voyage AI 埋め込みモデル + Weaviate](./embeddings.md) +- [Voyage AI マルチモーダル埋め込みモデル + Weaviate](./embeddings-multimodal.md) + +### コード例 + +コレクションで統合を構成すると、 Weaviate のデータ管理および検索操作は他のコレクションと同一に動作します。モデルに依存しない次の例をご覧ください。 + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) では、データ操作 (コレクションおよびその中のオブジェクトの作成、読み取り、更新、削除) の方法を示しています。 +- [How-to: Query & Search](../../search/index.mdx) では、 ベクトル、キーワード、ハイブリッド検索および 検索拡張生成 の実行方法を説明しています。 + +### 参考情報 + +- Voyage AI [Reranker API ドキュメント](https://docs.voyageai.com/docs/reranker) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/_category_.json new file mode 100644 index 000000000..419ca137a --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Weaviate", + "position": 60 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/embeddings.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/embeddings.md new file mode 100644 index 000000000..624e7371b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/embeddings.md @@ -0,0 +1,369 @@ +--- +title: テキスト埋め込み +description: Weaviate Embeddings のモデルは Weaviate Cloud インスタンスから直接アクセスできます。 +sidebar_position: 20 +image: og/docs/integrations/provider_integrations_wes.jpg +# tags: ['model providers', 'weaviate', 'wes', 'weaviate embeddings'] +--- + +:::info `1.27.10`, `1.28.3`, `1.29.0` で追加 +::: + +# Weaviate Embeddings + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.weaviate.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.weaviate.ts'; +import GoConnect from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/1-connect-weaviate-embeddings/main.go'; +import JavaConnect from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/ConnectWeaviateEmbeddingsTest.java'; +import PyCode from '!!raw-loader!../_includes/provider.vectorizer.py'; +import TSCode from '!!raw-loader!../_includes/provider.vectorizer.ts'; +import GoCode from '!!raw-loader!/_includes/code/howto/go/docs/model-providers/2-usage-text/main.go'; +import JavaCode from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/UsageWeaviateTextEmbeddingsArcticEmbedLV20.java'; +import JavaImportQueries from '!!raw-loader!/_includes/code/howto/java/src/test/java/io/weaviate/docs/model_providers/ImportAndQueries.java'; + +Weaviate Embeddings のモデルは Weaviate Cloud インスタンスから直接アクセスできます。 + +[Weaviate ベクトルインデックスを設定](#configure-the-vectorizer) すると、指定したモデルとお客様の Weaviate API キーを用いて Weaviate が各種操作のために埋め込みを生成します。この機能は *ベクトライザー* と呼ばれます。 + +[インポート時](#data-import) に Weaviate はテキストオブジェクトの埋め込みを生成し、インデックスに保存します。[ベクトル](#vector-near-text-search) および [ハイブリッド](#hybrid-search) 検索操作では、Weaviate がテキストクエリを埋め込みに変換します。 + +![埋め込みインテグレーションの図](../_includes/integration_wes_embedding.png) + +## 必要条件 + +import Requirements from '/_includes/weaviate-embeddings-requirements.mdx'; + + + +### Weaviate の設定 + +Weaviate Embeddings ベクトライザーは Weaviate Cloud インスタンスでのみご利用いただけます。現時点では、自己ホスト環境では Weaviate Embeddings をご利用いただけません。 + +### API 資格情報 + +Weaviate Embeddings は Weaviate Cloud と統合されています。お客様の Weaviate Cloud 資格情報が、Weaviate Cloud インスタンスによる Weaviate Embeddings へのアクセス認可に使用されます。 + + + + + + + + + + + + + + + + + + + + + +## ベクトライザーの設定 + +次のように [Weaviate インデックスを設定](../../manage-collections/vector-config.mdx#specify-a-vectorizer) して、Weaviate Embeddings モデルを使用します。 + + + + + + + + + + + + + + + + + + + + + + +### モデルの選択 + +以下の設定例に示すように、ベクトライザーで使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + + + + + + + + + +Weaviate に対して使用する [利用可能なモデル](#available-models) のいずれかを[指定](#vectorizer-parameters)できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +import VectorizationBehavior from '/_includes/vectorization.behavior.mdx'; + +
+ ベクトル化の挙動 + + + +
+ +### ベクトライザーのパラメーター + +import WeaviateEmbeddingsVectorizerParameters from '/_includes/weaviate-embeddings-vectorizer-parameters.mdx'; + + + +## データのインポート + +ベクトライザーの設定後、Weaviate に[データをインポート](../../manage-objects/import.mdx)します。Weaviate は、指定されたモデルを使用してテキストオブジェクトの埋め込み (embedding) を生成します。 + + + + + + + + + + + + + + + + + + + + + +:::tip 既存ベクトルの再利用 +互換性のあるモデルの ベクトル が既にある場合は、それを直接 Weaviate に渡すことができます。同じモデルで埋め込みをすでに生成しており、別のシステムからデータを移行する際に Weaviate で再利用したい場合などに便利です。 +::: + +## 検索 + +ベクトライザーが設定されると、Weaviate は指定された WED モデルを使用して ベクトル 検索およびハイブリッド検索を実行します。 + +![検索時の埋め込み統合の図](../_includes/integration_wes_embedding_search.png) + +### ベクトル (near text) 検索 + +[ベクトル検索](../../search/similarity.md#search-with-text) を実行すると、Weaviate はテキストクエリを指定されたモデルで埋め込みに変換し、データベースから最も類似したオブジェクトを返します。 + +`limit` で設定した値に基づき、以下のクエリはデータベースから `n` 件の最も類似したオブジェクトを返します。 + + + + + + + + + + + + + + + + + + + + + +### ハイブリッド検索 + +:::info ハイブリッド検索とは? +ハイブリッド検索では、ベクトル検索とキーワード ( BM25 ) 検索を実行し、その結果を[組み合わせて](../../search/hybrid.md)データベースから最適なオブジェクトを返します。 +::: + +ハイブリッド検索を実行すると、Weaviate は指定されたモデルを使用してテキストクエリをエンベディングに変換し、データベースからスコアの高いオブジェクトを返します。 + +以下のクエリは、`limit` で指定された `n` 個のスコアが最も高いオブジェクトをデータベースから返します。 + + + + + + + + + + + + + + + + + + + + +## 参考資料 + +### 利用可能なモデル + +import WeaviateEmbeddingsModels from '/_includes/weaviate-embeddings-models.mdx'; + + + +## さらに詳しい情報 + +### コード例 + +コレクションでインテグレーションを設定すると、Weaviate でのデータ管理および検索操作は他のコレクションと同じ方法で行えます。以下のモデル非依存の例をご覧ください: + +- [How-to: Manage collections](../../manage-collections/index.mdx) と [How-to: Manage objects](../../manage-objects/index.mdx) のガイドでは、データ操作(コレクションおよび内部のオブジェクトの作成、読み取り、更新、削除)の方法を示しています。 +- [How-to: Query & Search](../../search/index.mdx) のガイドでは、検索操作(ベクトル、キーワード、ハイブリッド)および 検索拡張生成 の方法を示しています。 + +### 参考資料 + +- Weaviate Embeddings [ドキュメント](/cloud/embeddings) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/index.md new file mode 100644 index 000000000..be28156e0 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/weaviate/index.md @@ -0,0 +1,49 @@ +--- +title: Weaviate Embeddings +sidebar_position: 10 +image: og/docs/integrations/provider_integrations_wes.jpg +# tags: ['model providers', 'weaviate', 'weaviate embeddings'] +--- + +:::info Weaviate Embeddings へのアクセス +Weaviate Embeddings は Weaviate Cloud で提供される有料サービスです。Sandbox クラスターを使用して無料でお試しいただけます。 +::: + + + +[Weaviate Embeddings](/cloud/embeddings) は Weaviate Cloud ユーザーに ベクトライザー モデルを提供し、Weaviate Cloud のデータベース インスタンスから直接 Weaviate Embeddings のモデルを活用できます。 + +これらの統合により、開発者は高度な AI ドリブン アプリケーションを簡単に構築できます。 + +## Weaviate Embeddings との統合 + +### ベクトル検索向け エンベディングモデル + +![エンベディング統合の図](../_includes/integration_wes_embedding.png) + +Weaviate Embeddings のモデルは、テキストデータを意味とコンテキストを捉えた ベクトル エンベディングへ変換します。 + +[Weaviate Cloud は Weaviate Embeddings のエンベディングモデル](./embeddings.md) と統合して、データのシームレスなベクトル化を実現します。この統合により、追加の前処理やデータ変換を行わずに、セマンティック検索やハイブリッド検索を実行できます。 + +[Weaviate Embeddings の統合ページ](./embeddings.md) + +## 概要 + +これらの統合により、開発者は Weaviate 内部で Weaviate Embeddings の強力なモデルを直接利用できます。 + +その結果、AI ドリブン アプリケーションの構築プロセスが簡素化され、開発を加速し、革新的なソリューションの創出に集中できます。 + +## はじめに + +これらの統合を利用するには、有効な Weaviate Cloud API キーを Weaviate に提供する必要があります。[Weaviate Cloud](https://console.weaviate.cloud/) にアクセスして登録し、API キーを取得してください。 + +次に、該当する統合ページで Weaviate を Weaviate Embeddings モデルと連携する設定方法を確認し、アプリケーションで利用を開始してください。 + +- [テキスト エンベディング](./embeddings.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/_category_.json new file mode 100644 index 000000000..b0db2c436 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "xAI", + "position": 281 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/generative.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/generative.md new file mode 100644 index 000000000..5ddfde293 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/generative.md @@ -0,0 +1,277 @@ +--- +title: 生成 AI +sidebar_position: 51 +# image: og/docs/integrations/provider_integrations_xai.jpg +# tags: ['model providers', 'xAI', 'generative', 'rag'] +--- + +# Weaviate による xAI 生成 AI + +:::info `v1.30.0` で追加 +::: + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import FilteredTextBlock from '@site/src/components/Documentation/FilteredTextBlock'; +import PyConnect from '!!raw-loader!../_includes/provider.connect.py'; +import TSConnect from '!!raw-loader!../_includes/provider.connect.ts'; +import PyCode from '!!raw-loader!../_includes/provider.generative.py'; +import TSCode from '!!raw-loader!../_includes/provider.generative.ts'; + +Weaviate の xAI API との統合により、xAI のモデル機能に Weaviate から直接アクセスできます。 + +xAI の生成 AI モデルを使用するために、[Weaviate コレクションを設定](#configure-collection) してください。Weaviate は、指定したモデルとお客様の xAI API Key を用いて 検索拡張生成 (RAG) を実行します。 + +より具体的には、Weaviate は検索を実行して最も関連性の高いオブジェクトを取得し、それらを xAI 上の生成モデルに渡して出力を生成します。 + +![RAG 統合の図](../_includes/integration_xai_rag.png) + +## 要件 + +### Weaviate の構成 + +ご利用の Weaviate インスタンスには xAI 生成 (`generative-xai`) モジュールを構成する必要があります。 + +
+ Weaviate Cloud (WCD) 利用者向け + +この統合は Weaviate Cloud (WCD) の serverless インスタンスではデフォルトで有効になっています。 + +
+ +
+ セルフホスト環境向け + +- モジュールが有効になっているか確認するには、[クラスターメタデータ](/deploy/configuration/meta.md) を確認してください。 +- モジュールを有効化するには、[モジュール設定方法](../../configuration/modules.md) ガイドに従ってください。 + +
+ +### API 認証情報 + +この統合を使用するには、有効な API Key を Weaviate に提供する必要があります。[xAI](https://console.x.ai/) にアクセスしてサインアップし、API Key を取得してください。 + +次のいずれかの方法で API Key を Weaviate に渡してください。 + +- Weaviate から参照可能な `XAI_APIKEY` 環境変数を設定します。 +- 以下の例のように、実行時に API Key を渡します。 + + + + + + + + + + + + + +## コレクションの設定 + +import MutableGenerativeConfig from '/_includes/mutable-generative-config.md'; + + + +xAI 生成 AI モデルを使用するには、次のように [Weaviate インデックスを設定](../../manage-collections/generative-reranker-models.mdx#specify-a-generative-model-integration) します。 + + + + + + + + + + + + +### モデルの選択 + +以下の設定例のように、Weaviate が使用する [利用可能なモデル](#available-models) のいずれかを指定できます。 + + + + + + + + + + + + +Weaviate が使用するモデルとして、[利用可能なモデル](#available-models) のいずれかを[指定](#generative-parameters)できます。モデルを指定しない場合は、[デフォルトモデル](#available-models) が使用されます。 + +### 生成パラメーター + +以下の生成パラメーターを設定して、モデルの動作をカスタマイズします。 + + + + + + + + + + + + +モデルパラメーターの詳細については、[xAI API ドキュメント](https://docs.x.ai/docs/guides/chat#parameters)をご覧ください。 + +## 実行時のモデル選択 + +コレクションを作成するときにデフォルトのモデルプロバイダーを設定するだけでなく、クエリ実行時に上書きすることもできます。 + + + + + + + + + + +## 検索拡張生成 + +生成 AI との統合を設定した後、[単一プロンプト](#single-prompt) または [グループタスク](#grouped-task) の方法で RAG 操作を実行します。 + +### 単一プロンプト + +![Single prompt RAG integration generates individual outputs per search result](../_includes/integration_xai_rag.png) + +検索結果の各オブジェクトに対してテキストを生成するには、単一プロンプト方式を使用します。 + +次の例では、`limit` パラメーターで指定した `n` 件の検索結果それぞれに対して出力を生成します。 + +単一プロンプトクエリを作成するときは、波かっこ `{}` を使用して、Weaviate が言語モデルに渡すオブジェクトのプロパティを補間します。たとえば、オブジェクトの `title` プロパティを渡すには、クエリに `{title}` を含めます。 + + + + + + + + + + + + + +### グループタスク + +![Grouped task RAG integration generates one output for the set of search results](../_includes/integration_xai_rag.png) + +検索結果全体に対して 1 つのテキストを生成するには、グループタスク方式を使用します。 + +言い換えれば、`n` 件の検索結果がある場合でも、生成モデルはそのグループ全体に対して 1 つの出力を返します。 + + + + + + + + + + + + + +## 参考情報 + +### 利用可能なモデル + +Weaviate では、[xAI の API](https://docs.x.ai/docs/models) 上の任意の生成モデルを使用できます。 + +デフォルトモデルは `grok-2-latest` です。 + +## 追加リソース + +### コード例 + +インテグレーションをコレクションで設定すると、 Weaviate でのデータ管理および検索操作は他のコレクションとまったく同じ方法で動作します。次の model-agnostic な例を参照してください。 + +- [How-to: コレクションを管理する](../../manage-collections/index.mdx) および [How-to: オブジェクトを管理する](../../manage-objects/index.mdx) ガイドでは、データ操作(すなわちコレクションおよびその中のオブジェクトの作成、読み取り、更新、削除)の方法を示します。 +- [How-to: クエリ & 検索](../../search/index.mdx) ガイドでは、ベクトル、キーワード、ハイブリッド検索に加えて 検索拡張生成 の実行方法を示します。 + +### 参考資料 + +- [ xAI API ドキュメント ](https://docs.x.ai/docs/introduction) + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/index.md new file mode 100644 index 000000000..f8759dc47 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/model-providers/xai/index.md @@ -0,0 +1,45 @@ +--- +title: xAI と Weaviate +sidebar_position: 10 +# image: og/docs/integrations/provider_integrations_xai.jpg +# tags: ['model providers', 'xAI'] +--- + + + +xAI は自然言語の処理と生成のために幅広いモデルを提供しています。 Weaviate は xAI の API とシームレスに統合され、ユーザーは Weaviate Database から直接 xAI のモデルを活用できます。 + +これらの統合により、開発者は高度な AI ドリブン アプリケーションを簡単に構築できます。 + +## xAI との統合 + +### RAG 用生成 AI モデル + +![単一プロンプト RAG 統合は検索結果ごとに個別の出力を生成します](../_includes/integration_xai_rag.png) + +xAI の生成 AI モデルは、与えられたプロンプトとコンテキストに基づいて人間のようなテキストを生成できます。 + +[Weaviate の生成 AI 統合](./generative.md) を使用すると、ユーザーは Weaviate Database から直接 検索拡張生成 (RAG) を実行できます。これは、Weaviate の効率的なストレージと高速な検索機能を xAI の生成 AI モデルと組み合わせることで、パーソナライズされた文脈に即した応答を生成します。 + +[xAI 生成 AI 統合ページ](./generative.md) + +## まとめ + +これらの統合により、開発者は xAI の強力なモデルを Weaviate 内で直接活用できます。 + +その結果、AI ドリブン アプリケーションの構築プロセスが簡素化され、開発を加速し、イノベーティブなソリューションの創出に集中できます。 + +## はじめに + +この統合を利用するには、有効な xAI API キーを Weaviate に提供する必要があります。 [xAI](https://console.x.ai/) にアクセスしてサインアップし、API キーを取得してください。 + +次に、該当する統合ページに移動し、xAI モデルで Weaviate を構成する方法を学び、ご自身のアプリケーションで利用を開始してください。 + +- [生成 AI](./generative.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/_category_.json new file mode 100644 index 000000000..18cca8309 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Reference: Modules", + "position": 95 +} diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/custom-modules.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/custom-modules.md new file mode 100644 index 000000000..94c58b4af --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/custom-modules.md @@ -0,0 +1,133 @@ +--- +title: カスタムモジュール +description: Weaviate でカスタムモジュールを利用してパーソナライズされたデータ管理機能を探求しましょう。 +sidebar_position: 90 +image: og/docs/modules/custom-modules.jpg +# tags: ['modules', 'other modules', 'custom modules'] +--- + + +## 概要 + +標準のベクトル化モデルを使用するだけでなく、独自の機械学習モデルを Weaviate に接続することもできます。これにより、効率的なデータ保存と取得を Weaviate が担うため、ML や NLP モデルを容易にスケールできます。カスタム ベクトライザー モジュールとは、たとえば独自の学習データで学習したモデルで、テキストや画像などのデータを埋め込みへ変換できるものです。 + +既存のモデルアーキテクチャ(例: Transformers)に適合するモデルがすでにある場合は、カスタムコードを書く必要はありません。既存の [`text2vec-transformer` モジュール](/weaviate/model-providers/transformers/embeddings.md)でその Transformer モデルをそのまま実行できます。 + +このページでは、独自の ML モデルを Weaviate にモジュールとして接続する方法を説明します。まず、Weaviate における(ベクトライザー / 埋め込み)モジュールの動作について解説します。 + +クイックリンク: +* 既存の Weaviate Module API を利用して独自の推論コンテナを作成する場合は [こちら](/weaviate/modules/custom-modules.md#a-replace-parts-of-an-existing-module)。 +* GraphQL へのフィールド追加など、完全に新しいモジュールを作成する場合は [こちら](/contributor-guide/weaviate-modules/how-to-build-a-new-module.md)。 + +## 動画: Weaviate でカスタムモジュールを作成する方法 + + + +_Weaviate meetup で収録 – カスタムモジュールの章は 13:30 分から開始_ + +## 背景: Weaviate のモジュールアーキテクチャ + +新しいモジュールを作成するには、まず Weaviate のモジュールシステムがどのように機能するかを理解する必要があります。 + +Weaviate は、モジュールが特定のライフサイクルフックに必要な値をどのように取得するかについては完全にアグノスティックです。たとえばベクトライザー モジュールの場合、Weaviate とモジュール間の契約は次のとおりです。インポート時に各オブジェクトが(設定された)ベクトライザー モジュールへ渡され、モジュールはそれをベクトル(埋め込み)で拡張しなければなりません。Weaviate はモジュールがその処理をどのように行うかを問いません。モジュールが既存の ML モデルを推論に使用する目的であれば、「vectorize」ライフサイクルフックの一環として別の推論サービスを用意し、そのサービスと通信してもかまいません。実際、`text2vec-contextionary` モジュールは推論サービスに gRPC API を使用していますが、`text2vec-transformers` モジュールは同じ目的で REST API を使用しています。 + +一般的に(ベクトライザー)モジュールは 2 つの部分で構成されます: +1. **Weaviate 用のモジュールコード (Go で記述)** + Weaviate のさまざまなライフサイクルにフックし、API 機能などの能力を提供して通常のフローに統合します。 +2. **推論サービス** + 通常はコンテナ化されたアプリケーションで、ML モデルをモジュール固有の API でラップし、パート 1 のモジュールコードから呼び出されます。 + +次の図は、モジュールが Weaviate にどのように接続されているかを示しています。黒枠が Weaviate Database、本体が灰色のボックスです。赤い部分はモジュールをどのように利用するかを示しており、一般的な Module System API を介しています。赤い Module API は 2 つの内部レイヤーにまたがり、GraphQL を拡張したり追加プロパティを提供したりして Weaviate API に影響を与えるほか、ビジネスロジックにも影響を与えます(例: オブジェクトのプロパティを取得してベクトルを設定)。 + +青色の部分は特定モジュールに属します(複数のモジュールを接続できますが、ここでは 1 つの例を示しています)。例として `text2vec-transformers` モジュール `bert-base-uncased` を使用しています。Weaviate Database 内の青いボックスがパート 1 のモジュールコード、外側の青いボックスがパート 2 の推論サービスです。 + +図では 3 つの API を示しています: +* Weaviate Database 内の灰色ボックスはユーザー向けの RESTful と GraphQL API です。 +* 赤いボックスは Go で書かれた Module System API です。 +* 3 つ目の API はモジュールが完全に所有しており、別コンテナとの通信に使用します。この例では左側の Python コンテナです。 + +![Weaviate module APIs overview](/img/contributor-guide/weaviate-modules/weaviate-module-apis.svg "Weaviate module APIs overview") + +独自の ML モデルを Weaviate で使用するには、次の 2 つのオプションがあります([詳細はこちら](#how-to-build-and-use-a-custom-module)): +* A: 既存モジュールの一部を置き換え、推論サービス (パート 2) のみを差し替える。Weaviate Database 本体には手を加えません。 +* B: 完全に新しいモジュールを作成し、既存の青いパート (1 と 2) をすべて置き換える。GraphQL API の拡張など、独自の動作を設定できますが、赤い Module System API にフックするために Go でモジュールコードを書く必要があります。 + + + + +`text2vec-transformers` モジュールを例に、Weaviate で特定のモジュールを使用する設定方法を詳しく見てみましょう。`docker-compose.yml` で `ENABLE_MODULES=text2vec-transformers` を設定すると、Weaviate に該当する Go コード(パート 1)をロードさせます。さらに推論用モデルを含む別サービス(パート 2)も `docker-compose.yml` に追加します。`text2vec-transformers` モジュールの特定の (GraphQL) 機能実装を詳しく見ると以下のようになります。 + +1. **Weaviate 用モジュールコード (Go):** + * Weaviate GraphQL API に `nearText` メソッドを提供することを通知 + * 特定の設定やスキーマを検証し、API で利用できるようにする + * ベクトル(例: 単語や画像の埋め込み)が必要になった際に取得する方法を定義(この例では Python アプリケーションに HTTP リクエストを送信) +2. **推論サービス:** + * モデル推論を提供 + * A と契約した API を実装(Weaviate と直接の契約ではありません) + +これは一例であり、パート 1 が Go で Weaviate と接続し、パート 2 がパート 1 から利用される推論モデルを持つという点さえ満たせば、さまざまなバリエーションが可能です。たとえば、`text2vec-transformers` モジュール(パート 1)を修正し、自前のコンテナではなく Hugging Face API などのサードパーティー推論サービスを使用することもできます。 + +モジュールは依存するコンテナやサービスとの通信方法を完全に制御します。たとえば `text2vec-transformers` モジュールでは推論コンテナとの通信に REST API を使用していますが、`text2vec-contextionary` モジュールでは gRPC を使用しています。 + +### モジュールの特性 + +モジュールは特定のライフサイクルフックに接続して Weaviate を拡張するカスタムコードです。Weaviate が Go で書かれているため、モジュールコードも Go で書く必要があります。ただし既存モジュールの中には独立したサービスを併用しているものもあり、こうしたサービスは任意の言語で実装できます。ベクトライザー モジュールでは推論コンテナが Python で書かれていることがよくあります。 + +モジュールは「ベクトライザー」(データからベクトルの数値を生成する方法を定義)として機能するものや、質問応答やカスタム分類など追加機能を提供するものがあります。モジュールの特性は以下のとおりです。 +- 命名規則 + - ベクトライザー: `2vec--` 例: `text2vec-contextionary`, `img2vec-neural`, `text2vec-transformers` + - その他: `--` + - モジュール名は URL セーフである必要があります。つまり URL エンコードが必要な文字を含めてはいけません。 + - モジュール名は大文字小文字を区別しません。`text2vec-bert` と `text2vec-BERT` は同じモジュールです。 +- モジュール情報は `v1/modules//` RESTful エンドポイントから取得可能です。 +- 一般的なモジュール情報(接続されているモジュール、バージョンなど)は Weaviate の [`v1/meta` エンドポイント](/weaviate/api) で取得できます。 +- モジュールは RESTful API の `additional` プロパティおよび GraphQL API の [`_additional` プロパティ](/weaviate/api/graphql/additional-properties.md) を追加できます。 +- モジュールは GraphQL クエリで [フィルター](/weaviate/api/graphql/filters.md) を追加できます。 +- どのベクトライザーやその他モジュールをどのデータクラスに適用するかは、[コレクション設定](../manage-collections/vector-config.mdx) で指定します。 + +## カスタムモジュールを構築して使用する方法 + +Weaviate をカスタムベクトル化機能で拡張する方法は 2 つあります。完全に新しいモジュール(パート 1 + 2)を構築するか、既存モジュールの推論サービス(パート 2)のみを置き換えるか(オプション A)です。後者は迅速なプロトタイプや PoC に適しています。この場合、推論モデル(パート 2)だけを差し替え、Weaviate とやり取りする Go 製インターフェースはそのまま再利用します。まったく異なるモデルタイプを素早く統合できる方法です。オプション B の完全新規モジュールは最も柔軟ですが、Weaviate インターフェースを Go で書く必要があります。まずはオプション A で結果を確認し、PoC が満足できるものになったらオプション B で正式なモジュールに移行することを推奨します。 + +### A. 既存モジュールの一部を置き換える + +まったく異なる推論モデルを統合する最短経路は、既存モジュールの一部を置き換える方法です。パート 1(Weaviate とのインターフェース)は再利用し、その API 契約に従いながらパート 2 だけを変更または置き換えます。 + +Go で書かれた Weaviate インターフェースコードに手を加えないため、パート 1 に存在しないモジュール固有の新しい設定を Weaviate の API に導入することはできません。また、新しい(GraphQL)API 関数やフィルターを追加・変更することもできません。 +_なお、Weaviate の API は安定性を保証するものではありません。互換性を損なわない Weaviate のリリースでも「内部」API は変更される可能性があります。_ + +既存の Weaviate インターフェース(パート 1)で新しい推論モデル(パート 2)を使用するには、既存モジュールの Go コードをすべて再利用し、別の推論コンテナを指すように設定するだけです。`text2vec-transformers` モジュールを例に、カスタム推論モジュールを使用する手順は次のとおりです。 +1. Transformers を利用するように設定された有効な `docker-compose.yml`([設定コンフィギュレーター](/deploy/installation-guides/docker-installation.md#configurator)で作成可能)を開くと、`TRANSFORMERS_INFERENCE_API: 'http://text2vec-transformers:8080'` のような環境変数があります。これを任意のアプリへ向けるだけです。変数名 `TRANSFORMERS_INFERENCE_API` はそのまま残してください。 +2. モデルをラップする小さな HTTP API を構築します。最低限、以下のエンドポイントを実装してください(この例は `text2vec-transformers` モジュール固有であり、完全にモジュール側の制御となります)。 + 1. `GET /.well-known/live` -> アプリが動作中なら `204` を返す + 2. `GET /.well-known/ready` -> サービス開始可能なら `204` を返す + 3. `GET /meta` -> 推論モデルのメタ情報を返す + 4. `POST /vectors` -> 以下のリクエスト / レスポンス例を参照(この例では Docker Compose で `ports: ["8090:8080"]` を追加し、ローカルの 8090 番ポートで公開しています) + +リクエスト: +```bash +curl localhost:8090/vectors/ -H "Content-Type: application/json" -d '{"text":"hello world"}' +``` +レスポンス: +```bash +{"text":"hello world","vector":[-0.08469954133033752,0.4564870595932007, ..., 0.14153483510017395],"dim":384} +``` + +### B. 完全に新しいモジュールを構築する + +パート 1 と 2 の両方を含む完全新規モジュールを実装すると、命名、API、動作などを自在に制御できます。この場合は実質的に Weaviate へ貢献する形になります。Weaviate のアーキテクチャや、モジュールが制御できる範囲(「固定」されている部分)を理解する必要があります。[Weaviate のリポジトリ](https://github.com/weaviate/weaviate) をフォークし、その中に完全新規の [module](https://github.com/weaviate/weaviate/tree/master/modules) を作成可能です。この新モジュールは複数のコンテナに依存させることもでき、依存先との通信に任意の API を使用できます(依存先がない場合も可)。 + +詳細手順は [コントリビューターガイド](/contributor-guide/weaviate-modules/how-to-build-a-new-module) に記載しています。 + +Weaviate の Go インターフェースを含む完全新規モジュールを構築する場合は、[フォーラム](https://forum.weaviate.io) または [GitHub Issue](https://github.com/weaviate/weaviate/issues) でご連絡ください。開始時のサポートを行います。 + +## 重要な注意点 +- ベクトライザーが生成するベクトルの長さは後の利用に影響します。たとえば GraphQL の explore フィルターでデータをベクトル探索する場合、クエリに渡すベクトルの長さはデータポイントのベクトル長と一致している必要があります。 +- モジュール内部で使用される Weaviate の API は安定性を保証するものではありません。互換性を損なわないリリースでも「内部」API は変更される可能性があります。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/data2vec-c11y.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/data2vec-c11y.svg new file mode 100644 index 000000000..f304f917f --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/data2vec-c11y.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/vectors-3d-dataobject.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/vectors-3d-dataobject.svg new file mode 100644 index 000000000..ae8e6b839 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/vectors-3d-dataobject.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/vectors-3d.svg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/vectors-3d.svg new file mode 100644 index 000000000..ac8290579 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img/vectors-3d.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img2vec-neural.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img2vec-neural.md new file mode 100644 index 000000000..eb1f34bde --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/img2vec-neural.md @@ -0,0 +1,218 @@ +--- +title: ResNet 画像 ベクトライザー +sidebar_position: 20 +image: og/docs/modules/img2vec-neural.jpg +# tags: ['img2vec', 'img2vec-neural'] +--- + +:::caution 新規プロジェクトには CLIP を推奨 +新規プロジェクトでは `img2vec-neural` の代わりに [Transformers マルチモーダル統合](../model-providers/transformers/embeddings-multimodal.md) モジュールの利用を推奨します。これは CLIP モデルを使用しており、`img2vec-neural` が使用する `resnet` モデルよりもモダンなアーキテクチャです。さらに CLIP モデルはマルチモーダルで、画像とテキストの両方を扱えるため、より広いユースケースに適用できます。 +::: + +`img2vec-neural` モジュールを使用すると、 Weaviate は [`resnet50`](https://arxiv.org/abs/1512.03385) モデルを用いてローカルで画像からベクトルを取得できます。 + +`img2vec-neural` はモデルを Docker コンテナにカプセル化しており、 GPU 対応ハードウェア上で独立してスケールさせつつ、 CPU 最適化された Weaviate を CPU のみのハードウェア上で動かすことが可能です。 + +Key notes: + +- このモジュールは Weaviate Cloud (WCD) では利用できません。 +- 本モジュールを有効にすると [`nearImage` 検索オペレーター](#additional-search-operator) が利用可能になります。 +- モデルは Docker コンテナにカプセル化されています。 +- 本モジュールは Auto-schema と互換性がありません。 [以下](#class-configuration) のとおりクラスを手動で定義する必要があります。 + + +## Weaviate インスタンス設定 + +:::info WCD には適用されません +このモジュールは Weaviate Cloud では利用できません。 +::: + +### Docker Compose ファイル + +`img2vec-neural` を使用するには、 Docker Compose ファイル (例: `docker-compose.yml`) で本モジュールを有効にする必要があります。 + +:::tip 設定ツールの利用を推奨 +手動で記述することも可能ですが、 [Weaviate 設定ツール](/deploy/installation-guides/docker-installation.md#configurator) を使って `Docker Compose` ファイルを生成することを推奨します。 +::: + +#### パラメーター + +Weaviate: + +- `ENABLE_MODULES` (Required): 有効化するモジュールを指定します。 `img2vec-neural` を含めてください。 +- `DEFAULT_VECTORIZER_MODULE` (Optional): 既定のベクトライザーモジュールを指定します。すべてのクラスで `img2vec-neural` を既定にする場合に設定します。 +- `IMAGE_INFERENCE_API` (Required): 推論コンテナの URL。 + +推論コンテナ: + +- `image` (Required): 推論コンテナのイメージ名 (例: `semitechnologies/img2vec-pytorch:resnet50` または `semitechnologies/img2vec-keras:resnet50`)。 + +#### 例 + +この設定例では `img2vec-neural` を有効にし、既定のベクトライザーに設定し、 Docker コンテナの各種パラメーターを指定しています。ここでは `img2vec-pytorch:resnet50` イメージを使用しています。 + +```yaml +services: + weaviate: + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + restart: on-failure:0 + ports: + - 8080:8080 + - 50051:50051 + environment: + QUERY_DEFAULTS_LIMIT: 20 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: "./data" + # highlight-start + ENABLE_MODULES: 'img2vec-neural' + IMAGE_INFERENCE_API: "http://i2v-neural:8080" + # highlight-end + CLUSTER_HOSTNAME: 'node1' +# highlight-start + i2v-neural: + image: cr.weaviate.io/semitechnologies/img2vec-pytorch:resnet50 +# highlight-end +... +``` + +### 代替案: 別コンテナの実行 + +代替として、推論コンテナを Weaviate とは別に起動することも可能です。手順は以下のとおりです。 + +- Docker Compose ファイルで `img2vec-neural` を有効化する +- `img2vec-neural` 固有のパラメーターを省略する +- 推論コンテナを Docker などで個別に起動する +- `IMAGE_INFERENCE_API` に推論コンテナの URL を設定する + +たとえば Weaviate を Docker 外で動かしている場合は、 `IMAGE_INFERENCE_API="http://localhost:8000"` と設定します。 Weaviate と推論コンテナが同じ Docker ネットワークに属している場合 (同じ `docker-compose.yml` に記述されているなど) は、 `IMAGE_INFERENCE_API=http://i2v-neural:8080` のように Docker の DNS 名を利用できます。 + +推論コンテナを起動する例: + +```shell +docker run -itp "8000:8080" semitechnologies/img2vec-neural:resnet50-61dcbf8 +``` + + +## クラス設定 + +各クラスでのモジュール挙動は [コレクション設定](../manage-collections/vector-config.mdx) で調整できます。 + +### ベクトル化設定 + +クラスおよびプロパティの `moduleConfig` セクションでベクトライザーの挙動を設定します。 + +#### クラスレベル + +- `vectorizer` - データをベクトル化する際に使用するモジュール +- `imageFields` - ベクトル化対象となる画像プロパティ名 + +#### プロパティレベル + +- `dataType` - プロパティのデータ型。 `imageFields` で使用する場合は `blob` に設定する必要があります。 + +#### 例 + +以下のクラス定義では、 `FashionItem` クラスの `vectorizer` として `img2vec-neural` を設定し、 + +- `image` プロパティを `blob` 型かつ画像フィールドとして指定しています。 + +```json +{ + "classes": [ + { + "class": "FashionItem", + "description": "Each example is a 28x28 grayscale image, associated with a label from 10 classes.", + // highlight-start + "vectorizer": "img2vec-neural", + "moduleConfig": { + "img2vec-neural": { + "imageFields": [ + "image" + ] + } + }, + // highlight-end + "properties": [ + // highlight-start + { + "dataType": [ + "blob" + ], + "description": "Grayscale image", + "name": "image" + }, + // highlight-end + { + "dataType": [ + "number" + ], + "description": "Label number for the given image.", + "name": "labelNumber" + }, + { + "dataType": [ + "text" + ], + "description": "label name (description) of the given image.", + "name": "labelName" + } + ], + } + ] +} +``` + +:::note すべての `blob` プロパティは base64 エンコードされたデータである必要があります。 +::: + + +### `blob` データオブジェクトの追加 + +`blob` 型のデータはすべて base64 エンコードする必要があります。画像の base64 文字列を取得するには、 Weaviate クライアントのヘルパーメソッドを使うか、次のコマンドを実行してください。 + +```bash +cat my_image.png | base64 +``` + +## 追加の検索オペレーター + +`img2vec-neural` ベクトライザーモジュールを有効にすると `nearImage` 検索オペレーターが利用可能になります。 + +## 使用例 + +### NearImage + +import CodeNearImage from '/_includes/code/img2vec-neural.nearimage.mdx'; + + + +## モデルについて + +[`resnet50`](https://arxiv.org/abs/1512.03385) は、 residual 畳み込みニューラルネットワークで、 2,550 万個のパラメーターを持ち、 [ImageNet データベース](https://www.image-net.org/) の 100 万枚以上の画像で学習されています。名前が示すとおり合計 50 層で構成され、 48 の畳み込み層、 1 つの MaxPool 層、 1 つの Average Pool 層からなります。 + + + +### 利用可能な img2vec-neural モデル + +選択できる推論モデルは 2 種類あります。マシンが `arm64` かその他か、また特徴 ベクトル 抽出にマルチスレッドを使用するかどうかに応じて、`keras` と `pytorch` から選択できます。両モデルの違いはそれ以外にはありません。 +- `resnet50` (`keras`): + - `amd64` をサポートし、`arm64` はサポートしません。 + - 現在 `CUDA` をサポートしていません + - マルチスレッド推論をサポートします +- `resnet50` (`pytorch`): + - `amd64` と `arm64` の両方をサポートします。 + - `CUDA` をサポートします + - マルチスレッド推論はサポートしません + +## モデルライセンス + +`img2vec-neural` モジュールは `resnet50` モデルを使用しています。 + +ライセンス条件がご利用目的に適しているかどうかを評価する責任は利用者にあります。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/index.md new file mode 100644 index 000000000..01535d295 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/index.md @@ -0,0 +1,139 @@ +--- +title: リファレンス - モジュール +description: Weaviate のモジュールについて学び、機能を拡張しましょう。 +sidebar_position: 0 +image: og/docs/modules/_title.jpg +# tags: ['modules'] +--- + +このセクションでは、 Weaviate の個別モジュールの機能と使用方法について説明します。 + +:::tip ベクトライザー、生成 AI、またはリランカーの連携ドキュメントをお探しですか? +それらは、よりユーザー中心の内容となる [モデルプロバイダー連携](../model-providers/index.md) セクションへ移動しました。 +::: + +## 一般 + + Weaviate のモジュールはコードベースに組み込まれており、[環境変数で有効化](../configuration/modules.md) して追加機能を提供します。 + +### モジュールの種類 + + Weaviate のモジュールは、次のカテゴリに分類できます。 + +- [ベクトライザー](#vectorizer-reranker-and-generative-ai-integrations): データをベクトル埋め込みへ変換し、インポートやベクトル検索に利用します。 +- [リランカー](#vectorizer-reranker-and-generative-ai-integrations): 初期検索結果を並べ替えて検索精度を向上させます。 +- [生成 AI](#vectorizer-reranker-and-generative-ai-integrations): 検索拡張生成 (RAG) 用に生成 AI モデルを統合します。 +- [バックアップ](#backup-modules): Weaviate でのバックアップおよびリストア操作を支援します。 +- [オフロード](#offloading-modules): テナントデータを外部ストレージへオフロードします。 +- [その他]: 追加機能を提供するモジュールです。 + +#### ベクトライザー、リランカー、および生成 AI 連携 + +これらのモジュールについては、[モデルプロバイダー連携](../model-providers/index.md) ドキュメントをご覧ください。ページはモデルプロバイダー (例: Hugging Face、OpenAI) 別に、その後モデルタイプ (例: ベクトライザー、リランカー、生成 AI) 別に整理されています。 + +例: + +- [OpenAI 埋め込み連携ページ](../model-providers/openai/embeddings.md) では、 OpenAI の埋め込みモデルを Weaviate で利用する方法を解説しています。 + +埋め込み連携のイラスト +
+ +- [Cohere リランカー連携ページ](../model-providers/cohere/reranker.md) では、 Cohere のリランカーモデルを Weaviate で利用する方法を解説しています。 + +リランカー連携のイラスト +
+ +- [Anthropic 生成 AI 連携ページ](../model-providers/anthropic/generative.md) では、 Anthropic の生成 AI モデルを Weaviate で利用する方法を解説しています。 + +生成 AI 連携のイラスト +
+ +### モジュールの特性 + +- 命名規則 + - ベクトライザー (Retriever モジュール): `2vec--` 例: `text2vec-contextionary`, `img2vec-neural`, `text2vec-transformers` + - その他のモジュール: `--` 例: `qna-transformers` + - モジュール名は URL セーフでなければなりません。つまり、 URL エンコードが必要な文字を含めてはいけません。 + - モジュール名は大文字小文字を区別しません。`text2vec-bert` と `text2vec-BERT` は同一モジュールです。 +- モジュール情報へは `v1/modules//` RESTful エンドポイントでアクセスできます。 +- 一般的なモジュール情報 (添付済みモジュール、バージョンなど) には、 Weaviate の [`v1/meta` エンドポイント](/deploy/configuration/meta.md) からアクセスできます。 +- モジュールは RESTful API の `additional` プロパティおよび [GraphQL API の `_additional` プロパティ](../api/graphql/additional-properties.md) を追加できます。 +- モジュールは GraphQL クエリに [フィルター](../api/graphql/filters.md) を追加できます。 +- どのベクトライザーやその他モジュールをどのデータコレクションに適用するかは、[スキーマ](../manage-collections/vector-config.mdx#specify-a-vectorizer) で設定します。 + +## バックアップ モジュール + + Weaviate におけるバックアップおよびリストア操作は、バックアッププロバイダーモジュールによって実現されます。 + +これらは内部または外部のいずれかに存在する交換可能なストレージバックエンドです。 + +### 外部プロバイダー + +外部バックアッププロバイダーは、外部ストレージサービスと連携して Weaviate データのバックアップの保存および取得を行います。 + +バックアップデータを Weaviate インスタンスの外部に保存することで、バックアップの可用性がインスタンス自身から切り離されるため、本番環境に最適です。ノードが到達不能になった場合でもバックアップは利用可能です。 + +さらに、マルチノードの Weaviate クラスターでは外部プロバイダーの使用が _必須_ です。マルチノードバックアップを単一ノードの内部に保存すると、耐久性と可用性が大幅に低下するなどの問題があるためサポートされていません。 + +サポートされている外部バックアッププロバイダーは次のとおりです。 +- [S3](/deploy/configuration/backups.md#s3-aws-or-s3-compatible) +- [GCS](/deploy/configuration/backups.md#gcs-google-cloud-storage) +- [Azure](/deploy/configuration/backups.md#azure-storage) + +モジュールシステムの拡張性により、新しいプロバイダーも容易に追加できます。上記以外の外部プロバイダーにご興味がある場合は、ぜひ [フォーラム](https://forum.weaviate.io/) でご相談いただくか、[GitHub](https://github.com/weaviate/weaviate) に issue をお寄せください。 + +### 内部プロバイダー + +内部プロバイダーは、 Weaviate インスタンス内でバックアップデータの保存および取得を行います。このタイプは開発や実験用途向けであり、本番環境での使用は推奨されません。内部プロバイダーはマルチノードバックアップには対応しておらず、マルチノード環境では外部プロバイダーが必要です。 + + Weaviate `v1.16` 現在、サポートされている内部バックアッププロバイダーは [filesystem](/deploy/configuration/backups.md#filesystem) のみです。 + +## オフロード モジュール + +:::info `v1.26` で追加 +::: + +オフロードモジュールは、テナントデータを外部ストレージへオフロードする機能を提供します。これにより、リソースとコストの管理が容易になります。 + +設定方法の詳細は [設定方法: オフロード](/deploy/configuration/tenant-offloading.md) をご覧ください。 + +## その他のモジュール + +上記に加えて、次のようなモジュールがあります。 + +- [qna-transformers](./qna-transformers.md): transformers モデルを使用した質問応答 (回答抽出) 機能 +- [qna-openai](./qna-openai.md): OpenAI モデルを使用した質問応答 (回答抽出) 機能 +- [ner-transformers](./ner-transformers.md): transformers モデルを使用した固有表現抽出機能 +- [text-spellcheck](./ner-transformers.md): GraphQL クエリのスペルチェック機能 +- [sum-transformers](./sum-transformers.md): transformer モデルを使用してテキストを要約 +- [usage-modules](./usage-modules.md): 請求用途の使用状況分析を収集し、 GCS または S3 にアップロード + +## 関連ページ + +- [設定:モジュール](../configuration/modules.md) +- [概念:モジュール](../concepts/modules.md) + +## その他のサードパーティ統合 + +import IntegrationLinkBack from '/_includes/integrations/link-back.mdx'; + + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/model_providers.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/model_providers.md new file mode 100644 index 000000000..d507ee836 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/model_providers.md @@ -0,0 +1,13 @@ +--- +title: モデルプロバイダー統合 +sidebar_position: 0 +image: og/docs/modules/_title.jpg +# tags: ['modules'] +--- + +ベクトライザー、生成 AI、またはリランカー統合のドキュメントをお探しですか? + + Weaviate を Anthropic、AWS、Cohere、Hugging Face、Ollama、OpenAI などの一般的なモデルプロバイダーと組み合わせて使用する方法のドキュメントは、[Anthropic](../model-providers/anthropic/index.md)、[AWS](../model-providers/aws/index.md)、[Cohere](../model-providers/cohere/index.md)、[Hugging Face](../model-providers/huggingface/index.md)、[Ollama](../model-providers/ollama/index.md)、[OpenAI](../model-providers/openai/index.md) でご覧いただけます。 + +これらは、よりユーザー中心で焦点を絞った形で紹介する「[モデルプロバイダー統合](../model-providers/index.md)」セクションへ移動しました。 + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/ner-transformers.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/ner-transformers.md new file mode 100644 index 000000000..e0e35a360 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/ner-transformers.md @@ -0,0 +1,194 @@ +--- +title: 固有表現認識 +description: Weaviate で NER Transformers を統合し、テキスト内のエンティティを識別・分類します。 +sidebar_position: 60 +image: og/docs/modules/ner-transformers.jpg +# tags: ['ner-transformers', 'transformers', 'token classification'] +--- + +## 概要 + +* Named Entity Recognition(NER)モジュールは、トークン分類用の Weaviate モジュールです。 +* 本モジュールは Weaviate と共に稼働する NER Transformers モデルに依存します。あらかじめビルド済みのモデルも利用できますが、別の HuggingFace Transformer や独自の NER モデルを接続することも可能です。 +* GraphQL の `_additional {}` フィールドに `tokens {}` フィルターが追加されます。 +* モジュールはデータオブジェクトを通常どおり返し、その中で認識されたトークンは GraphQL の `_additional { tokens {} }` フィールドに含まれます。 + +## はじめに + +Named Entity Recognition(NER)モジュールは、既存の Weaviate テキストオブジェクトからエンティティをオンザフライで抽出するためのモジュールです。エンティティ抽出はクエリー時に実行されます。最高のパフォーマンスを得るには、Transformer ベースのモデルを GPU で実行することを推奨します。CPU でも動作しますが、スループットは低下します。 + +現在、以下の 3 種類の NER モジュールが利用可能です([Hugging Face](https://huggingface.co/) より): [`dbmdz-bert-large-cased-finetuned-conll03-english`](https://huggingface.co/dbmdz/bert-large-cased-finetuned-conll03-english)、[`dslim-bert-base-NER`](https://huggingface.co/dslim/bert-base-NER)、[`davlan-bert-base-multilingual-cased-ner-hrl`](https://huggingface.co/Davlan/bert-base-multilingual-cased-ner-hrl?text=%D8%A5%D8%B3%D9%85%D9%8A+%D8%B3%D8%A7%D9%85%D9%8A+%D9%88%D8%A3%D8%B3%D9%83%D9%86+%D9%81%D9%8A+%D8%A7%D9%84%D9%82%D8%AF%D8%B3+%D9%81%D9%8A+%D9%81%D9%84%D8%B3%D8%B7%D9%8A%D9%86.). + +## 有効化方法(モジュール設定) + +### Docker Compose + +NER モジュールは Docker Compose ファイルにサービスとして追加できます。`text2vec-contextionary` や `text2vec-transformers` のようなテキスト ベクトライザーが稼働している必要があります。以下は、`text2vec-contextionary` と組み合わせて `ner-transformers` モジュール(`dbmdz-bert-large-cased-finetuned-conll03-english`)を使用するための Docker Compose ファイル例です。 + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + CONTEXTIONARY_URL: contextionary:9999 + NER_INFERENCE_API: "http://ner-transformers:8080" + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'text2vec-contextionary,ner-transformers' + CLUSTER_HOSTNAME: 'node1' + contextionary: + environment: + OCCURRENCE_WEIGHT_LINEAR_FACTOR: 0.75 + EXTENSIONS_STORAGE_MODE: weaviate + EXTENSIONS_STORAGE_ORIGIN: http://weaviate:8080 + NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE: 5 + ENABLE_COMPOUND_SPLITTING: 'false' + image: cr.weaviate.io/semitechnologies/contextionary:en0.16.0-v1.0.2 + ports: + - 9999:9999 + ner-transformers: + image: cr.weaviate.io/semitechnologies/ner-transformers:dbmdz-bert-large-cased-finetuned-conll03-english +... +``` + +変数の説明: +* `NER_INFERENCE_API`: qna モジュールが稼働している場所を指定します。 + +## 使用方法(GraphQL) + +モジュールの機能を利用するには、クエリーに次の `_additional` プロパティを追加するだけです。 + +### GraphQL トークン + +このモジュールは、GraphQL の `_additional` フィールドに `token{}` 検索フィルターを追加します。新しいフィルターは次の引数を取ります。 + +| 項目 | データタイプ | 必須 | 例 | 説明 | +|- |- |- |- |- | +| `properties` | list of strings | yes | `["summary"]` | クエリー対象クラスでテキスト(`text` または `string` 型)を含むプロパティ。少なくとも 1 つは指定する必要があります。 | +| `certainty` | float | no | `0.75` | 認識されたトークンが満たすべき最小確信度。値が高いほど分類は厳密になります。設定しない場合、モデルが検出したすべてのトークンが返されます。 | +| `limit` | int | no | `1` | データオブジェクトごとに返されるトークンの最大数。 | + +### クエリ例 + +import CodeNerTransformer from '/_includes/code/ner-transformers-module.mdx'; + + + +### GraphQL レスポンス + +レスポンスは新しい GraphQL `_additional` プロパティ `tokens` に含まれ、トークンのリストを返します。各トークンには以下のフィールドがあります: +* `entity` (`string`): エンティティグループ(分類されたトークン) +* `word` (`string`): エンティティとして認識された語 +* `property` (`string`): トークンが見つかったプロパティ +* `certainty` (`float`): トークンが正しく分類された確信度(0.0–1.0) +* `startPosition` (`int`): プロパティ値内で単語の最初の文字がある位置 +* `endPosition` (`int`): プロパティ値内で単語の最後の文字がある位置 + +### レスポンス例 + +```json +{ + "data": { + "Get": { + "Article": [ + { + "_additional": { + "tokens": [ + { + "property": "title", + "entity": "PER", + "certainty": 0.9894614815711975, + "word": "Sarah", + "startPosition": 11, + "endPosition": 16 + }, + { + "property": "title", + "entity": "LOC", + "certainty": 0.7529033422470093, + "word": "London", + "startPosition": 31, + "endPosition": 37 + } + ] + }, + "title": "My name is Sarah and I live in London" + } + ] + } + }, + "errors": null +} +``` + +## HuggingFace の別 NER Transformer モジュールの使用 + +2 行だけの Dockerfile で、[Hugging Face model hub](https://huggingface.co/models) にある任意のモデルをサポートする Docker イメージを作成できます。以下の例では、[`Davlan/bert-base-multilingual-cased-ner-hrl` モデル](https://huggingface.co/Davlan/bert-base-multilingual-cased-ner-hrl) 用のカスタムイメージをビルドします。 + +#### ステップ 1: `Dockerfile` の作成 +新しい `Dockerfile` を作成します。ここでは `my-model.Dockerfile` という名前にし、次の行を追加します。 +``` +FROM semitechnologies/ner-transformers:custom +RUN chmod +x ./download.py +RUN MODEL_NAME=Davlan/bert-base-multilingual-cased-ner-hrl ./download.py +``` + +#### ステップ 2: Dockerfile をビルドしてタグ付けする +Dockerfile に `davlan-bert-base-multilingual-cased-ner-hrl` というタグを付けてビルドします。 +``` +docker build -f my-model.Dockerfile -t davlan-bert-base-multilingual-cased-ner-hrl . +``` + +#### ステップ 3: 完了! +イメージを任意のレジストリにプッシュするか、`docker-compose.yml` 内で Docker タグ `davlan-bert-base-multilingual-cased-ner-hrl` を使ってローカル参照できます。 + +## 仕組み(内部動作) + +このリポジトリのアプリケーションコードは、`My name is Sarah and I live in London` のようなテキスト入力を受け取り、次のような JSON 形式で情報を返すモデルと互換性があります。 + +```json +[ + { + "entity_group": "PER", + "score": 0.9985478520393372, + "word": "Sarah", + "start": 11, + "end": 16 + }, + { + "entity_group": "LOC", + "score": 0.999621570110321, + "word": "London", + "start": 31, + "end": 37 + } +] +``` + +Weaviate NER モジュールはこの出力を受け取り、GraphQL 出力に変換します。 + +## モデルのライセンス + +`ner-transformers` モジュールは複数のモデルと互換性があり、それぞれに独自のライセンスがあります。詳しくは、使用するモデルのライセンスを [Hugging Face Model Hub](https://huggingface.co/models) でご確認ください。 + +ライセンス条件がご自身の用途に適しているかどうかは、利用者ご自身でご判断ください。 + +## ご質問・フィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/qna-openai.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/qna-openai.md new file mode 100644 index 000000000..7bf86883d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/qna-openai.md @@ -0,0 +1,255 @@ +--- +title: 質問応答 - OpenAI +sidebar_position: 41 +image: og/docs/modules/qna-openai.jpg +# tags: ['qna', 'qna-openai', 'transformers', 'openai'] +--- + +:::caution 新しいプロジェクトには OpenAI 生成統合がおすすめです +現在、 `qna-openai` は保守されておらず、 `gpt-3.5-turbo-instruct` などの古いモデルを使用しています。新しいプロジェクトでは、 `qna-openai` の代わりに [OpenAI 生成統合](../model-providers/openai/generative.md) を使用することをおすすめします。 + +さらに、この生成統合は汎用性が高く、質問応答に限定されない幅広いユースケースで利用できます。 `gpt-3.5-turbo-instruct` は必ずしも質問応答専用に学習されているわけではないため、 `qna-openai` が最適となるケースは限られています。 +::: + + +## 概要 + +* OpenAI Question and Answer (Q&A) モジュールは、 OpenAI [completions endpoint](https://platform.openai.com/docs/api-reference/completions) または Azure OpenAI 相当のエンドポイントを通じてデータから回答を抽出するための Weaviate モジュールです。 +* このモジュールは、 Weaviate と共に稼働しているテキスト ベクトライザー モジュールに依存します。 +* GraphQL の `Get {}` クエリに `ask {}` オペレーターを追加します。 +* GraphQL の `_additional {}` フィールドに最大 1 件の回答を返します。 +* 最も高い `certainty` (信頼度)の回答が返されます。 +* Weaviate `v1.16.6` で追加されました。 + +import OpenAIOrAzureOpenAI from '/_includes/openai.or.azure.openai.mdx'; + + + +## はじめに + +Question and Answer (Q&A) OpenAI モジュールは、データから回答を抽出するための Weaviate モジュールです。最も関連性の高いドキュメントから回答を抽出するために、 OpenAI の completions エンドポイントを使用します。 + +このモジュールは、 GraphQL の `Get{...}` クエリで検索オペレーターとして使用できます。 `qna-openai` モジュールは、指定されたクラスのデータオブジェクトから回答を探します。指定した `certainty` 範囲内で回答が見つかった場合、 GraphQL の `_additional { answer { ... } }` フィールドに返されます。回答は最大 1 件で、(オプションで設定した) `certainty` を上回っている場合のみ返されます。最も高い `certainty` (信頼度)を持つ回答が返されます。 + +## 推論 API キー + +`qna-openai` を利用するには、 OpenAI または Azure OpenAI の API キーが必要です。 + +:::tip +使用するサービス(OpenAI または Azure OpenAI)に応じて、いずれか一方のキーを用意すれば十分です。 +::: + +## 組織名 + +:::info `v1.21.1` で追加 +::: + +OpenAI の組織名が必要なリクエストでは、クエリ時に HTTP ヘッダーへ次のように追加できます。 +- `"X-OpenAI-Organization": "YOUR-OPENAI-ORGANIZATION"` (OpenAI) + +### Weaviate へのキー提供 + +API キーは次の 2 つの方法で設定できます。 + +1. **構成時** — Docker インスタンスの設定中に、`Docker Compose` ファイルの `environment` セクションへ `OPENAI_APIKEY` または `AZURE_APIKEY`(サービスに応じて)を追加します。例: + + ```yaml + environment: + OPENAI_APIKEY: 'your-key-goes-here' # For use with OpenAI. Setting this parameter is optional; you can also provide the key at runtime. + AZURE_APIKEY: 'your-key-goes-here' # For use with Azure OpenAI. Setting this parameter is optional; you can also provide the key at runtime. + ... + ``` + +2. **実行時**(推奨) — リクエストヘッダーに `"X-OpenAI-Api-Key"` または `"X-Azure-Api-Key"` を指定します。Weaviate クライアントを使用する場合の例: + +import ClientKey from '/_includes/code/core.client.openai.apikey.mdx'; + + + +## モジュール設定 + +:::tip +Weaviate Cloud (WCD) をご利用の場合、このモジュールはすでに有効化・設定済みです。WCD では設定を編集できません。 +::: + +### Docker Compose ファイル (Weaviate Database のみ) + +`docker-compose.yml` などの Docker Compose ファイルで OpenAI Q&A モジュールを有効にできます。`ENABLE_MODULES` プロパティに `qna-openai`(および必要な他のモジュール)を追加します。 + +``` +ENABLE_MODULES: 'text2vec-openai,qna-openai' +``` + +以下は、`qna-openai` モジュールと `text2vec-openai` を組み合わせて使用する完全な Docker 構成例です。 + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: + cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'text2vec-openai,qna-openai' + OPENAI_APIKEY: sk-foobar # For use with OpenAI. Setting this parameter is optional; you can also provide the key at runtime. + OPENAI_ORGANIZATION: your-orgname # For use with OpenAI. Setting this parameter is optional; you can also provide the key at runtime. + AZURE_APIKEY: sk-foobar # For use with Azure OpenAI. Setting this parameter is optional; you can also provide the key at runtime. + CLUSTER_HOSTNAME: 'node1' +``` + +## スキーマ設定 + +### OpenAI と Azure OpenAI の違い + +- **OpenAI** を利用する場合、`model` パラメーターは任意です。 +- **Azure OpenAI** を利用する場合、`resourceName` と `deploymentId` の設定が必須です。 + +### モデルパラメーター + +下記のパラメーターを通じて、モデルの追加設定も行えます。 + +### スキーマ例 + +次のスキーマ設定では、`Document` クラスで `qna-openai` モデルを使用します。 + +この設定では `gpt-3.5-turbo-instruct` モデルを指定しています。 + +```json +{ + "classes": [ + { + "class": "Document", + "description": "A class called document", + "vectorizer": "text2vec-openai", + "moduleConfig": { + "qna-openai": { + "model": "gpt-3.5-turbo-instruct", // For OpenAI + "resourceName": "", // For Azure OpenAI + "deploymentId": "", // For Azure OpenAI + "maxTokens": 16, // Applicable to both OpenAI and Azure OpenAI + "temperature": 0.0, // Applicable to both OpenAI and Azure OpenAI + "topP": 1, // Applicable to both OpenAI and Azure OpenAI + "frequencyPenalty": 0.0, // Applicable to both OpenAI and Azure OpenAI + "presencePenalty": 0.0 // Applicable to both OpenAI and Azure OpenAI + } + }, + "properties": [ + { + "dataType": [ + "text" + ], + "description": "Content that will be vectorized", + "name": "content" + } + ] + } + ] +} +``` + +個々のパラメーターの使い方については [こちら](https://platform.openai.com/docs/api-reference/completions) を参照してください。 + +## 使い方 + +このモジュールは、 GraphQL の `Get{...}` クエリに `ask{}` という検索オペレーターを追加します。`ask{}` は以下の引数を受け取ります。 + +| フィールド | データ型 | 必須 | 例 | 説明 | +|- |- |- |- |- | +| `question` | string | yes | `"What is the name of the Dutch king?"` | 回答を求める質問。 | +| `properties` | list of strings | no | `["summary"]` | テキストを含むクラスのプロパティ。未指定の場合、すべてのプロパティが対象。 | + +注意: + +* GraphQL の `Explore { }` でも `ask` サーチャーは使えますが、結果は回答を含むオブジェクトへのビーコンのみです。そのため、質問で `nearText` セマンティック検索を行うのと実質的に同じで、抽出は行われません。 +* `'ask'` オペレーターは `'neaXXX'` 系オペレーターと同時に使用できません。 + +### クエリ例 + +import CodeQNAOpenAIAsk from '/_includes/code/qna-openai.ask.mdx'; + + + + + +### GraphQL レスポンス + +回答は、新しい GraphQL の `_additional` プロパティ `answer` に含まれます。`answer` には次のフィールドがあります。 + +* `hasAnswer` (`boolean`): 回答を見つけられたかどうか +* `result` (nullable `string`): 回答が見つかった場合の回答。`hasAnswer==false` の場合は `null` +* `property` (nullable `string`): 回答を含むプロパティ。`hasAnswer==false` の場合は `null` +* `startPosition` (`int`): 回答が始まる文字オフセット。`hasAnswer==false` の場合は `0` +* `endPosition` (`int`): 回答が終わる文字オフセット。`hasAnswer==false` の場合は `0` + +注: レスポンスの `startPosition`、`endPosition`、`property` は常に存在するとは限りません。これらは入力テキストに対して大文字小文字を無視した文字列一致関数で計算されます。もしトランスフォーマーモデルが出力を異なる形式で返した場合 (例: 元の入力にはなかったトークン間にスペースを挿入するなど)、位置計算やプロパティの特定に失敗します。 + +### レスポンス例 + +```json +{ + "data": { + "Get": { + "Document": [ + { + "_additional": { + "answer": { + "hasAnswer": true, + "result": " Stanley Kubrick is an American filmmaker who is best known for his films, including \"A Clockwork Orange,\" \"Eyes Wide Shut,\" and \"The Shining.\"" + } + } + } + ] + } + } +} +``` + +### トークン制限 + +入力トークン数がモデルの上限を超えた場合、モジュールは OpenAI API のエラーを返します。 + +## 仕組み (内部動作) + +内部では 2 段階のアプローチを使用します。まず、質問の回答を含む可能性が最も高いドキュメント (Sentence、Paragraph、Article など) を見つけるためにセマンティック検索を行います。次に、Weaviate が OpenAI Completions エンドポイントへの外部呼び出しに必要なプロンプトを生成します。もっとも関連性の高いドキュメントを使ってプロンプトを作成し、OpenAI が回答を抽出します。結果は次の 3 つのいずれかです。 + +1. 質問に回答できず、回答が見つからなかった +2. 回答は見つかったが、ユーザーが指定した最小確信度を満たさず破棄された (通常、ドキュメントがトピックに関連しているものの実際の回答が含まれていない場合) +3. 望ましい確信度を満たす回答が見つかり、ユーザーに返される + +モジュールは内部でセマンティック検索を実行するため、`text2vec-...` モジュールが必要です。ただし、`qna-...` モジュールと同じタイプである必要はありません。たとえば、セマンティック検索には `text2vec-contextionary`、回答抽出には `qna-openai` を使用できます。 + +## 追加情報 + +### 利用可能なモデル + +推奨モデル: + +- `gpt-3.5-turbo-instruct` + +以下のモデルは廃止予定です: + +- `text-ada-001` +- `text-babbage-001` +- `text-curie-001` +- `text-davinci-002` +- `text-davinci-003` + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/qna-transformers.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/qna-transformers.md new file mode 100644 index 000000000..64ef8deac --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/qna-transformers.md @@ -0,0 +1,174 @@ +--- +title: 質問応答 - transformers +description: Weaviate に QnA Transformers を追加して正確な質問応答とインサイトを得ます。 +sidebar_position: 40 +image: og/docs/modules/qna-transformers.jpg +# tags: ['qna', 'qna-transformers', 'transformers'] +--- + +## 概要 + +* Question and Answer (Q&A) モジュールは、データから回答を抽出するための Weaviate モジュールです。 +* このモジュールは、Weaviate と一緒に実行されるテキストベクトル化モジュールに依存します。 +* `ask {}` オペレーターを GraphQL `Get {}` クエリに追加します。 +* GraphQL の `_additional {}` フィールド内に最大 1 件の回答を返します。 +* `certainty`(信頼度)が最も高い回答が返されます。 + +## はじめに + +Question and Answer (Q&A) モジュールは、データから回答を抽出するための Weaviate モジュールです。BERT 系モデルを使用して回答を検索・抽出します。このモジュールは GraphQL `Get{...}` クエリ内で検索オペレーターとして利用できます。`qna-transformers` モジュールは、指定クラスのデータオブジェクト内から回答を探します。指定した `certainty` 範囲内で回答が見つかった場合、GraphQL の `_additional { answer { ... } }` フィールドに返されます。回答は最大 1 件で、設定された(オプション)`certainty` を上回っている場合のみ返却されます。`certainty`(信頼度)が最も高い回答が返されます。 + +現在利用できる Question Answering モデルは 5 種類あります(出典: [Hugging Face Model Hub](https://huggingface.co/models)): [`distilbert-base-uncased-distilled-squad (uncased)`](https://huggingface.co/distilbert-base-uncased-distilled-squad)、[`bert-large-uncased-whole-word-masking-finetuned-squad (uncased)`](https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad)、[`distilbert-base-cased-distilled-squad (cased)`](https://huggingface.co/distilbert-base-cased-distilled-squad)、[`deepset/roberta-base-squad2`](https://huggingface.co/deepset/roberta-base-squad2)、[`deepset/bert-large-uncased-whole-word-masking-squad2 (uncased)`](https://huggingface.co/deepset/bert-large-uncased-whole-word-masking-squad2)。すべてのモデルがすべてのデータセットやユースケースで高性能とは限りませんが、ほとんどのデータセットで高い性能を示す `bert-large-uncased-whole-word-masking-finetuned-squad (uncased)` の使用を推奨します(ただしサイズは大きめです)。 + +`v1.10.0` 以降では、回答スコアを検索結果のリランキング要因として利用できます。 + +## 有効化方法(モジュール設定) + +### Docker Compose + +Q&A モジュールは Docker Compose ファイルにサービスとして追加できます。`text2vec-contextionary` もしくは `text2vec-transformers` などのテキストベクトライザーが必要です。`qna-transformers` モジュール(`bert-large-uncased-whole-word-masking-finetuned-squad (uncased)`)を `text2vec-transformers` と組み合わせて使用する Docker Compose 例は以下のとおりです。 + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + TRANSFORMERS_INFERENCE_API: 'http://text2vec-transformers:8080' + QNA_INFERENCE_API: "http://qna-transformers:8080" + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'text2vec-transformers,qna-transformers' + CLUSTER_HOSTNAME: 'node1' + text2vec-transformers: + image: cr.weaviate.io/semitechnologies/transformers-inference:sentence-transformers-msmarco-distilbert-base-v2 + environment: + ENABLE_CUDA: '1' + NVIDIA_VISIBLE_DEVICES: all + deploy: + resources: + reservations: + devices: + - capabilities: [gpu] + qna-transformers: + image: cr.weaviate.io/semitechnologies/qna-transformers:bert-large-uncased-whole-word-masking-finetuned-squad + environment: + ENABLE_CUDA: '1' + NVIDIA_VISIBLE_DEVICES: all + deploy: + resources: + reservations: + devices: + - capabilities: [gpu] +... +``` + +変数の説明: +* `QNA_INFERENCE_API`: qna モジュールが稼働している場所 +* `ENABLE_CUDA`: 1 に設定すると、ホストマシンに GPU があれば使用します + +_注: 現時点では、テキストベクトル化モジュールを 1 つのセットアップで併用することはできません。`text2vec-contextionary`、`text2vec-transformers`、あるいはテキストベクトル化モジュールなしのいずれかを選択する必要があります。_ + +## 使い方( GraphQL ) + +### GraphQL Ask 検索 + +このモジュールは GraphQL `Get{...}` クエリに `ask{}` 検索オペレーターを追加します。`ask{}` は以下の引数を取ります。 + +| Field | Data Type | Required | Example value | Description | +|-|-|-|-|-| +| `question` | string | yes | `"What is the name of the Dutch king?"` | 回答を求める質問 | +| `certainty` | float | no | `0.75` | 回答の最小信頼度。値が高いほど検索が厳格になり、低いほど曖昧になります。設定しない場合、抽出可能な回答はすべて返されます | +| `properties` | list of strings | no | `["summary"]` | テキストを含むクラスのプロパティ。指定しない場合、すべてのプロパティが対象 | +| `rerank` | bool | no | `true` | 有効にすると、qna モジュールが回答スコアで結果をリランキングします。たとえば、以前の(セマンティック)検索で 3 番目だった結果に最も有力な回答が含まれていた場合、結果 3 が位置 1 に繰り上がります。*v1.10.0 より前では非対応* | + +注意: +* GraphQL の `Explore { }` 機能も `ask` 検索をサポートしますが、結果は回答を含むオブジェクトへの beacon のみであり、実際の抽出は行われません。したがって質問で `nearText` セマンティック検索を行うのと違いはありません。 +* `'ask'` オペレーターは `'nearXXX'` オペレーターと同時には使用できません。 + +### クエリ例 + +import CodeQnaTransformer from '/_includes/code/qna-transformers.ask.mdx'; + + + +### GraphQL レスポンス + +回答は `_additional` プロパティ内の `answer` に含まれます。フィールドは次のとおりです。 +* `hasAnswer` (`boolean`): 回答が見つかったかどうか +* `result` (nullable `string`): 回答文字列。`hasAnswer==false` の場合は `null` +* `certainty` (nullable `float`): 返された回答の信頼度。`hasAnswer==false` の場合は `null` +* `property` (nullable `string`): 回答を含むプロパティ名。`hasAnswer==false` の場合は `null` +* `startPosition` (`int`): 回答開始位置の文字オフセット。`hasAnswer==false` の場合は `0` +* `endPosition` (`int`): 回答終了位置の文字オフセット。`hasAnswer==false` の場合は `0` + +注: レスポンスの `startPosition`、`endPosition`、`property` は必ずしも返されるとは限りません。これらは入力テキストに対して大文字小文字を区別しない文字列マッチング関数で計算されます。Transformer モデルが出力をフォーマットする際に(元入力に存在しないトークン間スペースを追加するなどして)差異が生じた場合、位置計算やプロパティの判定に失敗する可能性があります。 + +### レスポンス例 + +```json +{ + "data": { + "Get": { + "Article": [ + { + "_additional": { + "answer": { + "certainty": 0.73, + "endPosition": 26, + "hasAnswer": true, + "property": "summary", + "result": "king willem - alexander", + "startPosition": 48 + } + }, + "title": "Bruised Oranges - The Dutch royals are botching covid-19 etiquette" + } + ] + } + }, + "errors": null +} +``` + +## カスタム Q&A Transformer モジュール + +`text2vec-transformers` と同様の方法が利用できます。詳細は [こちら](/weaviate/model-providers/transformers/embeddings-custom-image.md) を参照してください。つまり、プリビルドのコンテナを選択するか、`semitechnologies/qna-transformers:custom` ベースイメージを使って独自モデルからコンテナをビルドします。モデルが Hugging Face の `transformers.AutoModelForQuestionAnswering` と互換性を持つことを確認してください。 + +## 仕組み(内部動作) + +内部では 2 段階アプローチを採用しています。最初にセマンティック検索を行い、回答を含む可能性が高いドキュメント(例: 文、段落、記事など)を見つけます。次に、そのドキュメントのすべての `text` と `string` プロパティに対して BERT 形式の回答抽出を行います。結果は次の 3 通りです。 +1. 質問に対する回答が存在しないため、回答が見つからなかった。 +2. 回答は見つかったが、ユーザー指定の最小 `certainty` に達しておらず破棄された(トピックは合っているが実際の回答が含まれていない場合によく発生)。 +3. 指定した `certainty` を満たす回答が見つかり、ユーザーに返される。 + +このモジュールは内部でセマンティック検索を実行するため、`text2vec-...` モジュールが必要です。`qna-...` モジュールと同じ種類である必要はありません。たとえば、`text2vec-contextionary` でセマンティック検索を行い、`qna-transformers` で回答を抽出することもできます。 + +### 長いドキュメントへの自動スライディングウィンドウ + +データオブジェクト内のテキストが 512 トークンを超える場合、Q&A Transformer モジュールは自動でテキストを小さなチャンクに分割します。モジュールはスライディングウィンドウ(重複部分を持つテキスト片)を使用し、境界に回答がある場合でも見逃さないようにします。回答が重複して検出された場合は、最高スコアの回答が返されます。 + +## モデルのライセンス + +`qna-transformers` モジュールは複数のモデルと互換性があり、それぞれ独自のライセンスを持ちます。詳細は使用するモデルのライセンスを [Hugging Face Hub](https://huggingface.co/models) でご確認ください。 + +ライセンス条件が意図する用途に適しているかどうかを評価する責任はユーザーにあります。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/ref2vec-centroid.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/ref2vec-centroid.md new file mode 100644 index 000000000..783f8a9ac --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/ref2vec-centroid.md @@ -0,0 +1,164 @@ +--- +title: Ref2Vec Centroid ベクトライザー +description: Ref2Vec Centroid でより強力なデータ表現を用いた ベクトル 検索を強化します。 +sidebar_position: 25 +image: og/docs/modules/ref2vec-centroid.jpg +# tags: ['ref2vec', 'ref2vec-centroid', 'centroid'] +--- + +## 概要 + +`ref2Vec-centroid` モジュールは、参照先 ベクトル の重心 (centroid) を基にオブジェクトの ベクトル を計算するために使用します。この重心 ベクトル は、オブジェクトが参照する ベクトル から算出され、オブジェクト群のクラスタ間の関連付けを可能にします。これは、ユーザーの行動や嗜好を集約して提案を行うようなアプリケーションに役立ちます。 + +## 有効化方法 + +### Weaviate Cloud + +このモジュールは WCD ではデフォルトで有効になっています。 + +### Weaviate Database + +どのモジュールを Weaviate インスタンスで使用するかは、`Docker Compose` ファイルで指定できます。`ref2Vec-centroid` を追加するには次のようにします: + +```yaml +--- +services:html + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'ref2vec-centroid' + CLUSTER_HOSTNAME: 'node1' +... +``` + +## 設定方法 + +Weaviate スキーマ内で、このモジュールがデータをどのように ベクトル 化するかを定義する必要があります。Weaviate のスキーマに不慣れな場合は、まず [Weaviate スキーマに関するチュートリアル](../starter-guides/managing-collections/index.mdx) をご覧ください。 + +例えば、`ref2vec-centroid` を使用するように設定された `Article` クラスは次のとおりです。これにはクラス レベルの `moduleConfig` で 2 つのフィールドを指定するだけで済みます: + +1. `referenceProperties`: 重心計算に使用する参照プロパティのリスト +2. `method`: 重心を計算する方法。現在は `mean` のみサポートされています。 + +`Article` クラスでは、`hasParagraphs` プロパティを唯一の参照プロパティとして指定し、`Article` オブジェクトの ベクトル を計算します。 + +他のベクトライザー モジュール(例: text2vec / multi2vec / img2vec)とは異なり、ref2vec-centroid はオブジェクトの内容から埋め込みを生成しない点に注意してください。本モジュールの目的は、オブジェクトが *参照する* ベクトル を基にオブジェクト自身の ベクトル を計算することです。 + +この例では、`Paragraph` クラスは text2vec-contextionary モジュールで ベクトル を生成するように設定されています。そのため、`Article` クラスの ベクトル 埋め込みは、参照された `Paragraph` インスタンスから取得した text2vec-contextionary ベクトル の平均になります。 + +この例では `Paragraph` クラスの ベクトル 生成に text2vec-contextionary を使用していますが、ユーザーが独自に用意した ベクトル を使用する場合でも ref2vec-centroid の挙動は同じです。その場合でも、ref2vec-centroid の出力は参照 ベクトル の平均として計算され、参照 ベクトル の由来だけが異なります。 + +```json +{ + "classes": [ + { + "class": "Article", + "description": "A class representing a published article", + "moduleConfig": { + "ref2vec-centroid": { + "referenceProperties": ["hasParagraphs"], + "method": "mean" + } + }, + "properties": [ + { + "dataType": [ + "text" + ], + "description": "Title of the article", + "name": "title" + } + , + { + "dataType": [ + "Paragraph" + ], + "description": "Paragraphs belonging to this article", + "name": "hasParagraphs" + } + ], + "vectorizer": "ref2vec-centroid" + }, + { + "class": "Paragraph", + "description": "Paragraphs belonging to an Article", + "properties": [ + { + "dataType": [ + "text" + ], + "description": "Content that will be vectorized", + "moduleConfig": { + "text2vec-contextionary": { + "skip": false, + "vectorizePropertyName": false + } + }, + "name": "content" + } + ], + "vectorizer": "text2vec-contextionary" + } + ] +} +``` + +## 利用方法 + +`Article` クラスを ref2vec-centroid モジュールで正しく設定できたので、オブジェクトの作成を始められます。まだ参照する `Paragraph` オブジェクトが存在しない場合、あるいは `Paragraph` オブジェクトをまだ参照したくない場合は、新しく作成した `Article` オブジェクトの ベクトル は `nil` に設定されます。 + +既存の(`nil` ではない ベクトル を持つ)`Paragraph` オブジェクトを 1 つ以上参照すると、`Article` オブジェクトには自動的に重心 ベクトル が割り当てられます。この ベクトル は、`Article` オブジェクトが参照するすべての `Paragraph` オブジェクトの ベクトル から計算されます。 + +### 重心の更新 + +ref2vec-centroid を使用するよう設定されたクラスのオブジェクトは、以下のイベントが発生したときに ベクトル が計算(再計算)されます: +- 参照を含むプロパティを設定した状態でオブジェクトを作成したとき + - Object `POST`: 参照付きで 1 件のオブジェクトを作成 + - Batch object `POST`: 複数のオブジェクトを一度に作成し、それぞれに参照を付与 +- 既存のオブジェクトの参照リストを更新したとき。これには複数の方法があります: + - Object `PUT`: オブジェクトのすべてのプロパティを新しい参照セットで更新(既存の参照リストを完全に置き換え) + - Object `PATCH`: 既存のオブジェクトに新しい参照を追加 + - Reference `POST`: 既存のオブジェクトに対して新しい参照を作成 + - Reference `PUT`: オブジェクトのすべての参照を更新 +- オブジェクトから参照を削除したとき。これには複数の方法があります: + - Object `PUT`: オブジェクトのすべてのプロパティを更新し、すべての参照を削除 + - Reference `DELETE`: オブジェクトの参照リストから既存の参照を削除 + +**注意:** 参照をバッチで追加することは現在サポートされていません。バッチ参照機能は ベクトル インデックスの更新コストを回避するために設計されているためです。もしこのユースケースが重要な場合は、GitHub で [feature request](https://github.com/weaviate/weaviate/issues/new) を作成してください。 + +### クエリの実行 + +このモジュールは、既存の [nearVector](/weaviate/api/graphql/search-operators.md#nearvector) フィルターおよび [`nearObject`](/weaviate/api/graphql/search-operators.md#nearobject) フィルターと組み合わせて使用できます。`nearText` のような追加の GraphQL 拡張は提供しません。 + +## 追加情報 + +:::caution +注意: _参照先_ オブジェクトを更新しても、_参照元_ オブジェクトの ベクトル は自動的には更新されません。 +::: + +言い換えると、前述の `Article` / `Paragraph` の例を用いると: + +`"On the Philosophy of Modern Ant Colonies"` という `Article` オブジェクトが `"intro"`, `"body"`, `"conclusion"` の 3 つの `Paragraph` オブジェクトを参照しているとします。時間の経過とともに、働きアリと兵隊アリのダイナミクスに関する研究が進み、`"body"` が更新されるかもしれません。この場合でも、記事の既存 ベクトル は、リファクタリングされた `"body"` に基づいて自動的に更新されることはありません。 + +`"On the Philosophy of Modern Ant Colonies"` の重心 ベクトル を再計算したい場合は、何らかの形で更新をトリガーする必要があります。例えば、`"body"` への参照を一度削除してから再追加する、あるいは同一内容のまま `Article` オブジェクトを `PUT` するなどの方法です。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/spellcheck.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/spellcheck.md new file mode 100644 index 000000000..23a23c3a9 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/spellcheck.md @@ -0,0 +1,166 @@ +--- +title: スペルチェック +description: Weaviate にスペルチェックを統合してテキストデータの品質と検索精度を向上させます。 +sidebar_position: 70 +image: og/docs/modules/text-spellcheck.jpg +# tags: ['modules', 'other modules', 'spellcheck'] +--- + + +## 要点 + +* Spell Check モジュールは、 GraphQL クエリ内の生テキストのスペルをチェックする Weaviate のモジュールです。 +* このモジュールは Python のスペルチェックライブラリに依存します。 +* このモジュールは GraphQL の `nearText {}` 検索引数に `spellCheck {}` フィルターを追加します。 +* このモジュールはスペルチェックの結果を GraphQL の `_additional { spellCheck {} }` フィールドで返します。 + +## 概要 + +Spell Check モジュールは、 GraphQL クエリ入力内の生テキストのスペルをチェックする Weaviate のモジュールです。 [Python spellchecker](https://pypi.org/project/pyspellchecker/) ライブラリを使用してテキストを解析し、提案を行い、自動補正を強制できます。 + +## 有効化方法(モジュール設定) + +### Docker Compose + +Spell Check モジュールは Docker Compose ファイルにサービスとして追加できます。 `text2vec-contextionary` や `text2vec-transformers` などのテキスト ベクトライザーが稼働している必要があります。 `text2vec-contextionary` と併用して `text-spellcheck` モジュールを使うための例として、以下の Docker Compose ファイルがあります: + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + CONTEXTIONARY_URL: contextionary:9999 + SPELLCHECK_INFERENCE_API: "http://text-spellcheck:8080" + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'text2vec-contextionary,text-spellcheck' + CLUSTER_HOSTNAME: 'node1' + contextionary: + environment: + OCCURRENCE_WEIGHT_LINEAR_FACTOR: 0.75 + EXTENSIONS_STORAGE_MODE: weaviate + EXTENSIONS_STORAGE_ORIGIN: http://weaviate:8080 + NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE: 5 + ENABLE_COMPOUND_SPLITTING: 'false' + image: cr.weaviate.io/semitechnologies/contextionary:en0.16.0-v1.0.2 + ports: + - 9999:9999 + text-spellcheck: + image: cr.weaviate.io/semitechnologies/text-spellcheck-model:pyspellchecker-d933122 +... +``` + +変数の説明: +* `SPELLCHECK_INFERENCE_API`: Spell Check モジュールが稼働している場所 + +## 利用方法(GraphQL) + +Spell Check モジュールを利用して、クエリ時にユーザー入力の検索クエリが正しく綴られているか確認し、正しい綴りの候補を提案できます。クエリテキストを受け付けるフィルターには以下があります: + +* [`nearText`](/weaviate/api/graphql/search-operators.md#neartext) ( `text2vec-*` モジュールを使用している場合) +* `ask` ( [`qna-transformers`](./qna-transformers.md) モジュールが有効な場合) + +このモジュールには、スペルチェックと自動補正の 2 つの使い方があります。 + +### スペルチェック + +このモジュールは、提供されたクエリをチェック(変更はしない)するために使用できる新しい GraphQL `_additional` プロパティを提供します。 + +#### クエリ例 + +import SpellCheckModule from '/_includes/code/spellcheck-module.mdx'; + + + +#### GraphQL レスポンス + +結果は `spellCheck` という新しい GraphQL `_additional` プロパティに含まれます。含まれるフィールドは次のとおりです: +* `changes`: 以下のフィールドを持つリスト + * `corrected` (`string`): 修正された綴り(修正が見つかった場合) + * `original` (`string`): クエリ内の元の単語 +* `didYouMean`: クエリ内の修正済み全文 +* `originalText`: クエリ内の元の全文 +* `location`: クエリ内で誤綴りがあった位置 + +#### レスポンス例 + +```json +{ + "data": { + "Get": { + "Article": [ + { + "_additional": { + "spellCheck": [ + { + "changes": [ + { + "corrected": "housing", + "original": "houssing" + } + ], + "didYouMean": "housing prices", + "location": "nearText.concepts[0]", + "originalText": "houssing prices" + } + ] + }, + "title": "..." + } + ] + } + }, + "errors": null +} +``` + +### 自動補正 + +このモジュールは既存の `text2vec-*` モジュールを拡張し、 `autoCorrect` フラグを追加します。これを使用すると、クエリの綴りが間違っている場合に自動的に修正できます。 + +#### クエリ例 + +```graphql +{ + Get { + Article(nearText: { + concepts: ["houssing prices"], + autocorrect: true + }) { + title + _additional { + spellCheck { + changes { + corrected + original + } + didYouMean + location + originalText + } + } + } + } +} +``` + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/sum-transformers.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/sum-transformers.md new file mode 100644 index 000000000..82a748523 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/sum-transformers.md @@ -0,0 +1,207 @@ +--- +title: 要約 +description: Weaviate の SUM Transformers モジュールを使用してデータを効率的に要約します。 +sidebar_position: 80 +image: og/docs/modules/sum-transformers.jpg +# tags: ['transformers'] +--- + +## 概要 + +* Summarization ( `sum-transformers` ) モジュールは、段落全体を短いテキストに要約する Weaviate モジュールです。 +* このモジュールは要約に特化した transformers モデルをコンテナ化し、Weaviate から接続できるようにします。ここでは事前構築済みモデルを提供していますが、Hugging Face から別の transformer モデルを接続したり、カスタムモデルを使用したりすることも可能です。 +* モジュールは GraphQL の `_additional {}` フィールドに `summary {}` フィルターを追加します。 +* モジュールは GraphQL `_additional { summary {} }` フィールドで結果を返します。 + +## はじめに + +名前が示すとおり、Summarization モジュールはクエリ時に Weaviate のテキストオブジェクトを要約できます。 + +**例として**、Weaviate 内のデータに対してクエリを実行し、次のようなテキストを取得できます。 + +> "The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct." + +このテキストを次のような短い文に変換します。 + +> "The Eiffel Tower is a landmark in Paris, France." + +:::note GPUs preferred +クエリのパフォーマンスを最大化するには、transformer ベースのモデルを GPU で実行することを推奨します。 +CPU でも実行できますが、クエリ速度が大幅に低下します。 +::: + +### 利用可能なモジュール + +現在利用可能な `SUM` モジュールの一覧です([Hugging Face Model Hub](https://huggingface.co/models) から取得): +* [`bart-large-cnn`](https://huggingface.co/facebook/bart-large-cnn) +* [`pegasus-xsum`](https://huggingface.co/google/pegasus-xsum) + +## 有効化方法(モジュール設定) + +### Docker Compose + +`sum-transformers` モジュールは Docker Compose ファイルにサービスとして追加できます。 +`text2vec-contextionary` や `text2vec-transformers` などのテキストベクトライザーが稼働している必要があります。 + +以下は `facebook-bart-large-cnn` モデルを使用した `sum-transformers` モジュールと、`text2vec-contextionary` ベクトライザー モジュールを組み合わせた Docker Compose ファイルの例です。 + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + CONTEXTIONARY_URL: contextionary:9999 + SUM_INFERENCE_API: "http://sum-transformers:8080" + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + ENABLE_MODULES: 'text2vec-contextionary,sum-transformers' + CLUSTER_HOSTNAME: 'node1' + contextionary: + environment: + OCCURRENCE_WEIGHT_LINEAR_FACTOR: 0.75 + EXTENSIONS_STORAGE_MODE: weaviate + EXTENSIONS_STORAGE_ORIGIN: http://weaviate:8080 + NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE: 5 + ENABLE_COMPOUND_SPLITTING: 'false' + image: cr.weaviate.io/semitechnologies/contextionary:en0.16.0-v1.0.2 + ports: + - 9999:9999 + sum-transformers: + image: cr.weaviate.io/semitechnologies/sum-transformers:facebook-bart-large-cnn-1.2.0 + # image: cr.weaviate.io/semitechnologies/sum-transformers:google-pegasus-xsum-1.2.0 # Could be used instead +... +``` + +変数の説明: +* `SUM_INFERENCE_API`: Summarization モジュールが稼働している場所 + +## 使い方(GraphQL) + +モジュールの機能を利用するには、クエリの `_additional` プロパティを次のように拡張します。 + +### GraphQL トークン + +このモジュールは GraphQL クエリの `_additional` フィールドに `summary{}` という検索フィルターを追加します。 +この新しいフィルターは次の引数を取ります。 + +| Field | Data Type | Required | Example value | Description | +| - | - | - | - | - | +| `properties` | list of strings | yes | `["description"]` | クラスのうちテキストを含むプロパティ( `text` または `string` データタイプ)。少なくとも 1 つのプロパティを指定する必要があります | + +### クエリ例 + +import CodeSumTransformer from '/_includes/code/sum-transformers-module.mdx'; + + + +### GraphQL レスポンス + +回答は `summary` という新しい GraphQL `_additional` プロパティに含まれ、トークンのリストを返します。 +内容は次のフィールドです: +* `property` ( `string` ): 要約されたプロパティ名。複数プロパティを要約する場合に役立ちます +* `result` ( `string` ): 出力された要約文 + +### レスポンス例 + +```json +{ + "data": { + "Get": { + "Article": [ + { + "_additional": { + "summary": [ + { + "property": "summary", + "result": "Finding the perfect pair of jeans can be a challenge." + } + ] + }, + "title": "The Most Comfortable Gap Jeans to Shop Now" + } + ] + } + }, + "errors": null +} +``` + +## Hugging Face の別の Summarization モジュールを使用する + +[Hugging Face Model Hub](https://huggingface.co/models?pipeline_tag=summarization) にある任意の要約モデルを、2 行の Dockerfile でサポートする Docker イメージを構築できます。 +以下の例では、[`google/pegasus-pubmed` モデル](https://huggingface.co/google/pegasus-pubmed) 用のカスタムイメージを作成します。 + +#### Step 1: `Dockerfile` を作成する + +新しい `Dockerfile` を作成し、`my-model.Dockerfile` と名付けます。次の行を追加してください。 +``` +FROM semitechnologies/sum-transformers:custom +RUN chmod +x ./download.py +RUN MODEL_NAME=google/pegasus-pubmed ./download.py +``` + +#### Step 2: Dockerfile をビルドしてタグ付けする + +Dockerfile に `google-pegasus-pubmed` というタグを付けてビルドします。 +``` +docker build -f my-model.Dockerfile -t google-pegasus-pubmed . +``` + +#### Step 3: Weaviate でイメージを使用する + +イメージを任意のレジストリへプッシュするか、`docker-compose.yml` で `google-pegasus-pubmed` タグを参照して Weaviate から利用できます。 + +## 仕組み(内部動作) + +`sum-transformers` モジュールは transformer ベースの要約モデルを使用します。 +これらは抽象的 (abstractive) 要約を行い、入力テキストから新しいテキストを生成します。例として、以下のようなテキストを入力すると: + +
+ 元のテキストを表示 + +> *The Loch Ness Monster (Scottish Gaelic: Uilebheist Loch Nis), affectionately known as Nessie, is a creature in Scottish folklore that is said to inhabit Loch Ness in the Scottish Highlands. It is often described as large, long-necked, and with one or more humps protruding from the water. Popular interest and belief in the creature has varied since it was brought to worldwide attention in 1933. Evidence of its existence is anecdotal, with a number of disputed photographs and sonar readings.* +> *The scientific community explains alleged sightings of the Loch Ness Monster as hoaxes, wishful thinking, and the misidentification of mundane objects. The pseudoscience and subculture of cryptozoology has placed particular emphasis on the creature.* + +
+ +次のように要約を生成します。 + +> *The Loch Ness Monster is said to be a large, long-necked creature. Popular belief in the creature has varied since it was brought to worldwide attention in 1933. Evidence of its existence is disputed, with a number of disputed photographs and sonar readings. The pseudoscience and subculture of cryptozoology has placed particular emphasis on the creature.* + +出力の多くは入力をそのままコピーせず、*基づいて* 生成されている点に注意してください。`sum-transformers` モジュールはこの出力をレスポンスとして返します。 + +:::note Input length +他の多くの言語モデルと同様に、要約モデルが処理できるテキスト量には制限があります。 +`sum-transformers` モジュールは使用するモデルの最大長に制限されます。例として、`facebook/bart-large-cnn` モデルは 1024 トークンまでしか処理できません。 + +一方、入力が短すぎたり詳細が不足したりすると、transformer モデルが [幻覚](https://en.wikipedia.org/wiki/Hallucination_(artificial_intelligence)) を起こす可能性がある点にもご注意ください。 +::: + + + +## モデルライセンス + +`sum-transformers` モジュールは、ライセンスがそれぞれ異なる複数のモデルと互換性があります。詳細については、[Hugging Face モデル Hub](https://huggingface.co/models) でご利用のモデルのライセンスをご確認ください。 + +ライセンスが存在する場合、その条件がご予定の用途に適しているかどうかを評価する責任はお客様にあります。 + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/text2vec-contextionary.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/text2vec-contextionary.md new file mode 100644 index 000000000..b4c30de0d --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/text2vec-contextionary.md @@ -0,0 +1,453 @@ +--- +title: "Contextionary ベクトライザー" +description: Weaviate で Text2Vec Contextionary を使用し、コンテキストに基づくテキスト ベクトル化を向上させます。 +sidebar_position: 10 +image: og/docs/modules/text2vec-contextionary.jpg +# tags: ['text2vec', 'text2vec-contextionary', 'contextionary'] +--- + +`text2vec-contextionary` モジュールを使用すると、軽量モデルでローカルにベクトルを取得できます。 + +:::caution Deprecated module +`Contextionary` モデルは古く、どのユースケースにも推奨されません。代わりに他のモジュールをご利用ください。 + +ローカルかつ軽量なモデルをテストや開発目的でお探しの場合は、[`text2vec-model2vec` モジュール](../model-providers/model2vec/embeddings.md) をお試しください。 + +本番環境などでベクトル品質が重要な場合は、よりモダンな Transformer ベースのアーキテクチャを採用している[他のモデル統合](../model-providers/index.md)を推奨します。 +::: + +主なポイント: + +- このモジュールは Weaviate Cloud (WCD) では利用できません。 +- モジュールを有効にすると、[`nearText` 検索オペレーター](/weaviate/api/graphql/search-operators.md#neartext) が使用可能になります。 +- このモジュールは FastText に基づき、語彙の重み付き平均 (WMOWE) を使用してベクトルを生成します。 +- 複数言語に対応しています。 + +## Weaviate インスタンス設定 + +:::info Not applicable to WCD +このモジュールは Weaviate Cloud では利用できません。 +::: + +### Docker Compose ファイル + +`text2vec-contextionary` を使うには、Docker Compose ファイル (例: `docker-compose.yml`) で有効化する必要があります。 + +:::tip Use the configuration tool +手動でも設定できますが、[`Weaviate` 設定ツール](/deploy/installation-guides/docker-installation.md#configurator)を使用して `Docker Compose` ファイルを生成することを推奨します。 +::: + +#### パラメーター + +Weaviate: + +- `ENABLE_MODULES` (必須): 有効にするモジュール。`text2vec-contextionary` を含めてください。 +- `DEFAULT_VECTORIZER_MODULE` (任意): 既定のベクトライザーモジュール。`text2vec-contextionary` を設定すると、すべてのクラスで既定になります。 + +Contextionary: + +* `EXTENSIONS_STORAGE_MODE`: Contextionary の拡張を保存する場所 +* `EXTENSIONS_STORAGE_ORIGIN`: カスタム拡張ストレージのホスト +* `NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE`: 非常にまれな単語を非表示にできます。たとえば `5` を設定すると、出現頻度の第 5 パーセンタイルに当たる単語が最近傍探索 (GraphQL の `_additional { nearestNeighbors }` 機能など) から除外されます。 +* `ENABLE_COMPOUND_SPLITTING`: [こちら](#compound-splitting) を参照してください。 + +#### 例 + +この設定では `text2vec-contextionary` を有効化し、既定のベクトライザーとして設定し、Contextionary 用 Docker コンテナのパラメーターを指定しています。 + +```yaml +--- +services: + weaviate: + command: + - --host + - 0.0.0.0 + - --port + - '8080' + - --scheme + - http + image: cr.weaviate.io/semitechnologies/weaviate:||site.weaviate_version|| + ports: + - 8080:8080 + - 50051:50051 + restart: on-failure:0 + environment: + CONTEXTIONARY_URL: contextionary:9999 + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' + PERSISTENCE_DATA_PATH: '/var/lib/weaviate' + # highlight-start + ENABLE_MODULES: 'text2vec-contextionary' + # highlight-end + CLUSTER_HOSTNAME: 'node1' + # highlight-start + contextionary: + environment: + OCCURRENCE_WEIGHT_LINEAR_FACTOR: 0.75 + EXTENSIONS_STORAGE_MODE: weaviate + EXTENSIONS_STORAGE_ORIGIN: http://weaviate:8080 + NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE: 5 + ENABLE_COMPOUND_SPLITTING: 'false' + image: cr.weaviate.io/semitechnologies/contextionary:en0.16.0-v1.2.1 + ports: + - 9999:9999 + # highlight-end +... +``` + +## コレクション設定 + +各クラスでのモジュール動作は、[コレクション設定](../manage-collections/vector-config.mdx)で制御できます。 + +### ベクトル化設定 + +クラスおよびプロパティごとに、`moduleConfig` セクションでベクトライザーの動作を設定できます。 + +#### クラスレベル + +- `vectorizer` – データのベクトル化に使用するモジュール +- `vectorizeClassName` – クラス名をベクトル化するかどうか。既定値: `true` + +#### プロパティレベル + +- `skip` – プロパティのベクトル化を完全にスキップするかどうか。既定値: `false` +- `vectorizePropertyName` – プロパティ名をベクトル化するかどうか。既定値: `false` + +#### 例 + +```json +{ + "classes": [ + { + "class": "Document", + "description": "A class called document", + "vectorizer": "text2vec-contextionary", + "moduleConfig": { + // highlight-start + "text2vec-contextionary": { + "vectorizeClassName": false + } + // highlight-end + }, + "properties": [ + { + "name": "content", + "dataType": [ + "text" + ], + "description": "Content that will be vectorized", + // highlight-start + "moduleConfig": { + "text2vec-contextionary": { + "skip": false, + "vectorizePropertyName": false + } + } + // highlight-end + } + ], + } + ] +} +``` + +### クラス / プロパティ名 + +このモジュールを使用し、クラス名やプロパティ名をベクトル化する場合、それらの名前は `text2vec-contextionary` に含まれている必要があります。 + +複数語をクラスまたはプロパティ定義に使用する場合は、以下のように結合してください。 +- クラス名やプロパティ名: camelCase (例: `bornIn`) +- プロパティ名: snake_case (例: `born_in`) + +たとえば、次の例はすべて有効です。 + +```yaml +Publication + name + hasArticles +Article + title + summary + wordCount + url + hasAuthors + inPublication # CamelCase (all versions) + publication_date # snake_case (from v1.7.2 on) +Author + name + wroteArticles + writesFor +``` + +## 使用例 + +`text2vec-contextionary` を使った `nearText` クエリの例です。 + +import CodeNearText from '/_includes/code/graphql.filters.nearText.mdx'; + + + +## 追加情報 + +### コンセプトの検索 + +概念や単語を検索したり、コンセプトが Contextionary に含まれているか確認したりするには、`v1/modules/text2vec-contextionary/concepts/` エンドポイントを使用します。 + +```js +GET /v1/modules/text2vec-contextionary/concepts/ +``` + +#### パラメーター + +唯一のパラメーター `concept` は文字列で、複合語の場合は camelCase、または単語のリストを指定します。 + +#### レスポンス + +結果には以下のフィールドが含まれます: +- `"individualWords"`: クエリ内の各単語またはコンセプトの結果リスト + - `"word"`: 要求したコンセプトまたは単語 + - `"present"`: 単語が Contextionary に存在する場合は `true` + - `"info"`: 次のフィールドを持つオブジェクト + - `""nearestNeighbors"`: 最近傍のリストで、`"word"` と高次元空間での `"distance"` を含みます。`"word"` にはデータオブジェクトが含まれる場合もあります。 + - `"vector"`: 300 次元の生ベクトル値 + - `"concatenatedWord"`: 結合されたコンセプトのオブジェクト + - `"concatenatedWord"`: 指定したコンセプトが camelCase の場合、その結合語 + - `"singleWords"`: 結合コンセプト内の単語リスト + - `"concatenatedVector"`: 結合コンセプトのベクトル値リスト + - `"concatenatedNearestNeighbors"`: 最近傍のリストで、`"word"` と高次元空間での `"distance"` を含みます。`"word"` にはデータオブジェクトが含まれる場合もあります。 + +#### 例 + +```bash +curl http://localhost:8080/v1/modules/text2vec-contextionary/concepts/magazine +``` + +または ( camelCased の複合コンセプトである点に注意してください) + +import CodeContextionary from '/_includes/code/contextionary.get.mdx'; + + + +結果は次のようになります: + +```json +{ + "individualWords": [ + { + "inC11y": true, + "info": { + "nearestNeighbors": [ + { + "word": "magazine" + }, + { + "distance": 6.186641, + "word": "editorial" + }, + { + "distance": 6.372504, + "word": "featured" + }, + { + "distance": 6.5695524, + "word": "editor" + }, + { + "distance": 7.0328364, + "word": "titled" + }, + ... + ], + "vector": [ + 0.136228, + 0.706469, + -0.073645, + -0.099225, + 0.830348, + ... + ] + }, + "word": "magazine" + } + ] +} +``` + +### モデル詳細 + +`text2vec-contextionary` (Contextionary) は、Wiki と CommonCrawl データに対して [fastText](https://fasttext.cc/) を用いて学習された Weaviate 独自の言語 ベクトライザー です。 + +`text2vec-contextionary` モデルは 300 次元の ベクトル を出力します。この ベクトル は Weighted Mean of Word Embeddings (WMOWE) 手法によって計算されます。 + +この ベクトル は、元の学習テキストコーパスにおける各単語の出現回数で重み付けされた単語のセントロイドに基づいて計算されます (例: 単語 `"has"` は 単語 `"apples"` よりも重要度が低いと見なされます)。 + +![contextionary を用いたデータから ベクトル への変換](./img/data2vec-c11y.svg "contextionary を用いたデータから ベクトル への変換") + +### 利用可能な言語 + +Contextionary モデルは以下の言語で利用できます: + +* CommonCrawl と Wiki を用い、GloVe で学習 + * English + * Dutch + * German + * Czech + * Italian +* Wiki で学習 + * English + * Dutch + +### Contextionary の拡張 + +カスタムの単語や略語 (すなわち「コンセプト」) は、`v1/modules/text2vec-contextionary/extensions/` エンドポイントを通じて `text2vec-contextionary` に追加できます。 + +このエンドポイントを使用すると、[transfer learning](https://en.wikipedia.org/wiki/Transfer_learning) により、独自の単語・略語・コンセプトを Contextionary にコンテキストごと追加して拡充できます。`v1/modules/text2vec-contextionary/extensions/` エンドポイントを使用すると、コンセプトはリアルタイムで追加または更新されます。 + +データを追加する前に新しいコンセプトを Weaviate に導入する必要があります。そうしないと Weaviate が ベクトル を自動更新することはありません。 + +#### パラメーター + +Contextionary に追加したい拡張単語または略語を持つボディ (JSON または YAML) には、以下のフィールドを含めます: +- `"concept"`: 単語、複合語、略語を指定する文字列 +- `"definition"`: コンセプトのコンテキストを作成し、高次元 Contextionary 空間に配置するための明確な説明 +- `"weight"`: コンセプトの相対的重みを表す float 値 (Contextionary 既定のコンセプトは 1.0) + +#### レスポンス + +拡張が成功すると、入力パラメーターと同じフィールドがレスポンスボディに含まれます。 + +#### 例 + +コンセプト `"weaviate"` を Contextionary に追加してみましょう。 + +import CodeContextionaryExtensions from '/_includes/code/contextionary.extensions.mdx'; + + + +新しいコンセプトが Contextionary に存在するかは、いつでも確認できます: + +```bash +curl http://localhost:8080/v1/modules/text2vec-contextionary/concepts/weaviate +``` + +なお、連結語や複数単語から成るコンセプトで Contextionary を拡張することは (まだ) できません。 + +このエンドポイントで既存のコンセプトを上書きすることも可能です。たとえば、`Application Programming Interface` ではなく `Academic Performance Index` を表す略語 `API` を使用しており、このコンセプトを Contextionary で再配置したい場合は次のようにします: + +```bash +curl \ + -X POST \ + -H 'Content-Type: application/json' \ + -d '{ + "concept": "api", + "definition": "Academic Performance Index a measurement of academic performance and progress of individual schools in California", + "weight": 1 + }' \ + http://localhost:8080/v1/modules/text2vec-contextionary/extensions +``` + +これで `API` の意味があなたの Weaviate 環境で変更されました。 + +### ストップワード + +camelCased や CamelCased の名前からは、ストップワードが自動的に削除されます。 + + + +#### ベクトル化の挙動 + +ストップワードは役立つ場合もあるため、完全に除外することを推奨するわけではありません。代わりに Weaviate は ベクトル化 の際にストップワードを取り除きます。 + +多くの場合、この処理は裏側で行われるため気付きませんが、検証エラーを引き起こす可能性があるいくつかのエッジケースがあります: + +* camelCased のクラス名またはプロパティ名がストップワード **のみ** で構成されている場合、検証は失敗します。例: `TheInA` は無効ですが、`TheCarInAField` は有効です (内部では `CarField` として扱われます)。 + +* キーワードリストにストップワードが含まれている場合、それらは削除されます。ただし、すべてのキーワードがストップワードである場合、検証は失敗します。 + +#### Weaviate によるストップワードの判定方法 + +ストップワードのリストは使用している Contextionary バージョンから派生しており、Contextionary ファイルと一緒に公開されています。 + +### 複合語分割 + +Weaviate の Contextionary が、本来理解できるはずの単語から成る複合語を理解できないことがあります。この影響は、任意の複合語が許される言語 (オランダ語やドイツ語など) では大きく、複合語があまり一般的でない言語 (英語など) では小さくなります。 + +#### 効果 + +クラス `Post` のオブジェクトを `This is a thunderstormcloud` という内容でインポートすると仮定します。任意に複合された `thunderstormcloud` という単語は Contextionary に存在しません。そのため、オブジェクトの位置は Contextionary が認識する `"post", "this"` のみで決定されます (`"is"` と `"a"` はストップワードのため削除)。 + +`_interpretation` 機能を使ってこの内容がどのように ベクトル化 されたかを確認すると、次のようになります: + +```json +"_interpretation": { + "source": [ + { + "concept": "post", + "occurrence": 62064610, + "weight": 0.3623903691768646 + }, + { + "concept": "this", + "occurrence": 932425699, + "weight": 0.10000000149011612 + } + ] +} +``` + +この制限を克服するには、オプションの **Compound Splitting Feature** を Contextionary で有効にします。これにより任意の複合語を理解し、オブジェクトを次のように解釈します: + + ```json +"_interpretation": { + "source": [ + { + "concept": "post", + "occurrence": 62064610, + "weight": 0.3623903691768646 + }, + { + "concept": "this", + "occurrence": 932425699, + "weight": 0.10000000149011612 + }, + { + "concept": "thunderstormcloud (thunderstorm, cloud)", + "occurrence": 5756775, + "weight": 0.5926488041877747 + } + ] +} + ``` + +新しく見つかった単語 ( `thunderstorm` と `cloud` から構成) が ベクトル化 で最も高い重みを持つ点に注意してください。Compound Splitting がなければ失われていたこの意味を、いまや認識できます。 + +#### 有効化方法 + +`text2vec-contextionary` の Docker Compose ファイルで Compound Splitting を有効にできます。設定方法の詳細は [こちら](#compound-splitting) をご覧ください。 + +#### インポート速度と単語認識のトレードオフ + +Compound Splitting は、通常は認識されない単語に対して実行されます。データセットによっては、インポート時間が最大で 100% 長くなる可能性があります。そのため、より高い認識精度と高速なインポートのどちらがご利用のユースケースにとって重要かを慎重に評価してください。この機能のメリットは言語によって異なり(例:オランダ語やドイツ語では大きく、英語では小さい)、デフォルトではオフになっています。 + +### ノイズ フィルタリング + +「ノイズ ワード」とは、容易に意味を判別できないランダムな単語の連結語を指します。これらの単語は Contextionary の学習空間に存在しますが、極めてまれであるためランダムに分布しています。その結果、最近傍検索に依存する機能(追加プロパティ `nearestNeighbors` または `semanticPath`)でクエリを実行すると、こうしたノイズ ワードが直近の近傍として返される場合があります。 + +このノイズに対処するため、Contextionary には近傍フィルタリング機能が導入されており、学習セット内での出現回数に基づいて下位パーセンタイルの単語を無視します。デフォルトでは下位 5 パーセンタイルが除外対象です。この設定は上書き可能で、たとえば下位 10 パーセンタイルを無視したい場合は、Docker Compose ファイルで `text2vec-contextionary` コンテナに環境変数 `NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE=10` を指定してください。 + +## モデル ライセンス + +`text2vec-contextionary` モジュールは、MIT ライセンスで公開されている [`fastText`](https://github.com/facebookresearch/fastText/tree/main) ライブラリに基づいています。詳細については [license file](https://github.com/facebookresearch/fastText/blob/main/LICENSE) をご確認ください。 + +本ライブラリのライセンス条件が、ご利用目的に適切かどうかを評価する責任は利用者にあります。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/usage-modules.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/usage-modules.md new file mode 100644 index 000000000..4fd732e98 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/modules/usage-modules.md @@ -0,0 +1,174 @@ +--- +title: Usage モジュール +description: 使用状況モジュールを追加して、Google Cloud Storage (GCS) または AWS S3 に使用状況分析データを収集・アップロードします。 +--- + +:::info ` v1.32 ` で追加 +Usage モジュールは使用状況分析データを収集し、Google Cloud Storage (GCS) または AWS S3 にアップロードします。このモジュールは **課金** を目的とした分析およびモニタリングのために Weaviate インスタンスの使用状況を追跡します。 +::: + +:::danger +このモジュールは開発中のため、破壊的変更が発生する場合があります。 +::: + +### 機能 + +- 定期的に使用状況データを収集。 +- JSON レポートを S3 または GCS にアップロード。 +- 実行時の設定上書きをサポート。 +- メトリクスとログを含む。 +- アップロード前にストレージ権限を検証。 + +## 設定 + +### Backup と Usage を含む設定例 + +```yaml + +# environment variables +ENABLE_MODULES="backup-gcs,usage-gcs" +BACKUP_GCS_BUCKET=weaviate-backups +USAGE_GCS_BUCKET=weaviate-usage +USAGE_GCS_PREFIX=billing-usage +TRACK_VECTOR_DIMENSIONS=true # won't be needed from 1.32.1 +RUNTIME_OVERRIDES_ENABLED=true +RUNTIME_OVERRIDES_PATH="${PWD}/tools/dev/config.runtime-overrides.yaml" +RUNTIME_OVERRIDES_LOAD_INTERVAL=30s + +# in tools/dev/config.runtime-overrides.yaml +usage_scrape_interval: 1h +usage_shard_jitter_interval: 100ms #(optional) +usage_gcs_bucket: weaviate-usage +usage_gcs_prefix: billing + +``` + +### 環境変数 + +:::tip +Usage モジュールを有効にしない限り、いかなる設定も効果を持ちません。 +このモジュールはバックアップ機能とは直接関係ありませんが、バックアップが有効でない場合はバックアップのメトリクスは収集されません。 +::: + +```bash +# Enable the usage modules (required) + +ENABLE_MODULES=usage-gcs # if you want gcs +ENABLE_MODULES=usage-s3 # if you want s3 +ENABLE_MODULES=usage-s3,usage-gcs # or both + +``` + +#### 実行時オーバーライド + +:::tip +`TRACK_VECTOR_DIMENSIONS=true` は Usage レポートでベクトル次元のメトリクスを収集するために必要です。 ` v1.32.1 ` からは不要になります。 +::: + +```shell +RUNTIME_OVERRIDES_ENABLED=true +RUNTIME_OVERRIDES_PATH="${PWD}/tools/dev/config.runtime-overrides.yaml" +RUNTIME_OVERRIDES_LOAD_INTERVAL=30s + +# Required: Enable vector dimension tracking metrics + +TRACK_VECTOR_DIMENSIONS=true # won't be needed from 1.32.1 + +# Collection interval (default: 1h) +USAGE_SCRAPE_INTERVAL=2h + +# (optional) Shard loop jitter (default: 100ms) +USAGE_SHARD_JITTER_INTERVAL=50ms + +# (optional) Policy version (default: 2025-06-01) +USAGE_POLICY_VERSION=2025-06-01 + +# (optional) verify the bucket permission on start (default:false) +USAGE_VERIFY_PERMISSIONS=true +``` + +:::info +実行時オーバーライドを有効にすると、Usage モジュールの設定を更新しても Weaviate を再起動する必要がありません。 +::: + +#### `runtime-overrides.yaml` の例 + +```yaml +usage_scrape_interval: 1s +usage_shard_jitter_interval: 100ms # (optional) +usage_verify_permissions: true/false # (optional) + +# usage-gcs config +usage_gcs_bucket: weaviate-usage +usage_gcs_prefix: billing + +# usage-s3 config +usage_s3_bucket: weaviate-usage +usage_s3_prefix: billing +``` + +#### AWS S3 変数 + +```bash +# Required: S3 bucket name +USAGE_S3_BUCKET=my-weaviate-usage-bucket + +# Optional: Object prefix (default: empty) +USAGE_S3_PREFIX=usage-reports + +``` + +#### GCP GCS 変数 + +```bash +# Required: GCS bucket name +USAGE_GCS_BUCKET=my-weaviate-usage-bucket + +# Optional: Object prefix (default: empty) +USAGE_GCS_PREFIX=usage-reports +``` + +### 監視 + +モジュールは Prometheus メトリクスを提供します: + +- `weaviate_usage_{gcs|s3}_operations_total`: モジュールの総操作回数。ラベル (`operation`: collect/upload, `status`: success, error)。 +- `weaviate_usage_{gcs|s3}_operation_latency_seconds`: 使用状況操作のレイテンシ (秒)。ラベル (`operation`: collect/upload)。 +- `weaviate_usage_{gcs|s3}_resource_count`: モジュールが追跡するリソース数。ラベル (`resource_type`: collections/shards/backups)。 +- `weaviate_usage_{gcs|s3}_uploaded_file_size_bytes`: アップロードされた使用状況ファイルのサイズ (バイト)。 + +### デバッグログ + +デバッグを有効にするとモジュールの詳細な動作を確認できます。 + +```bash +LOG_LEVEL=debug +``` + +### テスト +Minio を使用する場合は、環境変数 `AWS_ENDPOINT`, `AWS_REGION` を設定してください。 + +#### ローカル +```bash +AWS_REGION=us-east-1 +AWS_ENDPOINT=http://localhost:9000 +``` + +#### クラウド + +``` +AWS_REGION=us-east-1 +AWS_ENDPOINT=minio.weaviate.svc.cluster.local:9000 +``` + +## 参考リソース + +- [監視](/docs/deploy/configuration/monitoring.md) +- [環境変数](/docs/deploy/configuration/env-vars/index.md) + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_architecture.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_architecture.md new file mode 100644 index 000000000..fdd2f2844 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_architecture.md @@ -0,0 +1,95 @@ +--- +title: アーキテクチャ +sidebar_position: 4 +image: og/docs/more-resources.jpg +# tags: ['Architecture'] +--- + + +... + +## 追加リソース - 箇条書き、公開準備前(!) + +以下は箇条書きのメモです。正式な文章へと書き換える必要があります。 +詳細に記載していますが、公開に不適切な内容があれば、一般的な意味が変わらない範囲で削除してください。 +また、すべての箇条書きはかなり率直な表現になっています。同じ内容でもマーケティング向けに言い換えたほうが良い場合は、自由に調整してください。 + +## 0.22.x(「サードパーティーセットアップ」) + +### 10,000 feet ビュー +* 「Core」 Weaviate アプリケーション(Weaviate Stack と混同しないでください)はステートレスで、データをサードパーティーのデータベースに保存します +* 使用しているデータベースは `etcd` と `Elasticsearch` の 2 種類です +* `etcd` は主に歴史的理由で採用されており、設定、スキーマ、contextionary の拡張を保存しています +* `Elasticsearch` はすべてのデータオブジェクトを保存し、検索機能を提供します +* 「Core」 Weaviate アプリケーションは、テキストからベクトルへの変換、データオブジェクトのスキーマ拡張、クロスリファレンスの構築と解決、バリデーション、および各種 API を担当します + +### ベクトル検索 +* ベクトル検索が実行されると、Core は Contextionary を用いてクエリテキストをベクトルに変換し、それを Elasticsearch に渡します +* Elasticsearch は OSS プラグイン `lior-k/fast-elasticsearch-vector-scoring` を使用してコサイン類似度を比較します +* これは素朴で網羅的な手法であり、クエリベクトルをインデックス内のすべてのベクトルと比較するため、計算量は O(n) です + +### 構造化検索 +* 構造化検索では、標準の ES/Lucene 転置インデックスが使用されます + +### その他 +* 1 つの Weaviate スキーマクラスは 1 つの Elasticsearch インデックスに対応します +* デフォルトで、1 インデックスにつき 3 つの Elasticsearch シャードが作成されます +* Weaviate データベースはステートレスのため、水平スケールが容易です +* Elasticsearch は水平スケールが可能です +* `etcd` も水平スケールが可能ですが、スタック内でボトルネックになる可能性は低いです +* contextionary コンテナ(「Semantic Search Extension」使用時のみ存在)は、インポート時とクエリ時の両方でテキストをベクトル化します +* インポート時には、contextionary コンテナと Elasticsearch コンテナの両方で負荷がピークになることが一般的です。通常、最初にスケールが必要になるコンポーネントです。経験則として、クラスターを監視し、リソースを最も消費している部分をスケールしてください。データセットごとに必要なリソースは異なります。 + +## 1.0.0(「スタンドアロン」) + +### 10,000 feet ビュー +* 「Core」 Weaviate アプリケーションがすべての永続化を担当し、サードパーティーのデータベースは不要です +* Weaviate の永続化レイヤーはベクトルネイティブに設計されています。同時に、0.22.x で人気だった構造化検索とベクトル検索の組み合わせも提供します +* 各クラスは 1 インデックスにマッピングされます。インデックスは 1..n 個のシャードから構成される自己完結型ユニットです +* 各シャードは 3 つの部分からなる自己完結型ユニットです:(1) ユーザーが入力したデータオブジェクトを保持するキー・バリュー ストア、(2) 構造化検索を可能にする Lucene 風の転置インデックス、(3) ベクトル検索を可能にするベクトルインデックス +* キー・バリュー ストアと転置インデックスはディスク操作に `boltdb` を使用します +* ベクトルインデックスは永続化に最適化した独自実装の `hnsw` です。将来的には他のベクトルインデックスも利用可能になりますが、多くのケースで HNSW が適切に機能します + +### ベクトル検索 +* 「Semantic Search Extension」を使用している場合、Contextionary がテキストをクエリベクトルに変換し、使用していない場合はユーザーがベクトルを直接提供します +* 対象クラスインデックスの内部 HNSW インデックスを使用して kNN 検索を行います +* HNSW はドキュメント ID を返し、それを転置インデックスとオブジェクトデータのキー・バリュー ストアで解決して完全なデータオブジェクトへ変換します +* このプロセスの計算量は概ね O(log n) で、大規模インデックスでは桁違いに高速です + +### 構造化検索 +* ベクトル検索を組み合わせない純粋な構造化検索では、転置インデックスを用いてドキュメント ID を取得し、その ID を解決してデータオブジェクトを取得し、ユーザーへ返します +* ベクトル検索と構造化検索を組み合わせる場合、転置インデックスでマッチするドキュメント ID の許可リスト(allow list)を作成し、それをベクトルインデックスへ渡します。(以下は HNSW 特有の挙動です)ベクトルインデックスは通常どおりリンクを辿りますが、最下層では許可リストに含まれるドキュメント ID のみを結果に含めます +* 将来的な最適化として、ベクトルインデックスをスキップし、許可リストに対して素朴検索を行う予定です。素朴検索が有利になるケースは 2 つあります:(1) 許可リストが短い場合、比較回数が少なくなるため素朴検索のほうが速い。(2) 逆に HNSW は許可リストが短い場合に遅くなる可能性があります。許可されたアイテムがクエリベクトルから非常に遠い位置にある場合(つまり、より近いマッチが許可リストに含まれない場合)、検索が網羅的になりやすいためです。ただしこの「網羅的」はインデックス全体に対するもので、かなり遅くなることがあります。例として、インデックスに 10 億件あり、許可リストに 2 件しか含まれない場合を考えてください。クエリベクトルに近い 5 億件が許可リストに含まれず、素朴検索なら比較は 2 回で済みますが、HNSW では 5 億回のベクトル比較が発生する場合があります。 + +### マルチノード構成 / 分散構成 / 水平スケール +* この機能は `1.0.0` にはまだ含まれず、将来のリリースで提供予定です。ただし永続化レイヤー全体は水平スケールを念頭に設計されています +* シャードの目的は、インデックスの一部をクラスター内の複数ノードに分散することです +* レプリケーションはマスターなしで行われます。つまりプライマリやセカンダリの区別がなく、どのレプリカも書き込みを受け付けます。そのため、シャード数が 1 でも真の水平スケールが可能です +* 例: + * 5 ノードクラスターで、1 インデックスが 1 シャード、レプリケーション 5 の場合、各ノードがインデックス全体のコピーを保持します。ディスク/メモリ要件はインデックスの 5 倍です。最大 4 ノードがダウンしてもすべてのデータを提供でき、高い可用性を持ちます。また、インデックスの特定領域に偏ったクエリでも全ノードが完全に回答できるため、クエリ性能は最も高くなります。 + * 5 ノードクラスターで、1 インデックスが 5 シャード、レプリケーション 3 の場合、各ノードは 3 つ(異なる)シャードを保持します。ディスク/メモリ要件はインデックスの 3 倍です(5 シャード × 1/5 ずつ × 3 レプリカ → 3)。最大 2 ノードがダウンしてもすべてのデータを提供できますが、3 ノード以上ダウンすると、同一シャードを保持する 3 ノードすべてが停止する可能性があり、その場合該当シャード(インデックス全体の 1/5)が提供できなくなります。 + * 5 ノードクラスターで、1 インデックスが 1 シャード、レプリケーション 3 の場合: クラスターは十分に活用されていません。単一シャードが 3 ノードに複製され、残り 2 ノードはデータを保持せずアイドル状態になります。この場合はシャード数を増やすべきです。 +* Weaviate は CAP 定理において AP データベースです。 + + + +### メモリ使用量 +* HNSW インデックスはメモリに収まる必要があります。ただし、これはすべての ベクトル がメモリに入る必要があるという意味ではなく、インデックス構造(多数のリンクを持つグラフ)だけが収まればよいことに注意してください。十分なメモリを確保できない場合、 Weaviate は起動できません。 +* 類似度比較でよく使用される ベクトル はキャッシュされます。そのため、すべての ベクトル をメモリに収める必要はありません。キャッシュがいっぱいになると項目は削除されます。キャッシュが頻繁に削除されるとディスク読み取りが増加します。最大のパフォーマンスを得るには、キャッシュがすべての ベクトル を収容できるサイズであることが理想です。ただし、メモリ要件が特に重要となる大規模クラスタでは、検索クエリがインデックス全体に均一に分散されることは稀です。そのため、多くの実際のケースでは、すべての ベクトル より小さいキャッシュでも高いパフォーマンスを達成できます。 +* 転置インデックスとオブジェクトストレージ用のキー・バリュー・ストアはメモリマップされています。そのため、利用可能メモリのおおよそ 50%(データセットとクエリプロファイルにより異なります)を Linux ページキャッシュとして残しておくべきです。 + +## 0.22.x の Standalone モード + + +* **重要**: Standalone モードは、1.0.0 で標準となる Standalone 機能のプレビューですが、Standalone モードは **1.0.0 のプレビューではありません**。言い換えると、1.0.0 への移行時には、0.22.x の Standalone モードには反映されていない破壊的変更が含まれる可能性があります。 +* 0.22.16 時点では、Standalone モードはまだ機能が完全ではありません。 +* 0.22.x の Standalone モードは、 Weaviate が永続化に外部 DB に依存しなくなった場合の姿をプレビューすることを目的としています。 +* 0.22.16 現在、Standalone モードにはスタックに `etcd` が依然として必要です。これは技術的な理由ではなく、現在 `etcd` に保存されているデータを置き換える仕組みが Weaviate Standalone にまだ組み込まれていないためです。`etcd` は 1.0.0 までに完全に削除される予定です。 +* 0.22.16 現在、各インデックスは 1 シャードのみです。カスタムのシャード数のサポートは `1.0.0` までに追加されます。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_best-practices.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_best-practices.md new file mode 100644 index 000000000..69455b6c2 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_best-practices.md @@ -0,0 +1,8 @@ +--- +title: ヒントとベストプラクティス +sidebar_position: 6 +image: og/docs/more-resources.jpg +# tags: ['tips', 'best practices'] +--- + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_category_.json new file mode 100644 index 000000000..94a8a4d6e --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "More resources", + "position": 150 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_deprecation-messages.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_deprecation-messages.md new file mode 100644 index 000000000..c600d0a60 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/_deprecation-messages.md @@ -0,0 +1,78 @@ +--- +title: 非推奨メッセージ +image: og/docs/more-resources.jpg +# tags: ['Deprecation messages'] +--- + + +以下のリストには非推奨メッセージが含まれています: + + +{% for message in site.data.deprecations.deprecations %} + + + +{{ message.msg }} + + +{% endfor %} + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/example-datasets.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/example-datasets.md new file mode 100644 index 000000000..0747aaa85 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/example-datasets.md @@ -0,0 +1,132 @@ +--- +title: データセット例 +sidebar_position: 5 +image: og/docs/more-resources.jpg +# tags: ['example datasets'] +--- + +## CLIP を使用したマルチモーダル テキスト/画像検索 + +このサンプルアプリケーションでは、[multi2vec-clip](/weaviate/model-providers/transformers/embeddings-multimodal.md) 連携を利用して Weaviate インスタンスを起動し、いくつかのサンプル画像をインポートします(ご自身の画像を追加することも可能です)。さらに、[React](https://reactjs.org/) と [TypeScript/JavaScript](../client-libraries/typescript/index.mdx) クライアントを使った非常にシンプルな検索フロントエンドを提供します。 + +[ここから始める](https://github.com/weaviate/weaviate-examples/blob/main/clip-multi-modal-text-image-search/README.md) + +## Wikipedia を用いたセマンティック検索 + +英語版 Wikipedia の記事全体を単一の Weaviate インスタンスにインポートし、記事間のすべてのグラフ関係も作成したうえで、Wikipedia 記事に対するセマンティック検索クエリを実行できるようにしました。インポートスクリプト、前処理済みの記事、バックアップを公開しているため、完全なセットアップをご自身で実行できます。 + +[ここから始める](https://github.com/weaviate/semantic-search-through-Wikipedia-with-Weaviate) + +## Meta AI Research - Wikidata 上の Biggraph + +Wikidata の PBG モデル全体を Weaviate にインポートし、インターネット遅延を除いて 50 ミリ秒未満でデータセット全体を検索できるようにしました。デモの GraphQL クエリには、純粋な ベクトル 検索とスカラー検索を組み合わせたクエリの両方が含まれています。 + +[ここから始める](https://github.com/weaviate/biggraph-wikidata-search-with-weaviate) + +## ニュース記事 + +このデータセットには、Financial Times、New York Times、Guardian、Wallstreet Journal、CNN、Fox News、The Economist、New Yorker、Wired、Vogue、Game Informer からランダムに抽出した約 1,000 件のニュース記事が含まれています。 + +`Article`、`Publication`、`Category`、`Author` クラスを含む [スキーマ](../starter-guides/managing-collections/index.mdx) が同梱されています。 + +### Docker Compose で実行 + +このデータセットをローカルで実行したい場合は、Docker Compose で一括実行できます。 + +このデモデータセットは、任意の `text2vec` モジュールで実行できます。例を以下に示します。 + +#### Text2vec-contextionary + +Docker Compose ファイルには、`text2vec-contextionary` モジュールを組み込んだ Weaviate とデータセットの両方が含まれています。 + +Docker Compose ファイルをダウンロード + +```bash +curl -o docker-compose.yml https://raw.githubusercontent.com/weaviate/weaviate-examples/main/weaviate-contextionary-newspublications/docker-compose.yaml +``` + +Docker を実行(バックグラウンドで実行する場合は `-d` を追加) + +```bash +docker compose up +``` + +ニュース記事デモデータセットを操作するには `http://localhost:8080/` に接続してください。 + +#### Text2vec-transformers (without GPU) + +Docker Compose ファイルには、`text2vec-contextionary`、`NER`、`Q&A`、`spellcheck` の各モジュールを組み込んだ Weaviate とデータセットの両方が含まれています。 + +Docker Compose ファイルをダウンロード + +```bash +curl -o docker-compose.yml https://raw.githubusercontent.com/weaviate/weaviate-examples/main/weaviate-transformers-newspublications/docker-compose.yml +``` + +Docker を実行(バックグラウンドで実行する場合は `-d` を追加) + +```bash +docker compose up +``` + +ニュース記事デモデータセットを操作するには `http://localhost:8080/` に接続してください。 + +#### Text2vec-transformers (with GPU enabled) + +Docker Compose ファイルには、`text2vec-contextionary`、`NER`、`Q&A`、`spellcheck` の各モジュールを組み込んだ Weaviate とデータセットの両方が含まれています。この構成を使用する場合、マシンに GPU が搭載されている必要があります。 + +Docker Compose ファイルをダウンロード + +```bash +curl -o docker-compose.yml https://raw.githubusercontent.com/weaviate/weaviate-examples/main/weaviate-transformers-newspublications/docker-compose-gpu.yaml +``` + +Docker を実行(バックグラウンドで実行する場合は `-d` を追加) + +```bash +docker compose up +``` + +ニュース記事デモデータセットを操作するには `http://localhost:8080/` に接続してください。 + +### 手動で実行 + +**外部** ホストまたは Docker Compose を使用しないローカルホストで独自の Weaviate を実行している場合: + +```bash +# WEAVIATE ORIGIN (e.g., https://foobar.weaviate.network), note paragraph basics for setting the local IP +export WEAVIATE_ORIGIN=WEAVIATE_ORIGIN +# Optionally you can specify which newspaper language you want (only two options `cache-en` or `cache-nl`, if not specified by default it is `cache-en` ) +export CACHE_DIR= +# Optionally you can set the batch size (if not specified by default 200) +export BATCH_SIZE= +# Make sure to replace WEAVIATE_ORIGIN with the Weaviate origin as mentioned in the basics above +docker run -it -e weaviate_host=$WEAVIATE_ORIGIN -e cache_dir-$CACHE_DIR -e batch_size=$BATCH_SIZE semitechnologies/weaviate-demo-newspublications:latest + +``` + +Docker を使用してローカル(Docker Compose あり)で実行する場合: + +_注意:Docker Compose ファイルがある同じディレクトリで実行してください_ + +```bash +# This gets the Weaviate container name and because the docker uses only lowercase we need to do it too (Can be found manually if 'tr' does not work for you) +export WEAVIATE_ID=$(echo ${PWD##*/}_weaviate_1 | tr "[:upper:]" "[:lower:]") +# WEAVIATE ORIGIN (e.g., http://localhost:8080), note the paragraph "basics" for setting the local IP +export WEAVIATE_ORIGIN="http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $WEAVIATE_ID):8080" +# WEAVIATE NETWORK (see paragraph: Running on the localhost) +export WEAVIATE_NETWORK=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.NetworkID}}{{end}}' $WEAVIATE_ID) +# Optionally you can specify which newspaper language you want (only two options `cache-en` or `cache-nl`, if not specified by default it is `cache-en` ) +export CACHE_DIR= +# Optionally you can set the batch size (if not specified by default 200) +export BATCH_SIZE= +# Run docker +docker run -it --network=$WEAVIATE_NETWORK -e weaviate_host=$WEAVIATE_ORIGIN -e cache_dir-$CACHE_DIR -e batch_size=$BATCH_SIZE semitechnologies/weaviate-demo-newspublications:latest +``` + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/example-use-cases.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/example-use-cases.md new file mode 100644 index 000000000..f9cdc6207 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/example-use-cases.md @@ -0,0 +1,68 @@ +--- +title: ユースケースとデモの例 +sidebar_position: 6 +image: og/docs/more-resources.jpg +# tags: ['use cases'] +--- + +このページでは、オープンソースのデモ プロジェクトを通じて vector データベースのさまざまなユースケースを紹介します。どのプロジェクトもフォークして自由に変更できます。 + +ご自身のプロジェクトをこのページに掲載したい場合は、[GitHub](https://github.com/weaviate/docs/issues) で Issue を作成してください。 + +## 類似検索 + +vector データベースは、テキストや画像などあらゆるモダリティ、またはそれらの組み合わせに対して、高速かつ効率的な類似検索を実現します。この類似検索機能は、従来の機械学習アプリケーションにおけるレコメンデーション システムなど、より複雑なユースケースにも利用できます。 + +| Title | Description | Modality | Code | +| --- | --- | --- | --- | +| Plant search | 植物に対するセマンティック検索。 | テキスト | [JavaScript](https://github.com/weaviate-tutorials/DEMO-text-search-plants) | +| Wine search | ワインに対するセマンティック検索。 | テキスト | [Python](https://github.com/weaviate-tutorials/DEMO-text-search-wines) | +| Book recommender system ([Video](https://www.youtube.com/watch?v=SF1ZlRjVsxw), [Demo](https://bookrecs.weaviate.io/)) | 検索クエリに基づいて書籍をおすすめ。 | テキスト | [TypeScript](https://github.com/weaviate/BookRecs) | +| Movie recommender system ([Blog](https://medium.com/towards-data-science/recreating-andrej-karpathys-weekend-project-a-movie-search-engine-9b270d7a92e4)) | 類似した映画を検索。 | テキスト | [JavaScript](https://github.com/weaviate-tutorials/awesome-moviate) | +| Multilingual Wikipedia Search | 複数言語の Wikipedia を検索。 | テキスト | [TypeScript](https://github.com/weaviate/weaviate-examples/tree/main/cohere-multilingual-wikipedia-search/frontend) | +| Podcast search | ポッドキャスト エピソードに対するセマンティック検索。 | テキスト | [Python](https://github.com/weaviate-tutorials/DEMO-semantic-search-podcast) | +| Video Caption Search | 動画内で質問への回答があるタイムスタンプを検索。 | テキスト | [Python](https://github.com/weaviate-tutorials/DEMO-text-search-video-captions) | +| Facial Recognition | 画像内の人物を識別します。 | 画像 | [Python](https://github.com/weaviate-tutorials/DEMO-face-recognition) | +| Image Search over dogs ([Blog](https://weaviate.io/blog/how-to-build-an-image-search-application-with-weaviate)) | アップロードした画像に基づいて似た犬種の画像を検索。 | 画像 | [Python](https://github.com/weaviate-tutorials/DEMO-image-search-dogs) | +| Text to image search | テキスト クエリに最も近い画像を検索。 | マルチモーダル | [JavaScript](https://github.com/weaviate-tutorials/DEMO-multimodal-text-to-image-search) | +| Text to image and image to image search | テキストまたは画像クエリに最も近い画像を検索。 | マルチモーダル | [Python](https://github.com/weaviate-tutorials/DEMO-multimodal-search) | + +## LLM と検索 + +vector データベースと LLM はクッキーとミルクのように相性抜群です! + +vector データベースは、LLM への入力の一部として関連情報を検索・提供することで、ハルシネーションなど LLM の課題を軽減します。 + +| Title | Description | Modality | Code | +| --- | --- | --- | --- | +| Verba, the golden RAGtriever ([Video](https://www.youtube.com/watch?v=OSt3sFT1i18 ), [Demo](https://verba.weaviate.io/)) | Weaviate のドキュメントとブログ記事とチャットできる Retrieval augmented generation (RAG) システム。 | テキスト | [Python](https://github.com/weaviate/Verba) | +| HealthSearch ([Blog](https://weaviate.io/blog/healthsearch-demo), [Demo](https://healthsearch-frontend.onrender.com/)) | 症状に基づきヘルスケア製品をレコメンド。 | テキスト | [Python](https://github.com/weaviate/healthsearch-demo) | +| Magic Chat | 『Magic: The Gathering』のカードを検索。 | テキスト | [Python](https://github.com/weaviate/st-weaviate-connection/tree/main) | +| AirBnB Listings ([Blog](https://weaviate.io/blog/generative-feedback-loops-with-llms)) | Generative Feedback Loops を用いて AirBnB のリスティング向けにカスタマイズされた広告を生成。 | テキスト | [Python](https://github.com/weaviate/Generative-Feedback-Loops/) | +| Distyll | テキストや動画コンテンツを要約。 | テキスト | [Python](https://github.com/databyjp/distyll) | + +詳しくは、[LLM と検索](https://weaviate.io/blog/llms-and-search) のブログ記事をご覧ください。 + +## 分類 + +Weaviate はベクトライザー機能を活用し、セマンティックな理解に基づいて未知の新しいコンセプトをリアルタイムで自動分類できます。 + +| Title | Description | Modality | Code | +| --- | --- | --- | --- | +| Toxic Comment Classification | コメントが有害か無害かを分類します。 | テキスト | [Python](https://github.com/weaviate-tutorials/DEMO-classification-toxic-comment) | +| Audio Genre Classification | 音声ファイルの音楽ジャンルを分類します。 | 画像 | [Python](https://github.com/weaviate-tutorials/DEMO-classification-audio-genre/) | + +## その他のユースケース + +Weaviate の[モジュラー エコシステム](../modules/index.md)により、[固有表現抽出](../modules/ner-transformers.md)や[スペル チェック](../modules/spellcheck.md)など、Weaviate vector データベースのさらなるユースケースが広がります。 + +| Title | Description | Code | +| --- | --- | --- | +| Named Entity Recognition (NER) | tbd | [Python](https://github.com/weaviate/weaviate-examples/tree/main/example-with-NER-module) | + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/faq.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/faq.md new file mode 100644 index 000000000..4bb3cc7eb --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/faq.md @@ -0,0 +1,639 @@ +--- +title: よくある質問 +sidebar_position: 3 +image: og/docs/more-resources.jpg +# tags: ['FAQ'] +--- + +## 一般 + +#### Q: Weaviate を ベクトル データベースとして使用する理由は何ですか? + +
+ 回答 + +> 私たちの目標は三つあります。 +> 1. まず、他の人が独自のセマンティック システムや ベクトル 検索エンジンをできる限り簡単に作成できるようにすることです(そのため API は GraphQL ベースです)。 +> 2. 次に、セマンティック要素(「ベクトル データベース」における「知識」部分)に強くフォーカスしています。最終的には、 Weaviate がデータの管理・インデックス作成・「理解」を支援し、より新しく、優れた、そして高速なアプリケーションを構築できるようにすることがゴールです。 +> 3. そして三つ目に、どこでも実行できるようにしたいと考えています。そのため Weaviate はコンテナ化されています。 + +
+ +#### Q: Weaviate と Elasticsearch などとの違いは何ですか? + +
+ 回答 + +> 他のデータベース システム(例: Elasticsearch)は転置インデックスに依存しており、高速な検索が可能です。 Weaviate もデータと値を保存するために転置インデックスを使用します。さらに、 Weaviate は ベクトル ネイティブ検索データベースでもあり、データを ベクトル として保存することでセマンティック検索を実現します。このデータ保存方式の組み合わせはユニークで、エンドツーエンドで高速・フィルタリング付き・セマンティック検索を可能にします。 + +
+ +#### Q: Weaviate をマネージド サービスとして提供していますか? + +
+ 回答 + +> はい、提供しています。詳しくは [Weaviate Cloud](https://weaviate.io/pricing) をご覧ください。 + +
+ +## 設定とセットアップ + +#### Q: インスタンスのサイズはどのように設定すれば良いですか? + +
+ 回答 + +> ドキュメントの [アーキテクチャ セクション](/weaviate/concepts/resources.md#an-example-calculation) を参照してください。 + +
+ +#### Q: Weaviate を利用するのに Docker(Compose)を理解している必要がありますか? + +
+ 回答 + +> Weaviate はリリースを配布する手段として Docker イメージを使用し、モジュールが豊富なランタイムをまとめるために Docker Compose を利用します。これらの技術に不慣れな場合は、[Docker Introduction for Weaviate Users](https://medium.com/semi-technologies/what-weaviate-users-should-know-about-docker-containers-1601c6afa079) をお読みいただくことをおすすめします。 + +
+ +#### Q: Weaviate の Docker コンテナが再起動した場合、データは失われますか? + +
+ 回答 + +> 3 つのレベルがあります。 +> 1. ボリュームを設定していない( `Docker Compose` ファイルのデフォルト)場合、コンテナが再起動しても(例: クラッシュや `docker stop/start`)データは保持されます。 +> 2. ボリュームを設定していない状態でコンテナを削除した場合(例: `docker compose down` や `docker rm`)、データは失われます。 +> 3. ボリュームを設定している場合、コンテナに何が起きてもデータは保持されます。コンテナを完全に削除・置換しても、次回ボリューム付きで起動すればすべてのデータがそこにあります。 + +
+ +#### Q: Weaviate で RBAC を有効にするには? + +
+ 回答 + +> RBAC(ロールベースアクセス制御)は、 `AUTHORIZATION_RBAC_ENABLED` 環境変数で Weaviate を設定するときに有効化できます。詳細は [RBAC: Configuration](/deploy/configuration/configuring-rbac.md) ガイドをご覧ください。 + +
+ +## スキーマとデータ構造 + +#### Q: スキーマを設計する際に考慮すべきベストプラクティスやガイドラインはありますか? + +*(例: 書籍の内容に対してセマンティック検索を行う場合、スキーマに Chapter や Paragraph を表現すべきか、それとも小説全体を 1 つのプロパティに含める方が良いかなど)* + +
+ 回答 + +> 大まかな目安として、単位が小さいほど検索は高精度になります。たとえば文という 2 つのオブジェクトは、共通の ベクトル(実質的には文の平均値)よりも多くの情報を ベクトル 埋め込みに含む傾向があります。一方で、オブジェクト数が増えるとインポート時間が長くなり(各 ベクトル もデータ量になるため)ディスク容量も増加します。例として、 transformers を使用する場合、1 つの ベクトル は 768×float32 = 3 KB です。数百万の ベクトル があれば大きな差になります。一般的に、 ベクトル が多いほどメモリも多く必要になります。 +> +> つまり、いくつかのトレードオフがあります。私たちの経験では、段落を個別の単位として扱うと非常に良い結果が得られました。より細粒度にしても大きなメリットはなく、章全体よりはるかに高精度だからです。 +> +> 章を段落へリンクする際などにはクロスリファレンスを使用できます。ただし、クロスリファレンスを解決するにはパフォーマンス上のペナルティがあります。実質的に A1→B1 を解決するコストは A1 と B1 の両方を個別に検索するのと同じです。大規模になるとこのコストが積み重なります。 +> +> そのため、データを正規化せず、クロスリファレンスを実際に参照せずとも解決できる形で保存する(デノーマライズする)ことを検討してください。これはデータベースで一般的なパターンであり、 Weaviate でも同様です。 + +
+ +#### Q: スキーマで参照(リファレンス)を使うべきですか? + +
+ 回答 + +> 端的に言えば、利便性のためにデータ スキーマへリレーションを追加すると、コードやクエリが少なくて済みますが、クエリ実行時に参照を解決する分だけパフォーマンスが低下します。 +> +> 1. 最終的な目標がパフォーマンスであれば、参照は付加価値を生まない可能性があります。解決コストがかかるためです。 +> 2. データ項目間の複雑な関係を表現することが目的であれば、大いに役立ちます。1 回のクエリで参照を解決できるため、複数のリンクを持つコレクションでは特に便利です。一方で、単一の(双方向)参照しかない場合は、リンクをデノーマライズ(例: ID フィールド)し検索時に解決する方法もあります。 + +
+ +#### Q: スキーマで 1 対多のリレーションシップを作成できますか? + +
+ 回答 + +> はい、クロスリファレンスを使用して 1 つまたは複数のオブジェクト(Class → 複数の Class)を参照できます。プリミティブのリストまたは配列への参照については、[こちら](https://github.com/weaviate/weaviate/issues/1611) で近日対応予定です。 + +
+ +#### Q: `text` と `string`、そして `valueText` と `valueString` の違いは何ですか? + +
+ 回答 + +> `text` と `string` のデータ型はトークナイズ方法が異なります。`string` は現在非推奨です。詳細は [このセクション](../config-refs/collections.mdx#tokenization) をご覧ください。 + +
+ + + +#### Q: Weaviate コレクションには名前空間がありますか? + +
+ 回答 + +はい。各コレクション自体が名前空間のように機能します。さらに、[マルチテナンシー](../concepts/data.md#multi-tenancy)機能を使用して、テナントごとに分離されたストレージを作成できます。これは、1 つのクラスターが複数の顧客やユーザーのデータを保存するユースケースで特に有用です。 + +
+ +#### Q: UUID の形式に制限はありますか?何か標準に従う必要がありますか? + +
+ 回答 + +> UUID は、[Canonical Textual representation](https://en.wikipedia.org/wiki/Universally_unique_identifier#Format) に一致する文字列として提供する必要があります。UUID を指定しない場合、 Weaviate は `v4`、つまりランダム UUID を生成します。ご自身で生成する場合は、ランダムに生成するか、保有するフィールドに基づいて決定論的に生成するかを選べます。その場合は、[`v3` または `v5`](https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_3_and_5_(namespace_name-based)) を使用する必要があります。 + +
+ +#### Q: データオブジェクト追加時に UUID を指定しないと、 Weaviate が自動で生成しますか? + +
+ 回答 + +> はい、 UUID を指定しない場合は Weaviate が自動で生成します。 + +
+ + +#### Q: なぜ Weaviate にはオントロジーではなくスキーマがあるのですか? + +
+ 回答 + +> スキーマはデータの表現(本ケースでは GraphQL API)に焦点を当てているためです。しかし、 Weaviate のスキーマを使ってオントロジーを表現することもできます。 Weaviate のコア機能の 1 つは、スキーマ(およびそのオントロジー)を意味的に解釈し、形式的に定義されたエンティティではなく概念で検索できるようにすることです。 + +
+ +#### Q: Weaviate のデータスキーマ、オントロジー、タクソノミーの違いは何ですか? + +
+ 回答 + +> タクソノミー、オントロジー、スキーマが Weaviate とどのように関連しているかについては、[このブログ記事](https://medium.com/semi-technologies/taxonomies-ontologies-and-schemas-how-do-they-relate-to-weaviate-9f76739fc695)をご覧ください。 + +
+ +## テキストと言語の処理 + +#### Q: カスタム用語はどのように扱えばよいですか? + +
+ 回答 + +> ユーザーが略語や専門用語などのカスタム用語を使用することがあります。エンドポイントの使用方法については [こちら](/weaviate/modules/text2vec-contextionary.md#extending-the-contextionary) を参照してください。 + +
+ +#### Q: セマンティックな意味を失わずにほぼリアルタイムでデータをインデックスするには? + +
+ 回答 + +> すべてのデータオブジェクトは、そのセマンティックな意味に基づいたベクトル埋め込みを取得します。要するに、データオブジェクトに使用されている語や概念に基づいてベクトル位置を計算します。コンテキショナリーに既に含まれるモデルだけで十分なコンテキストが得られます。詳細を確認したい場合は [こちらのコード](https://github.com/weaviate/contextionary/tree/master/server)を参照するか、[Stack Overflow](https://stackoverflow.com/tags/weaviate/) で Weaviate タグを付けて具体的な質問をしてください。 + +
+ +#### Q: 自分の言語用の text2vec-contextionary が存在しないのはなぜですか? + +
+ 回答 + +> おそらく、あなたがその言語を最初に必要としているからです![GitHub でこちら](https://github.com/weaviate/weaviate/issues)にお知らせいただければ、次のリリースで対応します(ただし、[Silbo Gomero](https://en.wikipedia.org/wiki/Silbo_Gomero) など笛で話す言語は除きます)。 + +
+ +#### Q: 多義語はどのように処理しますか? + +
+ 回答 + +> 「会社(ビジネス)」を意味するのか、「軍隊の部隊」を意味するのかを Weaviate はどのように解釈するのでしょうか?これはスキーマ構造と追加するデータに基づいて行います。 Weaviate のスキーマには company コレクションがあり、そのプロパティ name に Apple という値が入っているとします。このシンプルな表現(company, name, apple)だけで、データオブジェクトのベクトル位置がビジネスや iPhone 方面に引き寄せられます。詳細は[こちら](../)を参照するか、[Stack Overflow](https://stackoverflow.com/tags/weaviate/) で Weaviate タグを付けて具体的な質問をしてください。 + +
+ +#### Q: クエリ/ドキュメント埋め込みモデルの複数バージョンを同時に利用できますか?(新モデルのライブ実験に便利) + +
+ 回答 + +> Weaviate のスキーマで複数のコレクションを作成できます。1 つのコレクションは Kubernetes のネームスペースや Elasticsearch のインデックスのように機能します。スペース同士は完全に独立しているため、スペース 1 はスペース 2 とはまったく異なる埋め込みを使用できます。設定されたベクトライザーは常に単一のコレクションのみにスコープされます。また、 Weaviate のクロスリファレンス機能を使用して Class 1 のオブジェクトと Class 2 の対応オブジェクトをグラフ状に接続し、別スペースの同等オブジェクトを簡単に参照できます。 + +
+ +## クエリ + +#### Q: コレクション内のオブジェクト総数を取得するには? + +
+ 回答 + +import HowToGetObjectCount from '/_includes/how.to.get.object.count.mdx'; + +> この `Aggregate` クエリはコレクション内のオブジェクト総数を返します。 + + + +
+ +#### Q: Weaviate の certainty からコサイン類似度を求めるには? + +
+ 回答 + +> Weaviate の `certainty` から[コサイン類似度](https://en.wikipedia.org/wiki/Cosine_similarity)を取得するには、`cosine_sim = 2*certainty - 1` を使用してください。 + +
+ +#### Q: 指定した limit によって検索結果の品質が変わるのはなぜですか?どうすれば解決できますか? + +
+ 回答 + +Weaviate はベクトル検索を提供するために ANN インデックスを使用します。ANN インデックスとは近似最近傍 (approximate nearest neighbor) インデックスです。「近似」はリコールとクエリ速度のトレードオフを意味します。このトレードオフは [ANN ベンチマークセクション](/weaviate/benchmarks/ann.md#benchmark-results)で詳細に説明しています。たとえば、特定の HNSW パラメータでリコール 98% とは、結果の 2% が真の最近傍と一致しないことを意味します。どのビルドパラメータがどのリコールにつながるかはデータセットによって異なります。ベンチマークページでは 4 つの例示データセットを示しています。ご自身の本番ワークロードに最も近い特性を持つデータセットを基に、各ビルドおよびクエリ時パラメータでのリコールを推定できます。 + +一般的に、デフォルトパラメータより高いリコールが必要な場合は、より強いパラメータを使用できます。これはビルド時(`efConstruction`, `maxConnections`)かクエリ時(`ef`)に設定できます。概ね、クエリ時に `ef` を大きくすると検索がより綿密になり、レイテンシーはやや増えますがリコールも向上します。 + +指定した limit を変更すると、暗黙的に `ef` パラメータも変わります。これはデフォルトの `ef` が `-1` に設定されており、 Weaviate が limit に基づいて `ef` を決定するためです。動的な `ef` 値は、下限となる `dynamicEfMin`、上限となる `dynamicEfMax`、limit から目標 `ef` を導出する係数 `dynamicEfFactor` によって制御されます。 + +例: デフォルトパラメータ `ef=-1`, `dynamicEfMin=100`, `dynamicEfMax=500`, `dynamicEfFactor=8` を使用した場合、limit に応じた `ef` は以下のようになります。 + +* `limit=1` の場合: 計算上 `ef=1*8=8`。下限を下回るため `ef` は `100`。 +* `limit=20` の場合: 計算上 `ef=20*8=160`。範囲内のため `ef` は `160`。 +* `limit=100` の場合: 計算上 `ef=100*8=800`。上限を超えるため `ef` は `500`。 + +特定の limit でより高い検索品質が必要な場合は、次の選択肢を検討できます。 + +1. 動的 `ef` の代わりに、望ましいリコールを満たす固定値を使用する。 +1. クエリ時の `ef` によって検索品質が大きく変動する場合は、より強力なビルドパラメータを選択することも検討してください。[ANN ベンチマークセクション](/weaviate/benchmarks/ann.md#benchmark-results)には、さまざまなデータセットに対する多数のパラメータ組み合わせが掲載されています。 + +
+ + + +#### Q: なぜ SPARQL ではなく GraphQL を使用したのですか? + +
+ Answer + +> ユーザー エクスペリエンスのためです。スタックへ Weaviate を統合する作業をできる限り簡単にしたいと考えており、それに対する答えが GraphQL だと信じています。GraphQL を取り巻くコミュニティとクライアント ライブラリは非常に豊富で、そのほとんどを Weaviate で利用できます。 + +
+ +## データ管理 + +#### Q: オブジェクトを反復処理する最良の方法は何ですか?ページネーションされた API 呼び出しは可能ですか? + +
+ Answer + +> はい、Weaviate はカーソル ベースのイテレーションと結果セットのページネーションの両方をサポートしています。 +> +> すべてのオブジェクトを反復処理するには、[`after` 演算子](../manage-objects/read-all-objects.mdx)を使用できます。 +> +> 結果セットをページネーションする場合は、GraphQL API 呼び出しで `offset` と `limit` 演算子を使用できます。パフォーマンス上のヒントや制限事項を含むこれらの演算子の使い方については、[このページ](../api/graphql/filters.md)をご覧ください。 + +
+ +#### Q: データを更新する際のベストプラクティスは何ですか? + +
+ Answer + +> データを更新する際のベストプラクティスを 3 つ挙げます: +> 1. [バッチ API](../manage-objects/import.mdx) を使用する +> 2. まず 1 バッチあたり 100 件程度の小さめのバッチ サイズから始める。非常に高速であれば増やし、タイムアウトが発生する場合は減らす +> 3. 一方向のリレーションシップ (例: `Foo -> Bar`) がある場合は、まずすべての `Bar` オブジェクトをインポートし、その後リファレンスを設定済みの `Foo` オブジェクトをインポートするのが最も簡単です。より複雑なリレーションシップがある場合は、まずリファレンスなしでオブジェクトをインポートし、その後で[リファレンスを追加](../manage-objects/import.mdx#import-with-references)してコレクション間のリンクを任意の方向に設定できます。 + +
+ +## モジュール + +#### Q: 独自のモジュールを接続できますか? + +
+ Answer + +> [はい!](/weaviate/modules/custom-modules.md) + +
+ +#### Q: 自分で text2vec-contextionary ベクトライザー モジュールをトレーニングできますか? + +
+ Answer + +> 現時点ではできません。現在は[既存の contextionary](../weaviate/modules/text2vec-contextionary.md)を複数の言語で使用でき、必要に応じて転移学習機能でカスタム概念を追加できます。 + +
+ +## Weaviate におけるインデックス + +#### Q: Weaviate は Hnswlib を使用していますか? + +
+ Answer + +> いいえ +> +> Weaviate は、[hnswlib](https://github.com/nmslib/hnswlib) の制限 (永続性要件、CRUD サポート、プリフィルタリング など) を克服した独自実装の HNSW を使用しています。 +> +> Weaviate におけるカスタム HNSW 実装の参考情報: +> +> - [HNSW プラグイン (GitHub)](https://github.com/weaviate/weaviate/tree/master/adapters/repos/db/vector/hnsw) +> - [vector dot product ASM](https://github.com/weaviate/weaviate/blob/master/adapters/repos/db/vector/hnsw/distancer/asm/dot_amd64.s) +> +> さらに詳しく: +> +> - [Weaviate, an ANN Database with CRUD support – DB-Engines.com](https://db-engines.com/en/blog_post/87) ⬅️ このトピックで最も優れた資料 +> - [Weaviate の HNSW 実装 (ドキュメント)](/weaviate/concepts/indexing/vector-index.md#hierarchical-navigable-small-world-hnsw-index) +> +> _Note I: HNSW は Weaviate で使用されている実装の 1 つに過ぎません。Weaviate は[こちら](/weaviate/concepts/indexing/vector-index.md)で説明されているように複数のインデックス アルゴリズムをサポートできます_ + +
+ +#### Q: すべての ANN アルゴリズムが Weaviate のインデックス プラグイン候補になり得ますか? + +
+ Answer + +> いいえ +> +> 一部のアルゴリズム (例: Annoy や ScaNN) は、ビルド後は完全にイミュータブルで、変更や段階的な構築ができません。すべてのベクトルがそろった状態で一度だけビルドし、その後はクエリのみ可能で、要素の追加や変更はできません。したがって、Weaviate がサポートしたい CRUD 操作には対応できません。 + +
+ +#### Q: Weaviate は ANN インデックス検索でプレフィルタリングとポストフィルタリングのどちらを使っていますか? + +
+ Answer + +> 現在、Weaviate はフィルター付き ANN 検索においてプレフィルタリングのみを採用しています。詳細は「Weaviate の ベクトル とスカラー フィルタリングの仕組み」をご覧ください。 + +
+ +#### Q: Weaviate の ベクトル とスカラー フィルタリングの仕組みは? + +
+ Answer + +> 2 ステップのプロセスです: +> +> 1. インポート時に構築される転置インデックスがクエリを実行し、指定されたドキュメント ID の許可リストを生成します。その後、ANN インデックスがこの許可リストを使ってクエリされます (このリストが独自実装の理由の一つです)。 +> 2. 近いマッチではあるが許可リストに存在しないドキュメント ID に遭遇した場合、その ID は候補として扱われ (評価するリンク リストに追加)、結果セットには追加されません。許可された ID だけを結果セットに追加するため、上位 k 要素に到達する前に早期終了しません。 +> +> 技術的な実装の詳細については、[この動画](https://www.youtube.com/watch?v=6hdEJdHWXRE)をご覧ください。 + +
+ +#### 埋め込みの ベクトル 次元数の最大値は? + +
+ Answer + +> 現在、埋め込みは `uint16` で保存されているため、最大長は 65535 です。 + +
+ + + +## パフォーマンス + +#### Q: Weaviate のクエリ速度にとってより重要なのは何ですか? より多くの CPU パワーですか、それともより多くの RAM ですか? + +より具体的には: 16 GB の RAM と 2 つの CPU を搭載したマシンと、8 GB の RAM と 4 つの CPU を搭載したマシンのどちらを選びますか? + +
+ 回答 + +> これを 100% 正確に答えるのは非常に難しいですが、いくつかの要因があります: +> * **ベクトル検索自体** +> この部分は CPU ボトルネックですが、スループットに関してのみです。1 件の検索はシングルスレッドで実行されますが、複数の並列検索は複数スレッドを利用できます。そのため、ほかに処理がない状態で単一リクエストの時間を測定すると、マシンが 1 core でも 100 core でも同じです。しかし QPS が CPU のスループットに近づくと、コア数を増やすことで大きなメリットが得られます。 +> * **オブジェクトの取得** +> ベクトル検索が終わると、n 個の ID のリストを実際のオブジェクトへ解決する必要があります。これは一般的に IO ボトルネックです。ただし、すべてのディスクファイルはメモリマップされています。そのため、メモリが多いほどディスク状態をメモリに保持できます。とはいえ検索は均一に分散しているわけではありません。たとえば検索の 90% が 10% のオブジェクトだけを返すとしましょう(人気のある検索結果)。その 10% のディスクオブジェクトがすでにメモリにキャッシュされていれば、メモリを追加してもメリットはありません。 +> +> 以上を踏まえると、スループットが問題なら CPU を増やし、応答時間が問題ならメモリを増やすことを慎重に推奨できます。ただし後者は、キャッシュ可能なものが十分にある場合にのみ価値があります。ディスク状態(少なくとも大半のクエリに関連する部分)全体をキャッシュできるだけのメモリがすでにある場合、これ以上メモリを増やしてもメリットはありません。 +> なお、インポートについては HNSW インデックス作成のコストによりほぼ常に CPU ボトルネックです。もしインポート時とクエリ実行時でリサイズできるなら、インポート時は CPU を優先し、その後クエリ実行時に徐々に CPU をメモリに置き換えていくことをお勧めします。効果がなくなるまで続けてください。(実運用でインポートとクエリが分離していない場合もあります。) + +
+ +#### Q: データのインポートが時間がかかる/遅いのですが、原因と対策は? + +
+ 回答 + +> HNSW はクエリ時には非常に高速ですが、ベクトル化時は遅くなります。つまり、データオブジェクトの追加や更新には比較的時間がかかります。[非同期インデックス作成](../config-refs/indexing/vector-index.mdx#asynchronous-indexing)を試すことで、データ取り込みとベクトル化を分離できます。 + +
+ +#### Q: 遅いクエリをどのように最適化できますか? + +
+ 回答 + +> フィルタリングや解決が必要な深いネスト参照を含むクエリは時間がかかることがあります。最適化戦略については [こちら](./performance.md#costs-of-queries-and-operations) をご覧ください。 + +
+ + +#### Q: スカラー検索とベクトル検索を組み合わせた場合、スカラーフィルタは最近傍(ベクトル)検索の前に実行されますか、それとも後に実行されますか? + +
+ 回答 + +> Weaviate における混合構造化ベクトル検索はプリフィルタ方式です。最初に転置インデックスにクエリをかけ、許可リストを作成します。HNSW 検索ではこのリストを使用し、許可されていないドキュメント ID は接続をたどるノードとしてのみ扱い、結果セットには追加しません。 + +
+ +#### Q: 「フィルタ付きベクトル検索」について: これは 2 段階のパイプラインですが、ID のリストはどのくらい大きくなりますか? そのサイズはクエリ性能にどのように影響しますか? + +
+ 回答 + +> ID のリストは内部ドキュメント ID を使用しており、型は `uint64`、1 ID あたり 8 バイトです。メモリが許す限りリストを拡張できます。たとえば空きメモリが 2 GB なら 250 M ID、20 GB なら 2.5 B ID を保持できます。 +> +> 性能面では 2 つのポイントがあります: +> 1. ルックアップリストの作成 +> 2. ベクトル検索時の結果フィルタリング +> +> リストの作成は典型的な転置インデックスのルックアップで、演算子に応じて == の場合は 1 回の読み取り、範囲検索(例: >7)の場合は値行を 7 から無限大まで読み取ります。このプロセスは従来の検索エンジン(Elasticsearch など)と同じく効率的です。 +> +> ベクトル検索中のフィルタリングは、フィルタの制約度合いによって異なります。ご質問のように多くの ID が含まれる場合は非常に効率的です。許可リストにすべての ID が含まれている状態がフィルタなし検索に相当し、HNSW インデックスは通常どおり動作します。ただしリストが存在する場合は毎回許可リストに含まれているかを確認する必要があり、これはハッシュマップのルックアップで O(1) ですが、わずかなオーバーヘッドがあります。 +> +> 逆にリストが非常に制限的で ID が少ない場合は、かなり時間がかかります。HNSW インデックスは近傍 ID を見つけても、それらがリストに含まれていなければ候補に追加できず、接続の評価だけを行います。極端に制限的なリスト(例: 10 件 / 1 B)の場合、フィルタ対象の ID がクエリから遠いと検索が網羅的になり、インデックスなしの総当たりベクトル検索の方が効率的になります。このように、ブラインドフォース検索の方が効率的になる境界があります。現在このカットオフポイントを検出してインデックスをスキップする最適化は実装されていませんが、実際に問題になれば比較的簡単に実装できるはずです。 + +
+ +#### Q: Weaviate インスタンスが期待以上のメモリを使用しています。どのようにデバッグできますか? + +
+ 回答 + +> インポートに使用している Weaviate のバージョンが最新か確認してください。`v1.12.0` と `v1.12.1` では、大量のデータをディスクに書き込み、再起動後に過剰なメモリ消費を招く [問題](https://github.com/weaviate/weaviate/issues/1868) が修正されています。アップグレードしても解決しない場合は、[メモリ使用状況のプロファイリング方法](https://stackoverflow.com/a/71793178/5322199) を参照してください。 + +
+ +## トラブルシューティング / デバッグ + +#### Q: Weaviate のスタックトレースを出力する方法は? + +
+ 回答 + +`SIGQUIT` シグナルをプロセスに送ることでスタックトレースをコンソールに出力できます。ログレベルとデバッグ変数は `LOG_LEVEL` と `DEBUG` の [環境変数](/deploy/configuration/env-vars/index.md) で設定できます。 + +SIGQUIT については [こちら](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGQUIT) と、この [StackOverflow の回答](https://stackoverflow.com/questions/19094099/how-to-dump-goroutine-stacktraces/35290196#35290196) をご覧ください。 + +
+ +#### Q: コレクション作成時に 'invalid properties' エラーが発生する(Python クライアント 4.16.0〜4.16.3) + +
+ 回答 + +Weaviate Python クライアントの `4.16.0` から `4.16.3` では、text2vec_xxx ベクトライザーで以下のパターンでコレクションを作成するとエラーになります: + +```python +client.collections.create( + "CollectionName", + vector_config=Configure.Vectorizer.text2vec_cohere(), # also applies to other vectorizers +) +``` + +エラーメッセージ例: + +```text +UnexpectedStatusCodeError: Collection may not have been created properly.! Unexpected status code: 422, with response body: {'error': [{'message': "module 'text2vec-cohere': invalid properties: didn't find a single property which is of type string or text and is not excluded from indexing.... +``` + +これは既知の問題で、ベクトライザー定義を設定しながらコレクションに `TEXT` または `TEXT_ARRAY` プロパティを 1 つも定義せず、AutoSchema にスキーマ作成を任せた場合に発生します。 + +**この問題は Weaviate Python クライアントのパッチリリース `4.16.4` で修正されています。バージョン `4.16.4` 以降へのアップデートを推奨します。** + +もし該当バージョンから変更できない場合は、次のいずれかの方法で回避できます。 + +1. コレクションスキーマで少なくとも 1 つの `TEXT` または `TEXT_ARRAY` プロパティを明示的に定義する: + +```python +client.collections.create( + "CollectionName", + properties=[ + Property(name="", data_type=DataType.TEXT), + ], + vector_config=Configure.Vectorizer.text2vec_cohere(), + # Additional configuration not shown +) +``` + +2. ベクトライザー定義で `vectorize_collection_name` を `True` に設定する: + +```python +client.collections.create( + "CollectionName", + vector_config=Configure.Vectorizer.text2vec_cohere( + vectorize_collection_name=True + ), + # Additional configuration not shown +) +``` + +
+ +## その他 + +#### Q: Weaviate に機能追加をリクエストできますか? + +
+ 回答 + +> もちろんです([プルリクエスト](https://github.com/weaviate/weaviate/pulls) も大歓迎です 😉)。[こちら](https://github.com/weaviate/weaviate/issues) にリクエストを追加してください。GitHub アカウントさえあれば OK ですし、ついでにスターもぜひ 😇。 + +
+ + + +#### Q: 分散セットアップにおける Weaviate の整合性モデルは何ですか? + +
+ 回答 + +> Weaviate は一般的に Availability を Consistency より優先するようにモデル化されており ( AP over CP ) 、可用性が整合性よりもビジネス上クリティカルな状況で、高スループット下でも低い検索レイテンシを提供できるよう設計されています。データに対して厳密なシリアライザビリティが必要な場合は、別のプライマリデータストアにデータを保存し、 Weaviate を補助的なデータストアとして使用し、両者間でレプリケーションを設定することを推奨します。シリアライザビリティが不要で最終的な整合性で十分なユースケースであれば、 Weaviate をプライマリデータストアとして使用できます。 +> +> Weaviate にはトランザクションの概念がなく、操作は常に正確に 1 つのキーにのみ影響するため、シリアライザビリティは適用されません。分散セットアップ ( 開発中 ) では、 Weaviate の整合性モデルは最終的な整合性です。クラスタが健全な状態の場合、書き込みがユーザーに ACK されるまでに、すべての変更が影響を受けるすべてのノードにレプリケートされます。インポートリクエストが完了すると、オブジェクトはすべてのノードの検索結果に即座に表示されます。インポート操作と同時に検索クエリが行われた場合、ノード間でまだ同期が取れていない可能性があります。つまり、一部のノードには新しく追加または更新されたオブジェクトが既に含まれている一方で、他のノードにはまだ含まれていない場合があります。健全なクラスタでは、インポートリクエストが正常に完了するまでにすべてのノードが収束します。一時的にノードが利用不可になり再参加した場合、一時的に同期が取れていないことがあります。その場合、当該ノードは他のレプリカノードから欠落している変更を同期し、最終的には再び同じデータを提供します。 + +
+ +#### Q: 集計でタイムバケットを作成する方法が見当たりませんでしたが、可能ですか? + +
+ 回答 + +> 現時点では、タイムシリーズをタイムバケットに集計することはまだできませんが、アーキテクチャ的には障壁はありません。要望があれば素晴らしい機能リクエストになりそうですので、[こちら](https://github.com/weaviate/weaviate/issues) で issue を送っていただけます。 ( 私たちは非常に小さな会社であり、現在は水平スケーリングが優先事項です ) 。 + +
+ +#### Q: Docker Compose で最新の master ブランチを実行するにはどうすればよいですか? + +
+ 回答 + +> `Docker Compose` を使用して Weaviate を実行する場合、[`master`](https://github.com/weaviate/weaviate) ブランチから独自のコンテナをビルドできます。これは正式にリリースされた Weaviate のバージョンではないため、バグが含まれている可能性がある点にご注意ください。 +> +> ```sh +> git clone https://github.com/weaviate/weaviate.git +> cd weaviate +> docker build --target weaviate -t name-of-your-weaviate-image . +> ``` +> +> その後、この新しいイメージを使用して `docker-compose.yml` ファイルを作成します。例: +> +> ```yml +> +> services: +> weaviate: +> image: name-of-your-weaviate-image +> ports: +> - 8080:8080 +> environment: +> CONTEXTIONARY_URL: contextionary:9999 +> QUERY_DEFAULTS_LIMIT: 25 +> AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true' +> PERSISTENCE_DATA_PATH: './data' +> ENABLE_MODULES: 'text2vec-contextionary' +> AUTOSCHEMA_ENABLED: 'false' +> contextionary: +> environment: +> OCCURRENCE_WEIGHT_LINEAR_FACTOR: 0.75 +> EXTENSIONS_STORAGE_MODE: weaviate +> EXTENSIONS_STORAGE_ORIGIN: http://weaviate:8080 +> NEIGHBOR_OCCURRENCE_IGNORE_PERCENTILE: 5 +> ENABLE_COMPOUND_SPLITTING: 'false' +> image: cr.weaviate.io/semitechnologies/contextionary:en0.16.0-v1.0.2 +> ``` +> +> ビルドが完了したら、docker compose でこの Weaviate ビルドを実行できます: + +```bash +docker compose up +``` + +
+ +#### Q: Windows で Weaviate を実行できますか? + +
+ 回答 + +Weaviate は、[Docker](/deploy/installation-guides/docker-installation.md) や [WSL](https://learn.microsoft.com/en-us/windows/wsl/) などのコンテナ化された環境を通じて Windows で利用できます。 + +現在、ネイティブ Windows サポートは提供していないため、[Weaviate Embedded](/docs/deploy/installation-guides/embedded.md) のようなデプロイオプションは避けてください。 + +
+ +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/glossary.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/glossary.md new file mode 100644 index 000000000..610448e2b --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/glossary.md @@ -0,0 +1,56 @@ +--- +title: 用語集 +sidebar_position: 4 +description: Weaviate の概念をより理解するための用語集にアクセスします。 +image: og/docs/more-resources.jpg +# tags: ['glossary', 'terminology'] +--- + +import APITable from '@site/src/components/APITable'; + +```mdx-code-block + +``` + +| Term | Description | +| :------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Aggregation** | クエリ結果セットに対して要約や統計情報(オブジェクト数のカウント、プロパティの最小値 / 最大値 / 平均値 など)を計算するプロセスです。通常、 GraphQL `Aggregate{}` 関数を使用して実行します。 | +| **API key** | Weaviate インスタンス(特に Weaviate Cloud)や OpenAI、Cohere などの外部モデルプロバイダーと統合する際の認証に用いられる秘密トークンです。 | +| **Beacon** | Beacon は、 Weaviate もしくはナレッジネットワーク内の特定のデータオブジェクトへの参照です。このデータオブジェクトは ベクトル 空間内にポジションを持ちます。一般的に `weaviate://{peerName}/{className}/{UUID}` の形式で定義されます( Weaviate `v1.14.0` 未満では `weaviate://{peerName}/{UUID}` )。 | +| **Class** | Class は [コレクション](../starter-guides/managing-collections/index.mdx) の旧称で、同じ構造(プロパティ、ベクトライザー設定 など)を共有するデータオブジェクトを格納するコンテナです。 | +| **Concept** | Concept は Entity に関連する概念です。データセットを検索する際に使用されます。たとえば、 _Arnold Schwarzenegger という名前の Actor_ と _Al Pacino という名前の Actor_ がある場合、 _Movie_ や _Terminator_ といった Concept は前者の Actor とより強い関連を持ちます。 | +| **Contextionary** | _dictionary_ と _context_ を組み合わせた造語です。特定言語で使用されるほぼすべての単語に対する ベクトル を含む事前学習済みベクトル空間を指します。 Contextionary( `text2vec-contextionary` )は、 [_単語表現のためのグローバルベクトル_](https://github.com/stanfordnlp/GloVe) のコンセプトに着想を得ており、データセットで使われる言語にコンテキストを与えます。詳細は [こちら](../modules/text2vec-contextionary.md) をご覧ください。 | +| **Embedding model** | テキスト・画像・音声などのデータを数値 ベクトル 表現(Embedding)へ変換する機械学習モデルです。 Vectorizer モジュールの中核コンポーネントとなります。 | +| **Entity** | Entity は、現実世界(の一部)を指す概念です。例: _Apple という名前の Company_ は _iPhone という名前の Product_ と関係づけられる Entity です。 Weaviate の Contextionary は、データ内の可能な限り多くの Entity を特定しようとします。 | +| **Fuzzy** | 多くの他のデータソリューションとは異なり、 Weaviate は [ファジー論理](https://en.wikipedia.org/wiki/Fuzzy_logic) を用いてクエリを解釈します。そのため、従来のデータソリューションでは見つからない回答を得られる可能性があります。 | +| **Generative model** | Weaviate と統合された AI モデル( `generative-openai` などのモジュール経由が多い)で、検索結果から得られるコンテキストを基に新しいコンテンツ(要約や回答 など)を生成できます。 | +| **HNSW** | Hierarchical Navigable Small World の略で、階層型グラフ ベクトル インデックス方式です。 | +| **Inverted index** | データベース内で、プロパティ値からデータオブジェクトの位置へのマッピングを格納するインデックスです(オブジェクトからプロパティ値へマッピングする forward index と対比されます)。 | +| **Model provider integrations** | Weaviate が外部サービス( OpenAI、Cohere、 Hugging Face、 Google Vertex AI など)と接続し、 Embedding モデル、 Generative モデル、 Reranker などをモジュール内で利用できる機能です。 | +| **Multimodal** | テキスト・画像・音声など複数のデータ種別(モダリティ)を同時に処理・理解する能力です。 `multi2vec-clip` などのマルチモーダル ベクトライザー モジュールは、複合的な概念を表す Embedding を生成します。 | +| **Multiple vector embeddings** | 1 つのデータオブジェクトに対して複数の名前付き ベクトル を保存できる機能です。たとえば、コンテンツ用とタイトル用で別々の Embedding を保持し、異なる側面を表現できます。 | +| **Multi-vectors** | Multi-vector embedding、すなわち 1 つのオブジェクトを複数の ベクトル(2 次元行列)で表す手法です。 | +| **NearText** | テキスト入力を受け取り、設定された ベクトライザー モジュールで動的にクエリ ベクトル を生成し、その ベクトル に基づいて類似度検索を行う検索オペレーターです。 | +| **Property** | すべての Class には Property が存在します。例: Class Company には _name_ という Property があるかもしれません。 Weaviate では Property 名の先頭文字が必ず小文字になります。 | +| **Quantization** | ベクトル Embedding のメモリ使用量を削減するための圧縮手法( Product Quantization「 PQ 」や Binary Quantization「 BQ 」など)で、精度を多少犠牲にする代わりに大幅なストレージ / パフォーマンス向上を実現します。 | +| **Reranker** | Weaviate と統合された AI モデル( `reranker-cohere` モジュールなど)で、初期検索結果リストを受け取り、第二の関連度計算で並べ替えることで上位結果の品質を向上させます。 | +| **Replication** | Weaviate クラスター内で、データシャードのコピー(レプリカ)を複数ノードに作成し、ノード障害時のデータ耐久性と高可用性を確保するプロセスです。( Clustering の一部) | +| **Schema** | Weaviate では、追加・クエリ予定のデータ型を定義するために Schema を使用します。詳細は [こちら](../starter-guides/managing-collections/index.mdx) をご覧ください。 | +| **Sharding** | Class のデータとインデックスを水平分割して複数ノード(シャード)に分散させるプロセスです。これにより、データセットサイズとワークロードを単一ノード容量を超えてスケールさせられます。( Clustering の一部) | +| **Vector index** | データを ベクトル(高次元空間の座標とも見なせる長い数値配列)として格納し、コンテキストベース検索を可能にするデータストレージ方式です。 | +| **Vectorizer** | Weaviate 内のモジュール( `text2vec-openai`、 `multi2vec-clip` など)で、データインポート時またはクエリ時( `nearText` など)に指定されたデータプロパティを自動的に ベクトル 埋め込みへ変換します。 | +| **WCS** | Weaviate Cloud Service。 Weaviate のマネージドクラウド提供の旧名称で、現在は Weaviate Cloud( WCD )として知られています。 | +| **[Weaviate Cloud (WCD)](../../cloud/index.mdx)** | WCD は Weaviate のクラウドインスタンスを提供する SaaS です。 | +| **Weaviate Cluster** | マネージド Weaviate クラスターです。 | + +```mdx-code-block + +``` + +## 質問とフィードバック + +import DocsFeedback from '/\_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/index.md new file mode 100644 index 000000000..5138ec335 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/index.md @@ -0,0 +1,37 @@ +--- +title: 追加リソース +sidebar_position: 0 +image: og/docs/more-resources.jpg +# tags: ['More resources'] +--- + +import Badges from '/_includes/badges.mdx'; + + + + +よくある質問に役立つページです: + +- [FAQ](./faq.md) +- [用語集](./glossary.md) +- [サンプルデータセット](./example-datasets.md) +- [ユースケース例](./example-use-cases.md) +- [インデックス種類とパフォーマンス](./performance.md) +- [移行ガイド](/deploy/migration/index.md) + +## 追加リソース(さらに) + +追加情報については、以下の資料もご覧ください。 + +- [ Weaviate コミュニティフォーラム](https://forum.weaviate.io/) +- [過去の Issue のナレッジベース](https://github.com/weaviate/weaviate/issues?utf8=%E2%9C%93&q=label%3Abug) +- [ Weaviate Slack チャンネル](https://weaviate.io/slack) + + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/performance.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/performance.md new file mode 100644 index 000000000..183e2ba56 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/performance.md @@ -0,0 +1,61 @@ +--- +title: インデックスタイプとパフォーマンス +sidebar_position: 7 +image: og/docs/more-resources.jpg +# tags: ['performance'] +--- + +Weaviate はパフォーマンス目標を達成するために、さまざまなインデックスタイプを使用します。 +このページでは、 [ HNSW ](https://arxiv.org/abs/1603.09320) と [ 転置インデックス ](https://en.wikipedia.org/wiki/Inverted_index) に焦点を当てます。 + +以下のインデックスが利用可能です。 + +ベクトルインデックス: + +- [HNSW](/weaviate/config-refs/indexing/vector-index.mdx#hnsw-index) +- [Flat](/weaviate/config-refs/indexing/vector-index.mdx#flat-index) + +従来型インデックス: + +- [Inverted index](#inverted-index) + +## 転置インデックス +転置インデックスは、ベクトルやセマンティクスを必要とせずに結果を見つける [ GraphQL `where` フィルター](../api/graphql/filters.md) を支える仕組みです。転置インデックスでは、単語や数値などのコンテンツやデータオブジェクトのプロパティが、データベース内の位置にマッピングされます。これは、ドキュメントからその内容へマッピングする従来のフォワードインデックスとは逆の構造です。 + +転置インデックスはドキュメント検索システムや検索エンジンでよく使用され、ブルートフォースを用いずに高速な全文検索やキー検索を可能にします。この高速なデータ取得の代償は、新しいデータオブジェクト追加時の処理時間がわずかに増えることだけです。これは、データオブジェクトを単に保存するのではなく、転置方式でインデックス化・保存する必要があるためです。データベース(Weaviate)には、すべての転置インデックスを保持する大きなルックアップテーブルがあります。特定のプロパティやコンテンツを持つオブジェクトを取得したい場合、データベースはそのプロパティを含む 1 行のみを検索し、関連するデータオブジェクト(行にはデータオブジェクト ID へのポインタが格納されています)を指し示します。これにより、この種のクエリでのデータオブジェクト取得は非常に高速になります。エントリーが 10 億件以上あっても、特定の単語やプロパティを含むエントリーだけを対象にする場合、読まれるのはポインタを含む 1 行だけです。 + +転置インデックスは現在、ソートのための重み付け(例: tf-idf)を行いません。これらの機能にはベクトルインデックスが使用されるためです。そのため転置インデックスは現状、結果リストからデータオブジェクトを含めるか除外するかの二択、いわば「許可リスト」を作るためのバイナリ操作となります。 + +## ベクトルインデックス +ベクトルを持つすべてのデータオブジェクトは、ベクトルインデックスにも登録されます。Weaviate は現在、 [ HNSW ](https://arxiv.org/abs/1603.09320) と Flat のベクトルインデックスをサポートしています。 + +詳細は [Concepts: vector index](../concepts/indexing/vector-index.md) をご覧ください。 + +## クエリおよび操作のコスト + +このセクションでは、一般的な操作のコストについて説明します。 + +### データインポートのコスト +現時点では、HNSW インデックス化の影響でデータインポートはクエリ時間に比べて相対的に遅くなります。もっとも安価なデータインポート操作は、以前に存在しなかったデータオブジェクトの単純な書き込みです。まったく新しいインデックスが付与されます。データオブジェクトを更新する場合も安価で、バックエンドではまったく新しいオブジェクトが作成され、新規オブジェクトとしてインデックス化されます。古いオブジェクトは非同期でクリーンアップされるため、その分の時間が追加でかかります。 + +### クエリのコスト +`where` フィルターのみを持つ単純な `Get` クエリは非常に安価で、 [転置インデックス](#inverted-index) が使用されます。`explore` フィルター(ベクトル検索)のみを使用する単純な `Get` クエリも同様に安価で、高速なベクトルインデックス HNSW が利用されます。2,000 万〜 1 億件以上のデータセットでも、20NN ベクトルクエリで 50ms 未満が可能です。Weaviate は複数のキャッシュに依存していますが、すべてのベクトルをメモリに常駐させる必要はありません。そのため、全ベクトルサイズよりメモリが少ないマシンでも Weaviate を実行できます。 + +`explore`(ベクトル)と `where` フィルターを 1 つの検索クエリで組み合わせる(これが Weaviate の特長)は、わずかに高コストになります。まず転置インデックスが呼び出され、`where` フィルターに一致するすべてのデータアイテムを返します。そのリストが HNSW によるベクトルインデックス検索に渡されます。この複合操作のコストは、データセットサイズと転置インデックス検索で返されたデータ量に依存します。`where` フィルターの結果が少ないほど、ベクトル検索がスキップする項目が増え時間が延びます。ただし、差は非常に小さく、体感できない程度です。 + +### 参照解決のコスト +Weaviate はグラフライクなデータモデルを持つデータベースですが、純粋なグラフデータベースではありません。グラフデータベースはリンクや参照を辿る操作が安価であり、複数アイテムを検索するよりリンククエリが安価です。一方、Weaviate は [ベクトルデータベース](https://weaviate.io/blog/what-is-a-vector-database) です。そのため、Weaviate で最も安価な操作の 1 つはデータのリスト取得であり、従来のグラフデータベースでは高コストになる操作です。Weaviate にはベクトル検索を中心としつつグラフ機能も備わっています。そのため、転置インデックスやベクトルインデックスによる検索が主目的でありながら、データオブジェクト間のグラフ参照も提供します。結果として、データオブジェクトの検索に比べ、グラフ参照の検索・追跡・取得は最適化の度合いが低く、より多くのクエリ時間を要します。 + +特に重要なのは、データオブジェクト間の接続数が多いほど、また単一クエリでより深く辿るほどクエリコストが増大する点です。こうしたクエリを扱う最良の方法は、*広く*かつ*深く*検索しないことです。多くのネスト参照を解決する必要がある場合は、返却件数(limit)を低く設定してください。また、すべての参照を一度に解決しないことも有効です。クエリに応じて複数クエリに分割できます。実際には、まずトップ 100 のデータオブジェクトを取得し、関心のある上位 5 件のみで深い参照を取得するといった方法が考えられます。 + +### 参照によるフィルターのコスト +ネストした参照フィルターを使用する場合、Weaviate は最も深い参照を解決してから、内側の層へと順に上がって他の参照を解決します。つまり、最深層の参照のビーコンを最初に取得します。これにより他の層では転置インデックスのルックアップを使用でき、マッチングは比較的安価になります。しかし、フィルター内にネスト参照を持つクエリは、それでも複数検索(各ネスト層ごと)が行われ、その結果を一つに結合する必要があるため比較的高コストです。内部層で大量の結果が返されるほど、一つ上の層が検索すべき対象が増えるため、コストは理論的には指数的に上がり得ます。 + +ネストの深いフィルターは可能な限り避けてください。また、クエリをできる限り制限的にするのも有効です。たとえば 10 階層のクエリでも、各階層が 1 件のみを返すのであればそれほど高コストではありません。この場合、1 件検索を 10 回実行するだけなので、クエリ内の検索回数は多いものの、各検索自体は非常に安価です。 + +## 質問とフィードバック + +import DocsFeedback from '/_includes/docs-feedback.mdx'; + + + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/write-great-bug-reports.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/write-great-bug-reports.md new file mode 100644 index 000000000..5f060d4d4 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/more-resources/write-great-bug-reports.md @@ -0,0 +1,58 @@ +--- +title: 優れたバグ報告を作成する方法 +sidebar_position: 99 +image: og/docs/more-resources.jpg +# tags: ['how to', 'reporting a bug', 'bugfix', 'reproducing example'] +--- + + +## 優れたバグ報告を作成する + +このページでは、理想的なバグ報告がどのようなものかを説明します。完璧なバグ報告を書くことが常に可能とは限らず、すべての情報を提供できないからといってバグ報告をためらってほしくはありません。ただし、エンジニアの作業を少しでも楽にできるよう、役立つ情報をお伝えします。また、バグのチケットをどの順番で対応するかを優先付けする必要がある場合もあります。十分に準備されたバグ報告は、先に対応される可能性が高くなります。 + +### 優れたバグ報告を際立たせる要素 + +以下のポイントが、バグ報告を優れたものにします。 + +- **コンテキストの提供** + 特定のユースケースに取り組んでいたり、長い間特定のバグと格闘している場合、あなたやチームの頭の中には多くのコンテキストがあるでしょう。しかし、そのコンテキストはバグ報告をエンジニアに引き渡す際に失われがちです。エンジニアは全く別の作業をしていた可能性が高く、あなたにとって当たり前の目標や前提を理解しにくい場合があります。優れたバグ報告はそのコンテキストを設定し、社内外のどのエンジニアでも容易にチケットに取り組めるようにします。 + +- **適切な情報量** + バグの種類によって必要となる情報は異なります。例として 2 つのバグを考えてみましょう。1 つ目は `img2vec` モジュールを使用した際に画像が正しくベクトル化されず、結果が狂ってしまうケース。2 つ目は ID でのルックアップが予想よりもかなり遅いケースです。どちらも正当なバグですが、それぞれに必要な情報は異なります。画像ベクトル化のバグでは `img2vec` モジュールの詳細が必要です。使用したバージョンは?どの推論コンテナを実行していたか?GPU は使用していたか?画像のファイル形式は?一方、パフォーマンスのバグではハードウェアに関する情報が重要です。マシンのサイズは?どの種類のディスクを使用していたか?遅いクエリ実行中の CPU 使用率、メモリ使用量、ディスク圧迫状況は?など。すべての内部を理解している必要はありませんが、バグを再現するのに役立つ詳細と不要な詳細を考えてみてください。 + +- **再現が容易** + すべてのバグは重要で、私たちはどの報告にも感謝しています。しかし、優先順位を付ける必要があります。再現しやすいバグ報告は取り組みやすいです。優れたバグ報告には、事前状態を仮定せず完全にバグを再現できる例が含まれています。以下にバグ報告における良い再現例の例を示します。 + +- **特定のエリアに絞り込まれている** + Weaviate は Weaviate サーバーだけでなく、言語別の Weaviate クライアントや任意のモジュールなど、エコシステム全体で構成されています。モジュールが機械学習モデルを使用する場合は独自の推論コンテナを持つこともあります。優れたバグ報告は問題がどこで発生しているかをできるだけ絞り込みます。どこでバグが起きているかを確認するためのヒントを下に示します。 + +ここまでで *何* が優れたバグ報告を構成するかを確認しました。次は個々の分野を見て、*どのように* すればより良い報告を書けるかを説明します。 + +## 常に提供すべき最小限の情報とコンテキスト + +- 使用したすべてのバージョンを明示してください。最低限、 Weaviate サーバーとクライアントのバージョンが必要です。 +- 最近のバージョンでバグが導入された可能性がある場合は、問題が発生しない最後のバージョンも報告してください。 +- バグの再現に重要なモジュールがある場合は、そのモジュールを指定してください。モジュールが複数のモデルを使用する場合は、モデル名も指定してください。 + +## 良い再現例の提供方法 + +- 優れた再現例は状態を一切仮定しません。必ず空の Weaviate インスタンスから始め、バグ再現に必要なオブジェクトをインポートします。エンジニアは読み取り / 検索クエリだけからインポートすべきオブジェクトを推測できません。 +- エラー再現に必要なものはすべて再現例の一部に含めてください。エンジニアが例をコピー&ペーストするだけで問題を確認できるようにします。 +- 再現例はコードで表現してください。これは Weaviate の言語クライアントでも、`curl` コマンドの一連でも構いません。 +- 再現例には期待していた動作を明記してください。実際の挙動が望ましくない理由が明白でない場合があります。代わりに何が起こるべきだったかをコード、コードコメント、または付随テキストで伝えてください。 + +## 問題が Weaviate、クライアント、その他のどこで発生しているかの判別方法 + +- 問題が Weaviate サーバーではなくクライアントにあると思われる場合は、別の言語クライアントまたはクライアントを使用しない方法で同様のリクエストを送信して確認できます。後者が最も確実で、クライアントの問題を完全に排除できます。純粋な HTTP(例: `curl`, Postman など)でリクエストを送ってもエラーが再現する場合、そのエラーは Weaviate サーバー側で発生しています。 +- 言語クライアントからスタックトレースが表示された場合は、エラーがどこで発生したかを推測できます。スタックトレースにネットワークリクエスト、2xx 以外の HTTP ステータスコード、シャードやインデックスに関するエラーメッセージが含まれている場合、バグは Weaviate サーバー内で発生している可能性が高いです。反対に、その言語特有の内容が多い場合はクライアント側のエラーを示唆します。 +- Kubernetes で実行するために `weaviate-helm` リポジトリなど、 Weaviate エコシステムの他のツールを使用している場合、それらの設定で問題が発生する可能性もあります。ランタイムやマニフェスト固有のバグと思われる場合は、別のランタイムでも試してみてください。すでに試したことがあれば教えてください。 + +## 上記の情報を提供することが困難な場合 + +心配はいりません。バグが複雑で再現が容易でないこともあると理解しています。完璧なバグ報告を書くのが難しい場合でも、ぜひ報告してください。良い報告を作成しようとしてくださる姿勢を私たちは大いに歓迎します。 + +## ありがとうございます + +Weaviate へのバグ報告は Weaviate への貢献です。私たちは、 +問題を報告し、Weaviate を改善するために時間を割いてくださり、本当に感謝しています。ありがとうございます! + diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/_category_.json b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/_category_.json new file mode 100644 index 000000000..60eb4886c --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Quickstart", + "position": 10 +} \ No newline at end of file diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/WCS-screenshot.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/WCS-screenshot.png new file mode 100644 index 000000000..4b818549f Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/WCS-screenshot.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/cluster_admin_key.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/cluster_admin_key.png new file mode 100644 index 000000000..aa3a731cc Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/cluster_admin_key.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/cluster_url.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/cluster_url.png new file mode 100644 index 000000000..4dbc7bb7e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/cluster_url.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/create_cluster.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/create_cluster.png new file mode 100644 index 000000000..53941b993 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/create_cluster.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/create_sandbox.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/create_sandbox.png new file mode 100644 index 000000000..ae33257fa Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/create_sandbox.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/enable_embeddings.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/enable_embeddings.png new file mode 100644 index 000000000..74796a3f0 Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/enable_embeddings.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/wcd_register.png b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/wcd_register.png new file mode 100644 index 000000000..c13caa72e Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/wcd_register.png differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/weaviate-cluster.jpg b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/weaviate-cluster.jpg new file mode 100644 index 000000000..84a0f65dd Binary files /dev/null and b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/img/weaviate-cluster.jpg differ diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/index.md b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/index.md new file mode 100644 index 000000000..f9e1ec022 --- /dev/null +++ b/i18n/ja/docusaurus-plugin-content-docs/current/weaviate/quickstart/index.md @@ -0,0 +1,622 @@ +--- +title: クイックスタート(クラウドリソース使用) +sidebar_position: 0 +image: og/docs/quickstart-tutorial.jpg +# tags: ['getting started'] +hide_table_of_contents: true +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import SkipLink from '/src/components/SkipValidationLink' + +想定所要時間: 30 分 前提条件: なし +

+ +:::info 学習内容 + +このクイックスタートでは、Weaviate Cloud と Cohere を組み合わせて次のことを行う方法を説明します。 + +1. Weaviate インスタンスをセットアップします。(10 分) +1. データを追加して ベクトル 化します。(10 分) +1. セマンティック検索と 検索拡張生成 (RAG) を実行します。(10 分) + +```mermaid +flowchart LR + %% Define nodes with white backgrounds and darker borders + A1["Create Weaviate
Sandbox"] --> A2["Install client
library"] + A2 --> A3["Connect to
Weaviate"] + A3 --> B1["Define collection
(with an inference API)"] + B1 --> B2["Batch import
objects"] + B2 --> C1["Semantic search
(nearText)"] + C1 --> C2["RAG
(Generate)"] + + %% Group nodes in subgraphs with brand colors + subgraph sg1 ["1\. Setup"] + A1 + A2 + A3 + end + + subgraph sg2 ["2\. Populate"] + B1 + B2 + end + + subgraph sg3 ["3\. Query"] + C1 + C2 + end + + %% Style nodes with white background and darker borders + style A1 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style A2 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style A3 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style B1 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style B2 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style C1 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + style C2 fill:#ffffff,stroke:#B9C8DF,color:#130C49 + + %% Style subgraphs with brand colors + style sg1 fill:#ffffff,stroke:#61BD73,stroke-width:2px,color:#130C49 + style sg2 fill:#ffffff,stroke:#130C49,stroke-width:2px,color:#130C49 + style sg3 fill:#ffffff,stroke:#7AD6EB,stroke-width:2px,color:#130C49 +``` + +Notes: + +- ここにあるコード例は自己完結型です。コピー&ペーストしてご自身の環境でお試しください。 + +- ローカルホスト環境を使用したい場合は、[Quickstart: locally hosted](./local.md) をご覧ください。 + +::: + +### 必要なもの + +最後のステップで 検索拡張生成 (RAG) を行うには、[Cohere](https://dashboard.cohere.com/) アカウントが必要です。無料の Cohere トライアル API キーを使用できます。 + +別の [モデル プロバイダー](/weaviate/model-providers) をお持ちの場合は、Cohere の代わりにそちらを使用できます。 + +
+ +## ステップ 1: Weaviate のセットアップ + +### 1.1 Weaviate データベースの作成 + +[Weaviate Cloud コンソール](https://console.weaviate.cloud) にアクセスし、無料の Sandbox インスタンスを作成します。 + +
+