Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,16 @@ queries.

## Installation
```
pip install git+https://github.com/TakoData/QueryFilter.git@0.1.2
pip install git+https://github.com/TakoData/QueryFilter.git@0.1.4
```
With embeddings support, which pulls in the large `sentence-transformers` package:
```
pip install "git+https://github.com/TakoData/QueryFilter.git@0.1.2#egg=tako-query-filter[embeddings]"
```

## Usage

### Prerequisites
- Get access to Tako Hugging Face repositories
- Install and init `git-lfs`
- Log into Hugging Face using `huggingface-cli login`

### Examples
See the [demo notebook](demo.ipynb) for a more interactive example.

```
from tako_query_filter.filter import TakoQueryFilter

query_filter = TakoQueryFilter.load_from_hf()
query_filter = TakoQueryFilter.load_with_keywords()

queries = [
"aapl vs nvda",
Expand All @@ -42,7 +31,6 @@ queries = [

query_filter.predict(queries)
```
You can also use the `force_download` flag to download the latest version of the models from HuggingFace.

## License

Expand Down
23 changes: 4 additions & 19 deletions demo.ipynb
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Make sure you are logged in to Hugging Face\n",
"!huggingface-cli login --token \"hf_my-hf-token\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -23,19 +13,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"from tako_query_filter.filter import TakoQueryFilter\n",
"\n",
"query_filter = TakoQueryFilter.load_from_hf(force_download=True)\n",
"# Alternatively, you can load from local paths\n",
"# query_filter = TakoQueryFilter.load_from_local(\n",
"# topic_model_path=\"local-scikit-model-path/topic_model.pkl\",\n",
"# spacy_model_path=\"local-spacy-model-path\",\n",
"# keywords_path=\"local-scikit-model-path/topic_model.pkl\"\n",
"# )\n"
"query_filter = TakoQueryFilter.load_with_keywords()\n"
]
},
{
Expand All @@ -53,10 +37,11 @@
" \"trump vs. harris\",\n",
" \"algae\",\n",
" \"san francisco game this week\",\n",
" \"what college did michael phelps go to\"\n",
" \"what college did michael phelps go to\",\n",
" \"election 2024\",\n",
" \"election results\",\n",
" \"presidential election polls 2024\",\n",
" \"what books do you recommend\",\n",
"]\n",
"\n",
"preds = query_filter.predict(queries)\n",
Expand Down
Loading