hoarder-app / hoarder

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
https://hoarder.app
GNU Affero General Public License v3.0
6.63k stars 240 forks source link

Request: Use LLM (if provided) to generate a summary of the bookmark #523

Open michael-j-green opened 1 month ago

michael-j-green commented 1 month ago

Since we’re using the LLM to generate tags, it might also be useful to generate a short summary of the page’s content.

joekaiser commented 1 month ago

Fabric has an extract_wisdom prompt that would probably work well for this

MohamedBassem commented 1 month ago

This is coming in the next release!

https://github.com/user-attachments/assets/0e8c9869-eba5-410c-87cc-521479f0e9d3

michael-j-green commented 1 month ago

Awesome :) The implementation looks really really good!

Would this be generated at fetch time? Or only on demand?

MohamedBassem commented 1 month ago

@michael-j-green My plan is to have both. So far, I've implemented the on-demand version only.

michael-j-green commented 1 month ago

Figured that would be the case. Always good to ask though!

bhupesh-sf commented 3 weeks ago

Loving this one

ProjectMoon commented 6 days ago

A suggested improvement for this after using it with Llama3.2 at Q5_K_M on ollama: Add an instruction to the summarization prompt to reply ONLY with the summary. When using llama 3.2, I get "Here's a 3 to 4 sentence summary: [...]".

Current prompt:

  const constructPrompt = (c: string) => `
    Summarize the following content in a 3-4 sentences in ${lang}:
    ${c}`;

Suggested new prompt: Summarize the following content in 3-4 sentences in ${lang}, responding ONLY with the summary:

This adds an instruction to respond only with the summary, and also corrects a minor typo (removal of a).

Alternatively, something like "Respond with a 3-4 sentence summary [...]" may work?

MohamedBassem commented 3 days ago

@ProjectMoon great idea. Modified the prompt in https://github.com/hoarder-app/hoarder/commit/b9f1a59d9997cc24239a9d4778110c0f6631fbc8

ProjectMoon commented 3 days ago

Tested it with latest just now. Works perfectly.