Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added Hub and Tokenizers libraries.#166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
greenrazer wants to merge5 commits intohuggingface:main
base:main
Choose a base branch
Loading
fromgreenrazer:main

Conversation

greenrazer
Copy link
Collaborator

AddedHub andTokenizers as separate library products inPackage.swift. This change should enable selective compilation of specific components while maintaining a single project structure.

Usage Example

Usage is pretty simple, I created an external project and all that was needed was to editPackage.swift.

Specifically, Add the package dependency:

dependencies: [        .package(url: "https://github.com/huggingface/swift-transformers", branch: "main")    ],

Then import specific products as dependencies of the desired target:

targets: [        .target(            ...            dependencies: [                .product(name: "Hub", package: "swift-transformers")            ]        ),

Testing

In the external project I copied and ran all the Tokenizer, and Hub tests from swift-transformers.

  • Successfully imported both products
  • All tests passed:
    • Hub: 14 tests passed in 9.822s
    • Tokenizers: 96 tests passed in 26.948s

Copy link
Member

@pcuencapcuenca left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

According to my tests, all the package dependencies are downloaded and resolved (so other dependencies are recursively pulled as well). However, they arenot compiled if they don't participate in the targets used by the client package. (Actually, there's a pre-processing step where stubs and headers are generated, but no actual compilation happens).

I tested building withswift build and Xcode, using a dependent package that uses theTokenizers library (withoutModels).

greenrazer and FL33TW00D reacted with heart emoji
Package.swift Outdated
@@ -8,6 +8,8 @@ let package = Package(
platforms: [.iOS(.v16), .macOS(.v13)],
products: [
.library(name: "Transformers", targets: ["Tokenizers", "Generation", "Models"]),
.library(name: "Hub", targets: ["Hub"]),
.library(name: "Tokenizers", targets: ["Tokenizers", "Models"]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
.library(name:"Tokenizers", targets:["Tokenizers","Models"]),
.library(name:"Tokenizers", targets:["Tokenizers"]),

This would pull most of the library, wouldn't it?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, I was getting an error with tokenizers when I didn't have the Models target, but I think that was just an issue with the test. I implemented the above change and fixed the test, and re-tested it in the external project.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@pcuencapcuencapcuenca left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@greenrazer@pcuenca

[8]ページ先頭

©2009-2025 Movatter.jp