3 ms·
How to add hyperlinks is something I've thought a bit about for Gwern.net: there's no point having all these fancy popups if there are no hyperlinks exploiting
by gwern 3y ago
How to add hyperlinks is something I've thought a bit about for Gwern.net: there's no point having all these fancy popups if there are no hyperlinks exploiting them, right?
The way I currently do it is that first, I make hyperlinks stable by automatically snapshotting & making local archives of pages (https://gwern.net/archiving#preemptive-local-archiving https://gwern.net/archiving#preemptive-local-archiving). There is no point in adding links if linkrot discourages anyone from using them, of course, and I found that manual linkrot fixing did not scale to the amount of writing & hyperlinking I want to do.
The next step is adding links automatically. Particularly in the STEM topics I write most about these days, AI, there are many acronyms & named systems which mean specific things but it's easy to get lost in. Fortunately, that makes them easy to write automatic link rules for: https://github.com/gwern/gwern.net/blob/master/build/Config/LinkAuto.hs https://github.com/gwern/gwern.net/blob/master/build/Config/... These run automatically on essay bodies when compiling the site, and on annotations when created. If a URL is already present, its rule doesn't run; and if it's not, only the first instance gets linked and the rest are skipped. (This is important: there are some approaches which take the lazy approach of hyperlinking every instance. This is bad and discredits linking.) This code is very slow but fast enough for static site building, anyway.
Sometimes terms are too ambiguous or too rare or too much work to write an explicit rewrite rule for. But it will still exist on-site. In fact, you can say that the site corpus defines a set of rewrite rules: everytime I write by hand `[foo](http://bar http://bar)`, am I not implicitly saying that there ought to be a rewrite rule for the string `foo` which ought to hyperlink `http://bar http://bar`? So there is a script (https://github.com/gwern/gwern.net/blob/master/build/link-suggester.hs https://github.com/gwern/gwern.net/blob/master/build/link-su...) which will parse the site corpus, compile all the text/link pairs, create/remove a bunch of them per whitelist/blacklists and a frequency/length threshold, and then generate a bunch of Emacs Lisp pairs. This master list of rewrites then gets read by an Elisp snippet in my Emacs and turned into several thousand interactive search-and-replace commands when I run my generic formatting command on a buffer.
The effect of this second script is that after I have linked `Foo et al 2023` to `/doc/2023-foo.pdf` a few times (perhaps I went back and hyperlinked all instances of it after realizing it's an important paper), any future instances of 'Foo et al 2023' will pop up a search-and-replace asking to hyperlink it to `/doc/2023-foo.pdf`, and so on.
Third, I exploit my link-recommendations for manually-curated 'see also' sections appended to annotations. I have a fairly standard link-recommender approach where each annotation is embedded by a neural network (OA API for now), and one does nearest-neighbor lookups to find _n_ 'similar' annotations, and shows the reader them in case any are relevant. So far so good. But I also do that after editing each annotation: embed-recommend-list, and spits out a HTML list of the top 20 or so similar-links appended to the annotation. I can look at that and delete the irrelevant entries, or the entire list. This means that they'll be included in the final embedded version of the annotation, will show up in any fulltext searche I run, are more visible to the reader, can be edited into the main body if I want to, etc.
Fourth and most lately, I've been experimenting with GPT-4 for auto-formatting & auto-linking (https://github.com/gwern/gwern.net/blob/master/build/paragraphizer.py https://github.com/gwern/gwern.net/blob/master/build/paragra...). GPT-4 has memorized many URLs, and where it hasn't, it still makes pretty good guesses. So, as part of the standard formatting passes, I pass annotations through GPT-4, with a bit added to its prompt, 'try to add useful hyperlinks to Wikipedia and other sources'. It often does, and it's quite convenient when that works. GPT-4 still confabulates URLs more often than I link, and sometimes hyperlinks too-obvious WP links and I have to delete them. So, still some adjustments required there.
And these work well with the other site features like recursive popups, or bidirectional backlinks (https://gwern.net/design#backlink https://gwern.net/design#backlink).
- gwern 3y agoAs far as OP goes, matching on n-grams is a reasonable & fast idea, but the presentation is not good. The problem with lots of links is that they are a tax on the reader's attention and limited decision-making reserves; unfortunately, not having links is an even greater tax, because now one has to exert much more effort and use one's fingers as well as one's eyeballs to see if there is anything at all worth looking at. My suggestion would be to relegate this to the authoring interface, and just show regular links to readers. This is still bad for authors, however, and so my suggestion would be to explicitly annotate 'possible links'. For example, you could draw an underline under all words, count how many hits that word would have across all possible n-grams, normalize document-wide, and set the opacity 0-100% based on that. So you would see most words have no underline (0% opacity), dubious links get hard to see lines, and then various proper nouns and titles and technical terms would have heavy dark underlines; the author can then easily see which ones might be viable links, and right-click or hover to check & instantiate. And this could be set to automatically hyperlink at certain % or run in an interactive modal to approve/disapprove hyperlinks as a final editing pass.
- dredmorbius 3y agoI'm increasingly inclined to see classical footnotes or endnotes as a preferable compromise. Simply hyperlinking text often provides little context as to where that link is going, though alternatives (as with your own pop-up context cards, see also Mediawiki's use of same) are useful. I've played with sidenotes as an option, implemented in CSS (I've a few CodePens on this concept). That also works reasonably well (and can even be responsive to screen size). There's also a fantastic quote of Walter Benjamin's I've just run across: “Already today, as the current scientific mode of production teaches, the book is already an obsolete mediation between two different card file systems. For everything essential is found in the index box of the researcher who wrote it, and the scholar who studies it assimilates it in his own card file.” -- Walter Benjamin - Attested Auditor of Books, in One Way Street (1928) <https://writingslowly.com/2023/07/24/walter-benjamin-on.html https://writingslowly.com/2023/07/24/walter-benjamin-on.html> The thought of books (or Web articles) as inter-process communication between author's personal datastors (Zettelkasten, databases, wikis, org-mode notes, ...) is a fresh and illuminating one.