1
1
Fork
You've already forked scrapeghost
0

Better Automatic Token Reduction #49

Open
opened 2023年06月07日 00:05:28 +02:00 by jamesturk · 1 comment
jamesturk commented 2023年06月07日 00:05:28 +02:00 (Migrated from github.com)
Copy link

To get this working in more places, more experimentation with token reduction is needed. How stripped down/minified can we get the HTML without causing reliability issues?

This isn't straightforward as it seems & many off the shelf tools are focused on different problems:

  • Minifiers seem to confuse GPT-4 a fair bit, so using off-the-shelf obfuscators/minifiers isn't the right solution here.
  • A lot of tools exist to sanitize HTML, but they often remove class names/etc. that are important to keep as hints. (and will be important if we get to the point of generating XPath)

It seems like the right approach is going to be an allow/disallow list based approach to extend/expand upon what's been done already in lxml.clean.

To get this working in more places, more experimentation with token reduction is needed. How stripped down/minified can we get the HTML without causing reliability issues? This isn't straightforward as it seems & many off the shelf tools are focused on different problems: - Minifiers seem to confuse GPT-4 a fair bit, so using off-the-shelf obfuscators/minifiers isn't the right solution here. - A lot of tools exist to sanitize HTML, but they often remove class names/etc. that are important to keep as hints. (and will be important if we get to the point of generating XPath) It seems like the right approach is going to be an allow/disallow list based approach to extend/expand upon what's been done already in `lxml.clean`.
jamesturk commented 2023年06月07日 03:15:10 +02:00 (Migrated from github.com)
Copy link

Leaving myself a note that it is probably desirable to have a mode that does not modify the page structure. (i.e. no deletion of container tags) so that XPath can remain valid if we go down that route. This doesn't mean it's a hard and fast rule, but that it should be configurable ideally.

This means

<div>
 <div> 
 <div> 
 Content
 </div>
 </div>
</div>

Can't be simplified.

Counts should be avoided in generated XPath at almost any cost (e.g. never generate //table[4]) but could run into similar issues, maybe a second toggle for this?

Leaving myself a note that it is probably desirable to have a mode that does not modify the page structure. (i.e. no deletion of container tags) so that XPath can remain valid if we go down that route. This doesn't mean it's a hard and fast rule, but that it should be configurable ideally. This means ``` <div> <div> <div> Content </div> </div> </div> ``` Can't be simplified. Counts should be avoided in generated XPath at almost any cost (e.g. never generate //table[4]) but could run into similar issues, maybe a second toggle for this?
Sign in to join this conversation.
No Branch/Tag specified
main
gh-pages
november-updates
log-config
pagination-restore
0.6.0
0.5.1
0.5.0
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jpt/scrapeghost#49
Reference in a new issue
jpt/scrapeghost
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?