Gemini doesn’t think any of the authors of “Attention Is All You Need” have written a book:
Have any of the authors of “Attention Is All You Need” written books?
To my knowledge, none of the original authors of the groundbreaking paper “Attention Is All You Need” have published books directly related to their work on transformers. However, there are several excellent books available that delve into the concepts and applications of transformers, including:
- Natural Language Processing with Transformers by Lewis Tunstall: This book provides a comprehensive guide to understanding and implementing transformers for various NLP tasks. While not directly written by the original authors, it offers a deep dive into the techniques and best practices.
- Generative Deep Learning: Teaching Machines To Paint, Write, Compose, and Play by David Foster: This book explores the broader field of generative deep learning, including the role of transformers in generating creative content. While not solely focused on the “Attention Is All You Need” paper, it provides valuable insights into the capabilities of transformer-based models.
These books, along with numerous research papers and online resources, offer valuable insights into the world of transformers and their impact on the field of artificial intelligence.
https://g.co/gemini/share/a8bd8f3c0193
Honestly, I didn’t know the answer to this when I asked it. I was curious about this because I was thinking of reading their books if there were some to read.
It’s a nice answer at least in that it points to some existing books that sound pretty good. But is it true that none of the authors have written a book?
Searching on Google for [book database] led me to Book Databases Overview 2024: Access Book Information via ISBN, which in turn let me know of the existence of the Open Library API. I read Death of the Stubborn Developer earlier today so I decided to give Colab’s code generation features a try.
My notebook: https://colab.research.google.com/drive/1pjJPasmJ-cscC88nropI1U9mYl3LgTQU
My first prompt “a function to use Open Library’s API to find whether an author with the name, given as a str, has written any books” yielded working code:
import requests
import json
def author_has_books(author_name):
"""
Checks if an author has written any books using the Open Library API.
Args:
author_name: The name of the author to search for (string).
Returns:
True if the author has written books, False otherwise.
Returns an error message if the API request fails.
"""
base_url = "https://openlibrary.org/search/authors.json"
params = {"q": author_name}
try:
response = requests.get(base_url, params=params)
response.raise_for_status() # Raise an exception for bad status codes
data = response.json()
if data['numFound'] > 0:
# Check if any of the author documents has works
for author in data['docs']:
if 'work_count' in author and author['work_count'] > 0:
return True
return False
except requests.exceptions.RequestException as e:
return f"Error: {e}"
except (KeyError, json.JSONDecodeError) as e:
return f"Error decoding API response: {e}"
# Example usage
author_name = "Stephen King"
result = author_has_books(author_name)
print(f"Does {author_name} have books? {result}")
author_name = "NonExistent Author"
result = author_has_books(author_name)
print(f"Does {author_name} have books? {result}")
I like that it even includes usage examples. I’m not a fan of converting the exceptions into strings returned as function values, but it’s nice to have examples to show how to handle the potential exceptions if desired. (Also, I’d rather avoid the possibility of key errors rather than catching them.) And one very small nit is the inconsistent use of double quotes vs single quotes for defining strings.
This definitely saved me multiple minutes or tens of minutes, not being familiar with Open Library’s API and still getting comfortable with the requests library.
After seeing the format for the API requests, I went ahead and made one manually myself:
https://openlibrary.org/search/authors.json?q=Arnold+Faden
{"numFound": 1, "start": 0, "numFoundExact": true, "docs": [{"birth_date": "1934", "key": "OL1800415A", "name": "Arnold M. Faden", "top_subjects": ["Space in economics", "Social sciences, methodology", "Social sciences", "Methodology", "Measure theory"], "top_work": "Economics of space and time", "type": "author", "work_count": 2, "_version_": 1795995901993418755}]}
“top_work” sounds perfect for what I’m looking for.
I tried an intermediate prompt, which unfortunately, I wasn’t careful to keep. The resulting code contained at least one API call that seemed mangled due to missing a “/”, merging the key and part of the path. I manually fixed that, but then found it not to be a real endpoint.
Trying again with the following prompt, we get something that works:
“a function to use Open Library’s API to find the top work for an author, empty string if they have no known books, giving the author’s name as a str“
import requests
import json
def get_top_work_for_author(author_name):
"""
Uses Open Library's API to find the top work for an author.
Args:
author_name: The name of the author (string).
Returns:
The title of the top work if found, or an empty string if no works are found or an error occurs.
"""
try:
base_url = "https://openlibrary.org/search/authors.json"
params = {"q": author_name}
response = requests.get(base_url, params=params)
response.raise_for_status()
data = response.json()
if data['numFound'] == 0:
return "" # No author found
for author in data['docs']:
if 'key' in author:
author_key = author['key'].replace('/authors/', '')
works_url = f"https://openlibrary.org/authors/{author_key}/works.json"
works_response = requests.get(works_url)
works_response.raise_for_status()
works_data = works_response.json()
if 'entries' in works_data and len(works_data['entries']) > 0:
# Assuming the first work in the list is the top work. Open Library API doesn't seem to have a "top work" indicator.
top_work = works_data['entries'][0]
if 'title' in top_work:
return top_work['title']
return "" # Author found but no works listed
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
return ""
except (KeyError, json.JSONDecodeError) as e:
print(f"Error decoding API response: {e}")
return ""
Giving it a whirl:
get_top_work_for_author("Arnold Faden")
yields “Essays in spatial economics”, which is new to me, but probably not the best answer.
I decided I’d try hacking on the first bit of generated code, also peeking at that example JSON output I got by directly calling the API. This is what I ended up with:
def fetch_author_top_work(author_name: str) -> str:
"""
Checks if an author has written any books.
Uses the Open Library API.
Args:
author_name: The name of the author to search for.
Returns:
Name of the author's top work if present, empty string otherwise.
"""
base_url = "https://openlibrary.org/search/authors.json"
params = {"q": author_name}
response = requests.get(base_url, params=params)
response.raise_for_status()
data = response.json()
for author in data.get("docs", []):
return author.get("top_work", "")
return ""
I like this better for directly taking advantage of the “top_work” value if present.
Finally, what do we get for the authors of “All You Need Is Attention”?
attention_authors = (
"Ashish Vaswani, Noam Shazeer, Niki Parmar, "
"Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, "
"Illia Polosukhin".split(", "))
for author in attention_authors:
top_work = fetch_author_top_work(author)
print(f"{author}: {top_work}")
- Ashish Vaswani:
- Noam Shazeer:
- Niki Parmar:
- Jakob Uszkoreit:
- Llion Jones: Bardd ar y bêl
- Aidan N. Gomez:
- Lukasz Kaiser: Logic and Games on Automatic Structures
- Illia Polosukhin:
Logic and Games on Automatic Structures: Playing with Quantifiers and Decompositions by Łukasz Kaiser came out in 2011. At least Google Scholar thinks this is the same Kaiser as on the paper.
Translating the Wikipedia page for “Bardd ar y bêl”, we learn it is “[a] book by
Llion Jones that follows the Welsh football team’s memorable journey from Andorra to Lyon in the Euro 2016 competition…” Translating the Welsh for the Llion Jones Wikipedia page, we find he is “a poet , critic and academic.” So, probably not the same Llion Jones as on the paper?
I’m kind of surprised that potentially only one of the authors has a book.
Leave a Reply