Skip to content

sugoikondo/albert_word_similarity_api

Repository files navigation

albert_word_similarity_api

API that calculates and returns the similarity between words. Currently only Japanese is supported.

Getting Started

Docker (Docker Compose)

docker-compose up -d

On local environment

Prerequisites

  • Python 3.10.6
  • poetry 1.1.6 or higher

Project set up

First, you need to install dependencies.

poetry install

Next, start and enter the virtual environment.

poetry shell

Then you can run application server.

uvicorn main:app --reload

Usage

When you send requests to POST /word_similarity, with body like this:

{
  "target_words": ["銀行"],
  "candidates": ["現金", "リース資産", "貸倒引当金", "当座預金"],
  "top_n": 3
}

Then you can obtain below result

{
    "results": [
        {
            "word": "銀行",
            "similar_words": [
                {
                    "word": "現金",
                    "similarity": 0.8859629034996033
                },
                {
                    "word": "リース資産",
                    "similarity": 0.8650936484336853
                },
                {
                    "word": "当座預金",
                    "similarity": 0.7373276352882385
                }
            ]
        }
    ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published