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
import torch | |
from transformers import top_k_top_p_filtering | |
logits = torch.tensor([2.0, 1.8, 1.5, 1.0, 0.5]) | |
words = ["頑張る", "成長する", "学ぶ", "健康", "新しい"] | |
def get_probabilities_hf(temperature, k=None, p=None): | |
scaled_scores = logits / temperature | |
# kとpがNoneの場合、デフォルト値を設定 |
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
val logits = arrayOf(2.0, 1.8, 1.5, 1.0, 0.5) | |
val words = arrayOf("頑張る", "成長する", "学ぶ", "健康", "新しい") | |
fun getProbabilitiesHf(temperature: Double, k: Int? = null, p: Double? = null) { | |
val defaultK = k ?: 0 // kがnullの場合は0(フィルタリングなし) | |
val defaultP = p ?: 1.0 // pがnullの場合は1.0(フィルタリングなし) | |
// スコアを温度でスケーリング | |
val scaledScores = logits.map { it / temperature }.toDoubleArray() | |
println("scaledScores:" + scaledScores.joinToString()) |
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
# You will need to take full responsibility for your action. | |
# only once | |
brew install mitmproxy | |
ifconfig|grep 192.168 |awk '{print $2}'|xargs -IIPADDRESS adb shell settings put global http_proxy IPADDRESS:8083 | |
mitmweb -p 8083 | |
adb shell am start -a android.intent.action.VIEW -d "http://mitm.it" | |
# download and install pem | |
# each time you want to do mitm |
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
// ---- User side (Write every time) ---- | |
val scaffoldState = rememberScaffoldState() | |
val viewModel = hiltViewModel<FooViewModel>() | |
SnackbarMessageEffect( | |
scaffoldState = scaffoldState, | |
messageStateHolder = viewModel | |
) | |
Scaffold(scaffoldState = scaffoldState) { | |
... |
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
// ----UI Layer---- | |
// -UI Layer(UI element)- | |
@AndroidEntryPoint | |
class ArticlesActivity : AppCompatActivity() { | |
// UI 1. ✅ You shouldn't store or keep in memory any application | |
// data or state in your app components | |
lateinit var binding: ActivityArticlesBinding | |
private val articlesViewModel by viewModels<ArticlesViewModel>() |
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
@Stable | |
data class UiModel(val articles: Articles) | |
@Composable | |
fun Composable2(uiModel: UiModel) { | |
Text(text = "Hello $uiModel!") | |
} |
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
data class Articles(val articles: List<Article>) | |
data class Article(val title: String) |
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
@Composable | |
fun Composable1(articles: Articles) { | |
Text(text = "Hello $articles!") | |
} | |
@Stable | |
data class UiModel(val articles: Articles) | |
@Composable | |
fun Composable2(uiModel: UiModel) { |
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
class HogeActivity { | |
val featureFlags = FeatureFlags() | |
@OptIn(AmazingFeature::class) | |
fun onClick() { | |
if (featureFlags.isAmazingFeaturesEnabled()) { | |
brokenAmazingFeatures() | |
} | |
} | |
} |
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
@RequiresOptIn(message = "AmazingFeature should be checked") | |
@Retention(AnnotationRetention.BINARY) | |
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) | |
annotation class AmazingFeature | |
@AmazingFeature | |
fun brokenAmazingFeature() { | |
TODO("aaaaa") | |
} | |
NewerOlder