More experimentation
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
This commit is contained in:
parent
c01d55d291
commit
c11880483d
43 changed files with 749 additions and 496 deletions
1
example/.gitignore
vendored
1
example/.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
data
|
||||
.ipynb_checkpoints
|
||||
tracing_database.json
|
||||
|
|
|
|||
12
example/README.md
Normal file
12
example/README.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Train Domain classifier from the [semantic scholar dataset](https://api.semanticscholar.org/corpus)
|
||||
|
||||
## Upload the dataset (or a part of it) to shared infrastructure
|
||||
|
||||
```sh
|
||||
mkdir ss-data && cd ss-data
|
||||
wget https://s3-us-west-2.amazonaws.com/ai2-s2-research-public/open-corpus/2022-02-01/manifest.txt
|
||||
wget -B https://s3-us-west-2.amazonaws.com/ai2-s2-research-public/open-corpus/2022-02-01/ -i manifest.txt
|
||||
cd -
|
||||
python3 -m good_ai.open_s3 --secrets s3.ini --push ss-data
|
||||
rm -rf ss-data
|
||||
```
|
||||
|
|
@ -1,15 +1,21 @@
|
|||
import json
|
||||
from random import shuffle
|
||||
|
||||
from devtools import debug
|
||||
from predict_domain import predict_domain
|
||||
|
||||
from good_ai import LargeFile, process_batch
|
||||
from good_ai import process_batch
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open("data/s2-corpus-1583.json") as f:
|
||||
with open(".cache/ss-data-0/s2-corpus-1583.json") as f:
|
||||
raw = json.load(f)
|
||||
|
||||
LargeFile.configure_credentials_from_file("s3.ini")
|
||||
|
||||
shuffle(raw)
|
||||
data = {f'{r["title"]} {r["abstract"]}': r["domain"] for r in raw[:5]}
|
||||
|
||||
print(process_batch(predict_domain, ["We have found a new type of chemical."]))
|
||||
results = process_batch(predict_domain, data.keys())
|
||||
|
||||
for predicted, actual in zip(results, data.values()):
|
||||
print(", ".join(actual))
|
||||
debug(predicted)
|
||||
print()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ def predict_domain(
|
|||
)
|
||||
)
|
||||
|
||||
if sum(r.probability for r in results) >= cut_off_probability:
|
||||
if sum(r.probability for r in results) >= cut_off_probability * 100:
|
||||
break
|
||||
|
||||
return results
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue