klotz: summarization* + python*

0 bookmark(s) - Sort by: Date ↓ / Title / - Bookmarks from other users for this tag

  1. Here’s the simplest version — key sentence extraction:


    <pre>
    ```
    def extract_relevant_sentences(document, query, top_k=5):
    sentences = document.split('.')
    query_embedding = embed(query)
    scored = »
    for sentence in sentences:
    similarity = cosine_sim(query_embedding, embed(sentence))
    scored.append((sentence, similarity))
    scored.sort(key=lambda x: x 1 » , reverse=True)
    return '. '.join( s[0 » for s in scored :top_k » ])
    ```
    </pre>

    For each sentence, compute similarity to the query. Keep the top 5. Discard the rest
  2. 2016-03-15 Tags: , , , by klotz

Top of the page

First / Previous / Next / Last / Page 1 of 0 SemanticScuttle - klotz.me: Tags: summarization + python

About - Propulsed by SemanticScuttle