Skip to content

Commit

Permalink
Updated native libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
olegtarasov committed Sep 30, 2024
1 parent 6d79f2a commit 87c4d73
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/BuildAndPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and publish
on:
push:
tags:
- '*'
- "*"

jobs:
test:
Expand All @@ -13,12 +13,12 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100
dotnet-version: 8.0.402

- name: Run tests
run: dotnet test
Expand All @@ -27,14 +27,14 @@ jobs:
if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, 'skip ci') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olegtarasov/[email protected]
- uses: actions/checkout@v4
- uses: olegtarasov/[email protected].3

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.100
dotnet-version: 8.0.402

- name: Create the package
run: dotnet pack FastText.NetWrapper --configuration Release -p:PackageVersion=$GIT_TAG_NAME -o .

Expand Down
4 changes: 2 additions & 2 deletions ConsoleTest/ConsoleTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
Expand All @@ -28,5 +28,5 @@
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Spectre.Console" Version="0.42.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions FastText.NetWrapper/FastText.NetWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="FastText.Native.Linux" Version="1.0.113" />
<PackageReference Include="FastText.Native.MacOs" Version="1.0.113" />
<PackageReference Include="FastText.Native.Windows" Version="1.0.113" />
<PackageReference Include="FastText.Native.Linux" Version="1.0.115" />
<PackageReference Include="FastText.Native.MacOs" Version="1.0.115" />
<PackageReference Include="FastText.Native.Windows" Version="1.0.115" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions FastText.NetWrapper/FastText.NetWrapper.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<dependencies>
<group targetFramework=".NETStandard2.0">
<dependency id="AutoMapper" version="10.1.1" />
<dependency id="FastText.Native.Linux" version="1.0.113" />
<dependency id="FastText.Native.MacOs" version="1.0.113" />
<dependency id="FastText.Native.Windows" version="1.0.113" />
<dependency id="FastText.Native.Linux" version="1.0.115" />
<dependency id="FastText.Native.MacOs" version="1.0.115" />
<dependency id="FastText.Native.Windows" version="1.0.115" />
<dependency id="Microsoft.Extensions.Logging.Abstractions" version="6.0.0" />
</group>
</dependencies>
Expand Down
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

# FastText.NetWrapper

This is a cross-platform .NET Standard wrapper for Facebook's [FastText](https://github.com/facebookresearch/fastText) library.
This is a cross-platform .NET Standard wrapper for Facebook's [FastText](https://github.com/facebookresearch/fastText) library.
The wrapper comes with bundled precompiled native binaries for all three platforms: Windows, Linux and MacOs.

Just add it to your project and start using it! No additional setup required. This library will unpack and call appropriate native
Just add it to your project and start using it! No additional setup required. This library will unpack and call appropriate native
binary depending on target platform.

## Is this project dead or abandoned?

Of course not! It's just complete :) There are no major updates for fastText, and most bugs in this repository are fixed. All the features
Of course not! It's just complete :) There are no major updates for fastText, and most bugs in this repository are fixed. All features
should work and if something doesn't — just ping me with an issue and I will try to get back to you.

## Usage
Expand All @@ -34,7 +34,7 @@ Note the arguments:
https://dl.fbaipublicfiles.com/fasttext/data/cooking.stackexchange.tar.gz. You can find extracted files split into training
and validation sets in `UnitTests` directory in this repository.
2. Your model will be saved to `cooking.bin` and `cooking.vec` with pretrained vectors will be placed if the same directory.
3. Here we use `Supervised()` overload with 2 arguments. This means that training will be done with default parameters.
3. Here we use `Supervised()` overload with 2 arguments. This means that training will be done with default parameters.
It's a good starting point and is the same as calling fastText this way:

```bash
Expand All @@ -60,7 +60,7 @@ the dimension 0.

```c#
var fastText = new FastTextWrapper();

var args = new SupervisedArgs
{
PretrainedVectors = "cooking.unsup.300.vec",
Expand Down Expand Up @@ -113,7 +113,7 @@ var plotModel = new PlotModel

using (var stream = new FileStream("precision-recall.svg", FileMode.Create, FileAccess.Write))
{
SvgExporter.Export(plotModel, stream, 600, 600, false);
SvgExporter.Export(plotModel, stream, 600, 600, false);
}
```

Expand Down Expand Up @@ -163,7 +163,7 @@ var autotuneArgs = new AutotuneArgs
Duration = 30, // in seconds
Metric = "precisionAtRecall:30", // supports custom metrics
Predictions = 2, // Supports @k predictions
ModelSize = "10M", // Set this to train a quantized model and do an
ModelSize = "10M", // Set this to train a quantized model and do an
// additional quantization hyperparameter search. Requires QuantizedSupervisedArgs.
ValidationFile = "cooking.valid.txt" // REQUIRED: path to a validation file
};
Expand Down Expand Up @@ -212,7 +212,7 @@ You can also inject your standard `IloggerFactory` through .NET Core DI.
```c#
// Add the following Nuget packages to your project:
// * Serilog.Sinks.Console
// * Serilog.Extensions.Logging
// * Serilog.Extensions.Logging
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
Expand All @@ -229,19 +229,23 @@ In version `1.1` I've added much better native error handling. Now in case of mo

## Windows Requirements

Since this wrapper uses native C++ binaries under the hood, you will need to have Visual C++ Runtime Version 140 installed when
running under Windows. Visit the MS Downloads page (https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
and select the appropriate redistributable.
Since this wrapper uses native C++ binaries under the hood, you will need to have Visual C++ Runtime Version 140 installed when
running under Windows. Visit the MS Downloads page (https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
and select the appropriate redistributable.

## FastText C-style API

If you are interested in using FastText with C-style API, here is my fork of the official library: https://github.com/olegtarasov/fastText.

## Changelog

### `1.3.1`

* Updated fastText binaries with latest improvements from the Facebook repo.

### `1.3.0`

* Native libraries are now explicitly included in target project and copied to output directory. Hopefully,
* Native libraries are now explicitly included in target project and copied to output directory. Hopefully,
this solves a couple of problems with the previous approach of dynamically extracting libraries from
resources.

Expand Down Expand Up @@ -294,4 +298,4 @@ Version 1.2.0 introduces a few breaking changes to library API. If you are not r
## Version `1.2.0` migration guide

* Instead of old `Train()` methods use `Supervised()` and `Unsupervised()` methods.
* Instead of `FastTextArgs.SupervisedDefaults()` use `SupervisedArgs` or `Supervised()` overload with 2 arguments.
* Instead of `FastTextArgs.SupervisedDefaults()` use `SupervisedArgs` or `Supervised()` overload with 2 arguments.
2 changes: 1 addition & 1 deletion UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
Expand Down

0 comments on commit 87c4d73

Please sign in to comment.