# KeyAtten

A zero-shot keyword and keyphrase extraction library that reads keywords directly out of a pretrained language model's attention weights, no fine-tuning or labeling required.

KeyAtten extracts keywords and keyphrases from text using a pretrained model's own attention weights in a single forward pass, with no training or labeling step, and supports both Chinese and English. It is evaluated on seven public datasets against 14 other methods, reporting a 67% F1@10 improvement over traditional baselines on Chinese news and a 78% improvement over the strongest external method on English long documents.

Its main route replaces the default candidate set with BIO-tagged candidates and reranks them with fine-tuned attention; standalone attention-series methods (received attention, SAMRank, fusion attention and their inverse-document-frequency variants) are also available, alongside legacy baselines for comparison. Word-level output includes the weight value, position index and part-of-speech tag, and attention can be fused across a single layer or multiple layers.

It installs with pip; a minimal install pulls in only numpy, so the full machine-learning stack is opt-in.

Website: https://github.com/Qingfeng-233/KeyAtten
