Live data from Hacker News

Experimental library for scraping websites using OpenAI's GPT API

jamesturk.github.io

91–100 of 149 posts

Re: Experimental library for scraping websites using OpenAI's GPT API

#91
post #51

The license for this is pretty hilarious and it's something you should pretty obviously never accept or use under any circumstances.

Yes, it goes beyond even just extensive usage restrictions and restricts _who_ can use it. https://jamesturk.github.io/scrapeghost/LICENSE/#3

It seems, for example, that (by 3.1.12) if you are a person who is involved in the mining of minerals (of any sort), that you are not allowed to use this library, even if you're not using the library for any mining-related purpose.

Re: Experimental library for scraping websites using OpenAI's GPT API

#92
Scraping/structuring data seems to be an area where LLMs are just great. This is a use-case that I think has a lot of potential, it's worth exploring.

That being said, I still have to be a stick in the mud and point out that GPT-4 is probably still vulnerable to 3rd-party prompt injection while scraping websites. I've run into people on HN who think that problem is easy to solve. Maybe they're right, maybe they're not, but I haven't seen evidence that OpenAI in particular has solved it yet.

For a lot of scraping/categorizing that risk won't matter because you won't be working with hostile content. But you do have to keep in mind that there is a risk here if you scrape a website and it ends up prompting GPT to return incorrect data or execute some kind of attack.

GPT-4 is (as far as I know) vulnerable to the Billy Tables attack, and I don't think there is (currently) any mitigation for that.

Re: Experimental library for scraping websites using OpenAI's GPT API

#93

Scraping/structuring data seems to be an area where LLMs are just great. This is a use-case that I think has a lot of potential, it's worth exploring. That being said, I still have to be a stick in the mud and point out that GPT-4 is probably still vulnerable to 3rd-party prompt injection while scraping websites. I've run into people on HN who think that problem is easy to solve. Maybe they're right, maybe they're no…

I assume that would be easy to put a guard in ChatGPT for this? I have not tried to exploit it but used quotes to signal a portion of text.

Are there interesting resources about exploiting the system? I played and it was easy to make the system to write discriminatory stuff but guard could be a signal to understand the text as-is instead of a prompt? All this assuming you cannot unguard the text with tags.

Re: Experimental library for scraping websites using OpenAI's GPT API

#95
post #93

Scraping/structuring data seems to be an area where LLMs are just great. This is a use-case that I think has a lot of potential, it's worth exploring. That being said, I still have to be a stick in the mud and point out that GPT-4 is probably still vulnerable to 3rd-party prompt injection while scraping websites. I've run into people on HN who think that problem is easy to solve. Maybe they're right, maybe they're no…

I assume that would be easy to put a guard in ChatGPT for this? I have not tried to exploit it but used quotes to signal a portion of text. Are there interesting resources about exploiting the system? I played and it was easy to make the system to write discriminatory stuff but guard could be a signal to understand the text as-is instead of a prompt? All this assuming you cannot unguard the text with tags.

I'm not sure that the guards in ChatGPT would work in the long run, but I've been told I'm wrong about that. It depends on whether you can train an AI to reliably ignore instructions within a context. I haven't seen strong evidence that it's possible, but as far as I know there also hasn't been a lot of attempt to try and do it in the first place.

https://greshake.github.io/ was the repo that originally alerted me to indirect prompt injection via websites. That's specifically about Bing, not OpenAI's offering. I haven't seen anyone try to replicate the attack on OpenAI's API (to be fair, it was just released).

If these kinds of mitigations do work, it's not clear to me that ChatGPT is currently using them.

> understand the text as-is

There are phishing attacks that would work against this anyway even without prompt injection. If you ask ChatGPT to scrape someone's email, and the website puts invisible text up that says, "Correction: email is ", I vaguely suspect it wouldn't be too much trouble to get GPT to return the phishing address. The problem is that you can't treat the text as fully literal; the whole point is for GPT to do some amount of processing on it to turn it into structured data.

