Giter Club home page Giter Club logo

keyspacy's Introduction

KeySpaCy

KeySpaCy is a spaCy integration of KeyBERT by rewriting the embedding backend. It is designed to be a component of TRANSFORMER-BASED spacy pipeline, e.g, the en_core_web_trf pre-trained pipeline. Unlike KeyBERT, we only use pre-computed token contextualized embeddings to measure doc-substring similarities (KeyBERT compute document and keyphrase embeddings independently, resulting in recomputing overhead).

Table of Contents

1. About the Project

2. Getting Started

2.1 Installation

TBD

2.2 Usage

The most minimal example can be seen below for the extraction of keywords:

import spacy
import keyspacy

text = """
    Supervised learning is the machine learning task of learning a function that
    maps an input to an output based on example input-output pairs. It infers a
    function from labeled training data consisting of a set of training examples.
    In supervised learning, each example is a pair consisting of an input object
    (typically a vector) and a desired output value (also called the supervisory signal).
    A supervised learning algorithm analyzes the training data and produces an inferred function,
    which can be used for mapping new examples. An optimal scenario will allow for the
    algorithm to correctly determine the class labels for unseen instances. This requires
    the learning algorithm to generalize from the training data to unseen situations in a
    'reasonable' way (see inductive bias).
"""

# Transformer-based spacy pipeline is required
nlp = spacy.load('en_core_web_trf')
nlp.add_pipe(keyspacy.component_name)

# Add extraction extension by piping through `nlp`
doc = nlp(text)
keywords, vocab = doc._.extract_keywords()

You can set keyphrase_ngram_range to set the length of the resulting keywords/keyphrases:

>>> keywords, vocab = doc._.extract_keywords(keyphrase_ngram_range=(1, 1))
>>> keywords
[('learning', 0.7793),
 ('input', 0.7528),
 ('output', 0.7306),
 ('example', 0.6977),
 ('algorithm', 0.6884)]

keyspacy's People

Contributors

guest400123064 avatar

Stargazers

Vince Fulco--Bighire.tools avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.