Token Classification
LiteRT
LiteRT
GLiFormer
English
android
named-entity-recognition
information-extraction
deberta
Instructions to use litert-community/GLiFormer-Large-NER-LiteRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/GLiFormer-Large-NER-LiteRT with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- GLiFormer
How to use litert-community/GLiFormer-Large-NER-LiteRT with GLiFormer:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
GLiFormer Large v1 NER for LiteRT: card, host runtime, contracts, licenses, checksums
5cee4fa verified Download examples/run_example.py from litert-community/GLiFormer-Large-NER-LiteRT: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/litert-community/GLiFormer-Large-NER-LiteRT/resolve/main/examples/run_example.py
- Command line
-
hf download hf://litert-community/GLiFormer-Large-NER-LiteRT/examples/run_example.py
-
curl -L -o run_example.py https://huggingface.co/litert-community/GLiFormer-Large-NER-LiteRT/resolve/main/examples/run_example.py
2.34 kB
| """Run one offline extract call and compare with the packaged source-oracle fixture.""" | |
| import argparse | |
| import json | |
| import os | |
| from pathlib import Path | |
| import sys | |
| sys.dont_write_bytecode = True | |
| os.environ['HF_HUB_OFFLINE'] = '1' | |
| os.environ['TRANSFORMERS_OFFLINE'] = '1' | |
| os.environ['TOKENIZERS_PARALLELISM'] = 'false' | |
| def main(): | |
| assets = Path(__file__).resolve().parents[1] / 'host_assets' | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--seq', type=int, choices=(128, 256, 512), default=None, | |
| help='Validation override; normally the runtime chooses the smallest window') | |
| parser.add_argument('--table', choices=('fp32', 'fp16'), default='fp32') | |
| parser.add_argument('--result', type=Path) | |
| args = parser.parse_args() | |
| sys.path.insert(0, str(assets)) | |
| import torch | |
| from runtime import HostRuntime, compare_entities | |
| from runtime.host_runtime import LABELS | |
| torch.set_num_threads(4) | |
| example = json.loads((assets/'example.json').read_text()) | |
| with HostRuntime(assets, table=args.table) as host: | |
| if args.seq is None: | |
| entities = host.extract(example['text'], LABELS) | |
| details = host.last_result | |
| else: | |
| details = host.extract_with_details(example['text'], LABELS, seq=args.seq) | |
| entities = details['entities'] | |
| comparison = compare_entities(entities, example['entities']) | |
| passed = details['all_finite'] and comparison['span_sets_equal'] and comparison['max_score_diff'] <= 1e-2 | |
| capture = details['captured'] | |
| result = {'status': 'PASS' if passed else 'FAIL', 'text': example['text'], 'entities': entities, | |
| 'comparison': comparison, 'score_atol': 1e-2, 'selected_shape': details['selected_shape'], | |
| 'graph_roles': list(details['backends']), 'backends': details['backends'], | |
| 'embedding_table': args.table, 'encoded_length': capture['encoded_length'], | |
| 'text_word_length': capture['text_word_length'], 'all_finite': details['all_finite'], | |
| 'HF_HUB_OFFLINE': os.environ['HF_HUB_OFFLINE']} | |
| if args.result: | |
| args.result.write_text(json.dumps(result, indent=2)+'\n') | |
| print(json.dumps(result, indent=2)) | |
| return 0 if passed else 2 | |
| if __name__ == '__main__': | |
| raise SystemExit(main()) | |