-
-
Save g8a9/07c2be12ae02cfad4aa430d77dc940cb to your computer and use it in GitHub Desktop.
latex listing in github style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\usepackage{amsmath,amssymb} | |
\usepackage{pifont} | |
\usepackage{xcolor} | |
\usepackage{listings} | |
\definecolor{codegreen}{rgb}{0,0.6,0} | |
\definecolor{codegray}{rgb}{0.5,0.5,0.5} | |
%\definecolor{emphcolor}{rgb}{} | |
\definecolor{backcolour}{RGB}{245,248,250} | |
\definecolor{emph}{RGB}{166,88,53} | |
\definecolor{nightblue}{RGB}{9,49,105} | |
\definecolor{keywords}{RGB}{207,33,46} | |
\definecolor{lightpurple}{RGB}{130,81,223} | |
\lstdefinestyle{mystyle}{ | |
backgroundcolor=\color{backcolour}, | |
commentstyle=\color{codegreen}, | |
keywordstyle=\color{keywords}, | |
stringstyle=\color{nightblue}, | |
basicstyle=\ttfamily\footnotesize, | |
breakatwhitespace=false, | |
breaklines=true, | |
captionpos=b, | |
keepspaces=true, | |
%numberstyle=\tiny\color{codegray}, | |
%numbers=none, | |
%numbersep=5pt, | |
showspaces=false, | |
showstringspaces=false, | |
showtabs=false, | |
tabsize=2, | |
frame=shadowbox, | |
emph={AutoTokenizer,AutoModelForSequenceClassification,Explainer}, | |
emphstyle={\color{emph}}, | |
emph={[2]from_pretrained,compute_table}, | |
emphstyle={[2]\color{lightpurple}} | |
%linewidth=12cm | |
} | |
\lstset{style=mystyle} | |
\begin{figure*}[!t] | |
\centering | |
\begin{lstlisting}[language=Python] | |
from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
from ferret import Benchmark | |
name = "cardiffnlp/twitter-xlm-roberta-base-sentiment" | |
model = AutoModelForSequenceClassification.from_pretrained(name) | |
tokenizer = AutoTokenizer.from_pretrained(name) | |
bench = Benchmark(model, tokenizer) | |
explanations = bench.explain("You look stunning!", target=1) | |
evaluations = bench.evaluate_explanations(explanations, target=1) | |
\end{lstlisting} | |
\caption{Essential code to benchmark explanations on an existing Hugging Face model using \placeholder.} | |
\label{fig:example_code} | |
\end{figure*} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment