Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation of Air module used for training models #119

Open
Jzow opened this issue Oct 26, 2023 · 2 comments
Open

Explanation of Air module used for training models #119

Jzow opened this issue Oct 26, 2023 · 2 comments

Comments

@Jzow
Copy link
Member

Jzow commented Oct 26, 2023

Usually, the training of models and reasoning is done through the low-level implementation, so we will not use Java to train models and reasoning regarding the air module.

  1. The first is: because it is within the jvm

  2. The second point is that Java is a high-performance language, but in the AI field, Python and are usually more favored. This is because many AI libraries in Python use high-performance C/C++ implementations at the bottom

[dependencies]
tensorflow = { version = "0.21.0", features = ["tensorflow_gpu"] }
tensorflow-sys = { version = "0.24.0", features = ["tensorflow_gpu"] }

But we chose to use Rust and Tensorflow to train and validate the model, and then Java would call the model code in memory provided by Rust.

Fortunately, we use Java 21 and no longer need to use JNI to call it. Instead, we would choose the methods of external functions and memory API's, such as Arena.

@Benchmark
public int getMemUnitPanama() throws Throwable {
    try (Arena arena = Arena.ofConfined()) {
        MemorySegment info = arena.allocate(sysinfoLayout);
        getMemUnit.invokeExact(info);
        return (int) memUnitHandle.get(info);
    }
}
@Jzow Jzow added the pr: good-first-issue An issue that a contributor can help us with label Oct 26, 2023
@Jzow Jzow pinned this issue Oct 26, 2023
@wansenai-bot wansenai-bot added the status: waiting-for-triage An issue we've not yet triaged label Oct 26, 2023
@Jzow Jzow added type: enhancement A general enhancement and removed pr: good-first-issue An issue that a contributor can help us with labels Oct 26, 2023
@Jzow
Copy link
Member Author

Jzow commented Oct 26, 2023

Supplement: We will collect data and train the model only after completing 70% of the business function development progress

@Jzow Jzow linked a pull request Oct 27, 2023 that will close this issue
@Jzow Jzow added status: pending-design-work and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 31, 2023
@Jzow
Copy link
Member Author

Jzow commented Oct 31, 2023

In the article on infoq, we saw an article about foreign Function & Memory API to Bridge the Gap between Java and Native Libraries

url:
Java External Function API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants