10 ms·
We've had the best success by first converting the HTML to a simpler format (i.e. markdown) before passing it to the LLM. There are a few ways to do this that
by jumploops 2y ago
We've had the best success by first converting the HTML to a simpler format (i.e. markdown) before passing it to the LLM.
There are a few ways to do this that we've tried, namely Extractus[0] and dom-to-semantic-markdown[1].
Internally we use Apify[2] and Firecrawl[3] for Magic Loops[4] that run in the cloud, both of which have options for simplifying pages built-in, but for our Chrome Extension we use dom-to-semantic-markdown.
Similar to the article, we're currently exploring a user-assisted flow to generate XPaths for a given site, which we can then use to extract specific elements before hitting the LLM.
By simplifying the "problem" we've had decent success, even with GPT-4o mini.
[0] https://github.com/extractus https://github.com/extractus
[1] https://github.com/romansky/dom-to-semantic-markdown https://github.com/romansky/dom-to-semantic-markdown
[2] https://apify.com/ https://apify.com/
[3] https://www.firecrawl.dev/ https://www.firecrawl.dev/
[4] https://magicloops.dev/ https://magicloops.dev/
- pkiv 2y agoIf you're open to it, I'd love to hear what you think of what we're building at https://browserbase.com/ https://browserbase.com/ - you can run a chrome extension on a headless browser so you can do the semantic markdown within the browser, before pulling anything off. We even have an iFrame-able live view of the browser, so your users can get real-time feedback on the XPaths they're generating: https://docs.browserbase.com/features/session-live-view#give-control-over-the-session-to-your-end-users https://docs.browserbase.com/features/session-live-view#give... Happy to answer any questions!
- maeil 2y agoAm I correct that the use case of doing this is 1. Scale and 2. Defeating Cloudflare et. al? I do scraping, but I struggle to see what these tools are offering, but maybe I'm just not the target audience. If the websites don't have much anti-scraping protection to speak of, and I only do a few pages per day, is there still something I can get out of using a tool like Browserbase? I wonder because of this talk about semantic markdown and LLMs, what's the benefit between writing (or even having an AI write) standard fetching and parsing code using playwright/beautifulsoup/cheerio?
- sunshadow 2y agoI don't see any difference than browserless?
- pkiv 2y agoThe price and the dashboard are a great start :)
- jumploops 2y agoThis is super neat and I think I've seen your site before :) Do you handle authentication? We have lots of users that want to automate some part of their daily workflow but the pages are often behind a login and/or require a few clicks to reach the desired content. Happy to chat: username@gmail.com
- retrofuturism 2y agoYou must get a lot of test emails to that FANTASTIC gmail address. Funny how it might even be worth some decent money.
- spyder 2y agoThat's not literally his e-mail :D. He means that you have to replace it with his HN username. It would have been better to write it like this: [HN username]@gmail.com
- delfinom 2y agoPersonally I thought it was a LLM reply to a LLM marketing post to fake engagement. Lol
- jumploops 2y agoInstructions unclear, here's a haiku about faking engagement: Beneath the deep waves, False likes in shadows do dance, Submarine ploys drift.
- retrofuturism 2y agoHahaha okay I feel dumb now.
- natpalmer1776 2y agoWell if you're dumb then we're dumb.
- 2y ago
- naiv 2y agoAwesome product! I was just a bit confused that the sign up buttons for the Hobby and Scale plans are grey, I thought that they are disabled until randomly hovering over them.
- pkiv 2y agoGood feedback! We'll take a look.
- emilburzo 2y agoRomania is missing from the list of phone number countries on signup, not sure if on purpose or not.
- neeleshs 2y agoWe did something similar -na although in a somewhat different context. Translating a complex JSON representing an execution graph to a simpler graphviz dot format first and then feeding it to an LLM. We had decent success.
- jumploops 2y agoYes, just like with humans, if you simplify the context, it's often much easier to get the desired result. Source: I have a toddler at home.
- snthpy 2y agoThank you for these. I've been wanting to try the same approach and have been looking for the right tools.
- pbronez 2y agoFirst I’ve heard of Semantic Markdown [0]. It appears to be a way to embed RDF data in Markdown documents. The page I found is labeled “Alpha Draft,” which suggests there isn’t a huge corpus of Semantic Markdown content out there. This might impede LLM’s ability to understand it due to lack of training data. However, it seems sufficiently readable that LLMs could get by pretty well by treating its structured metadata as parathenicals ===== What is Semantic Markdown? Semantic Markdown is a plain-text format for writing documents that embed machine-readable data. The documents are easy to author and both human and machine-readable, so that the structured data contained within these documents is available to tools and applications. Technically speaking, Semantic Markdown is "RDFa Lite for Markdown" and aims at enhancing the HTML generated from Markdown with RDFa Lite attributes. Design Rationale: Embed RDFa-like semantic annotation within Markdown Ability to mix unstructured human-text with machine-readable data in JSON-LD-like lists Ability to semantically annotate an existing plain Markdown document with semantic annotations Keep human-readability to a maximum About this document ===== [0] https://hackmd.io/@sparna/semantic-markdown-draft https://hackmd.io/@sparna/semantic-markdown-draft
- jumploops 2y agoThe specific library I mentioned was linked on HN awhile back: https://news.ycombinator.com/item?id=41043771 https://news.ycombinator.com/item?id=41043771
- mistercow 2y agoHave you compared markdown to just stripping the HTML down (strip tag attributes, unwrap links, remove obvious non-displaying elements)? My experience has been that performance is pretty similar to markdown, and it’s an easier transformation with fewer edge cases.
- nickpsecurity 2y agoThat’s what I’ve done for quite a few [non-LLM] applications. The remaining problem is that HTML is verbose vs other formats. That has a higher, per-token cost. So, maybe stripping followed by substituting HTML tags with a compressed notation.
- mistercow 2y agoYeah it’s slightly more token heavy, although not as much as it seems like at first glance. Most opening tags are 2-3 tokens, and most closing tags are 3-4. Since tags are generally a pretty small fraction of the text, it typically doesn’t make a huge difference IME, but it obviously depends on the particular content.
- defgeneric 2y agoI've tried this and found it doesn't make much difference. The idea was to somehow preserve the document structure while reducing the token count, so you do things like strip all styles, etc. until you have something like a structure of divs, then reduce that. But I found no performance gain in terms of output. It seems whatever structure of the document is left over after doing the reduction has little semantic meaning that can't be conveyed by spaces or newlines. Even when using something like html2markdown, it doesn't perform much better. So in a sense the LLM is "too good", and all you really need to worry about is reducing the token count.
- nickpsecurity 2y agoThat’s interesting that it didn’t change the performance. It might still reduce cost (CPU vs GPU’s) when pages have a lot of formatting.