Questions about machine-learning models for Fedora
Kaitlyn Abdo of Fedora's AI/ML SIG opened an issue with the Fedora Engineering Steering Committee (FESCo) recently that carried a few tricky questions about packaging machine-learning (ML) models for Fedora. Specifically, the SIG is looking for guidance on whether pre-trained weights for PyTorch constitute code or content. And, if the models are released under a license approved by the Open Source Initiative (OSI), does it matter what data the models were trained on? The issue was quickly tossed over to Fedora's legal mailing list and sparked an interesting discussion about how to handle these items, and a temporary path forward.
Defining terms
AI/ML is becoming, or at least feels, nearly omnipresent these days. However, the terminology may be confusing to those who are outside of that bubble, so Tim Flink helpfully supplied some definitions of terms when he carried the discussion from the FESCo ticket to Fedora legal.
To sum up Flink's definitions, a model describes an artificial
neural network (ANN), which is structured data "consisting
of neurons (nodes containing some value) organized into layers
with various connections between the neurons
". A model
describes a specific ANN, how its layers are configured, how
the data is structured, and the learning algorithms that will be used
when the model is trained on data to assign values (weights) to its nodes.
A model by itself is not of much use until it has been trained on
data and has had weights assigned to it to provide the
"exact value of how the connections affect flow through the
network
". As an example, one might want to use PyTorch's torchvision
library, which offers models for tasks like image classification and
object detection, to determine if there's a cat in a picture. One of
the torchvision models might be suitable for this, but it would need
to be trained on data (pictures with and without cats) before it would
be able to do its job.
Users could do the training themselves but, as Flink noted,
doing the training to create the weights "is a very expensive and time consuming
process
". So projects like PyTorch provide pre-trained
weights—that is, models that are populated with training
data—so that users can make use of the models without having to do
the training, or even having access to the data used to train the
model. For example, the PyTorch project offers torchvision
models
with and without weights.
Herein lies the perceived problem: while the weights and models may be offered under a license that is approved for Fedora, there's uncertainty about the data used to do the training. Copyright holders have been suing over the use of their data in training models, and the AI/ML SIG has hesitated to package weights due to those lawsuits and the questions about the input data used—even if the model is under a license accepted by Fedora.
In his first message in the thread, Flink asked whether
weights are normal non-code content, or if they
"require special handling
" even if the upstream offers the
models under a license "acceptable for non-code content in
Fedora
". Do packagers have any responsibility for reviewing the
training data, in other words, or is the upstream's choice of license sufficient to
make that call? So far, the SIG has erred on the side of caution
and refrained from packaging weights, but that has its own
drawbacks.
Supplying software like PyTorch without weights is a lot like supplying a spellchecker without the dictionary it needs as a word list. It would be easier for users if they didn't have to seek out the weights separately from installing the software—but the SIG wanted public guidance from FESCo (and then Fedora legal) before proceeding.
Are AI/ML weights special?
Richard Fontana, a member of Red Hat's legal team who advises Fedora on
legal issues, wrote
that he had recommended bumping the questions to FESCo
because he thought FESCo might decide weights were
"analogous to object code
" that users must be able to modify.
Fontana alluded to discussions
being led by the OSI over the definition of "open-source AI" and
said there is "definitely some sentiment among participants in that effort
" that training
data must be open because "this is necessary for users to exercise rights of
modification
." It would seem, however, that FESCo is satisfied with
the idea that weights are content unless Fedora legal
decides otherwise.
Fontana said that he was "struggling to see a justification
"
not to consider weights as content. However, he indicated that Fedora
should be cautious, at least initially, and take weights "on a
case-by-case basis
" until Fedora has more experience with this
type of content. Fontana said there may be circumstances when Fedora
might not want to package the weights "given what is disclosed,
or not disclosed, about how a model was trained
". That was, he
said, "unlikely, but not impossible
".
In a followup message, Fontana elaborated on this and said that he wants
to do further review "for any specific pre-trained weights that
will actually be included in Fedora packages, for some initial
period
", since it would be "highly impractical
" to
expect packagers or package reviewers to do this type of review. Fontana said that
if there are technical issues, such as "if there ought to be some
standards around packaging of upstream pre-trained weights
" he
would not be able to give guidance "beyond my initial suggestion to
raise this topic with FESCo which seems to have been
unsuccessful
".
FESCo member Neal Gompa replied:
With my FESCo hat on, the main question to answer is how we classify and identify them for package reviews, which is largely a Fedora Legal question. Personally, it's basically content to me, we do probably need some explicit documentation of this for the guidance that the AI/ML SIG can use to write packaging guidelines for FPC [Fedora Packaging Committee] to review.
What about build-time downloads?
Flink had also asked about scenarios where software packaged for Fedora might download weights upon first use. He used torchvision as the example of a library that is already packaged for Fedora as python-torchvision with the weights removed. If a user calls one of the models when using the torchvision library, such as the vit_b_16 model then the weights are downloaded from a third-party site on first use. Flink noted that some of the weights are under licenses acceptable as content for Fedora, some are under Creative Commons licenses that are not acceptable for content packaged for Fedora, and others have no explicit license at all.
Those scenarios, Gompa suggested,
were "in the same bucket
" as Python's pip,
Ruby's gem, and other software with package-manager
functionality that downloads software from sources outside of Fedora's repositories. Fontana agreed,
but Flink wrote
that "the capabilities do overlap but in my opinion, the intended uses are different and that may
be worth noting
". He also explained that downloads happen
"transparently to the user with no warning outside of a log message
when the weights are first downloaded
". This is a bit different than,
say, installing Python software with pip because users have to
explicitly run a pip install command to download software.
Flink said he was not arguing against having this functionality, but wanted to be sure it
was explained correctly.
Fontana replied
that he felt Flink was raising a more general issue that was not
specific to pre-trained models. He noted that any Fedora package could
download things with no warning to the user, and that he was unaware
of any Fedora technical or packaging guidelines that address that
issue. At this point, Gompa seemed
impatient with the discussion, noting that lots of Fedora packages
have similar functionality, and suggested that packagers "tweak
pytorch to require configuration or make a prompt when it triggers
the first time or something
" if the packagers were concerned about
that functionality.
Next steps
To date, no packages including pre-trained weights have been submitted for review. I followed up with Flink by email, and he confirmed plans to package weights for torchvision so that Fedora packages could be used alongside upstream PyTorch vision-related tutorials. It will be interesting to see what the case-by-case review looks like and what packages, if any, may be held back from Fedora due to concerns over the training data used.