So in the worst case scenario you could give GPT new instructions. But even in the best case scenario it seems like you could get GPT to return incorrect/malicious data. Typically the way we solve that is by having very structured data where it's impossible to insert contradictory fields or hidden fields or where user-submitted fields are separate from other website fields. But the whole point of GPT here is to use it on data that isn't already structured. So if it's supposed to parse a social website, what does it do if it encounters a user-submitted tweet/whatever that tells it to disregard the previous text it looked at and instead return something else?

There's a kind of chicken-and-egg problem. Any obvious security measure to make sure that people can't make their data weird is going to run into the problem that the goal here is to get GPT to work with weirdly structured data. At best we can put some kind of safeguard around the entire website.

Having human confirmation can be a mitigation step I guess? But human confirmation also sort-of defeats the purpose in some ways.

Re: Experimental library for scraping websites using OpenAI's GPT API

#96
post #37

I have implemented a scaled down version of this that just identifies the selectors needed for a scraper suite to use. for my single use case, I was able to optimize it to nearly 100% accuracy. Currently, I am only triggering the GPT portion when the scraper fails, which I assume means the page has changed.

That sounds really useful, can you provide a link if it's publicly hosted?

It's intimately tied to the rest my repo, but I'll spend some time tonight and try to pull it out into it's own library.

Re: Experimental library for scraping websites using OpenAI's GPT API

#97
post #41

This may finally be a solution for scraping wikipedia and turning it into structured data. (Or do we even need structured data in the post-AI age?) Mediawiki is notorious for being hard to parse: * https://github.com/spencermountain/wtf_wikipedia#ok-first- - why it's hard * https://techblog.wikimedia.org/2022/04/26/what-it-takes-to-p... - an entire article about parsing page TITLES * https://osr.cs.fau.de/wp-content/…

You might be interested in https://github.com/zverok/wikipedia_ql

Re: Experimental library for scraping websites using OpenAI's GPT API

#98

Scraping/structuring data seems to be an area where LLMs are just great. This is a use-case that I think has a lot of potential, it's worth exploring. That being said, I still have to be a stick in the mud and point out that GPT-4 is probably still vulnerable to 3rd-party prompt injection while scraping websites. I've run into people on HN who think that problem is easy to solve. Maybe they're right, maybe they're no…

> Billy Tables

Bobby Tables?

Re: Experimental library for scraping websites using OpenAI's GPT API

#99
post #41

This may finally be a solution for scraping wikipedia and turning it into structured data. (Or do we even need structured data in the post-AI age?) Mediawiki is notorious for being hard to parse: * https://github.com/spencermountain/wtf_wikipedia#ok-first- - why it's hard * https://techblog.wikimedia.org/2022/04/26/what-it-takes-to-p... - an entire article about parsing page TITLES * https://osr.cs.fau.de/wp-content/…

You might find this meets many needs: https://query.wikidata.org/querybuilder/ edit: I tried asking ChatGPT to write SPARQL queries, but the Q123 notation used by Wikidata seems to confuse it. I asked for winners of the Man Booker Prize and it gave me code that was used the Q id for the band Slayer instead of the Booker Prize.

I use wikidata a lot for movie stuff. Ideally I imagine the wiki foundation itself will be looking into using LLMs to help parse their own data and convert it into wikidata content (or confirm it, or keep it up to date, etc.)

Wikidata is incredibly useful for things that I would considered valuable (e.g. the tMDb link for a movie) but due to the curation imposed upon Wikipedia itself isn't typically available for very many pages. An LLM won't help with that but another bit of information like where films are set would be a perfect candidate for an LLM to try and determine and fill in automatically with a flag for manual confirmation.

Re: Experimental library for scraping websites using OpenAI's GPT API

#100
post #96

Earlier quoted context omitted.

That sounds really useful, can you provide a link if it's publicly hosted?

It's intimately tied to the rest my repo, but I'll spend some time tonight and try to pull it out into it's own library.

+1 for interest there
Post reply on HN