Skip to content

Commit

Permalink
updated demo, remove cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
brainsqueeze committed Jul 7, 2022
1 parent a18f607 commit 3b974a5
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 589 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,17 @@ Text2vec includes a Python API with convenient classes for handling attention an
## Inference Demo
---

Once a model is fully trained then a demo API can be run, along with a small UI to interact with the REST API. This demo attempts to use the trained model to condense long bodies of text into the most important sentences, using the inferred embedded context vectors.

Trained text2vec models can be demonstrated from a lightweight app included in this repository. The demo runs extractive summarization from long bodies of text using the attention vectors of the encoding latent space. To get started, you will need to clone the repository and then install additional dependencies:
```bash
git clone https://github.com/brainsqueeze/text2vec.git
cd text2vec
pip install flask tornado
```
To start the model server simply run
```bash
text2vec_main --run=infer --yaml_config=/path/to/config.yml
python demo/api.py --model_dir /absolute/saved_model/parent/dir
```
A demonstration webpage is included in [demo](demo) at
[context.html](demo/context.html).
The `model_dir` CLI parameter must be an absolute path to the directory containing the `/saved_model` folder and the `tokenizer.json` file from a text2vec model with an `embed` signature. A demonstration app is served on port 9090.

## References
---
Expand Down
3 changes: 0 additions & 3 deletions demo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import re

from flask import Flask, request, Response, send_from_directory
from flask_cors import cross_origin
from tornado.log import enable_pretty_logging
from tornado.httpserver import HTTPServer
from tornado.wsgi import WSGIContainer
from tornado.ioloop import IOLoop
import tornado.autoreload
# from tornado import web
import tornado

import tensorflow as tf
Expand Down Expand Up @@ -79,7 +77,6 @@ def root():


@app.route("/summarize", methods=["GET", "POST"])
# @cross_origin(origins=['*'], allow_headers=['Content-Type', 'Authorization'])
def summarize():
if request.is_json:
payload = request.json
Expand Down
4 changes: 2 additions & 2 deletions examples/trainers/news_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def train_tokenizer() -> Tuple[tokenizers.Tokenizer, tf.data.Dataset]:
pre_tokenizers.Digits(individual_digits=False)
])

dataset = datasets.load_dataset("multi_news", split="train")
dataset = datasets.load_dataset("multi_news", split="test")

def batch_iterator(batch_size=1000):
for i in range(0, len(dataset), batch_size):
Expand Down Expand Up @@ -126,7 +126,7 @@ def main(save_path: str):
)
)
],
epochs=10
epochs=2
)

model.save(
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
extras_require=dict(
serving=[
"flask",
"flask-cors",
"nltk",
"tornado"
]
),
Expand Down
Empty file removed text2vec/bin/__init__.py
Empty file.
266 changes: 0 additions & 266 deletions text2vec/bin/main.py

This file was deleted.

53 changes: 0 additions & 53 deletions text2vec/bin/serving_tools.py

This file was deleted.

Loading

0 comments on commit 3b974a5

Please sign in to comment.